invoices: refactor updateHtlc to return new state
With this refactor updateHtlc is renamed to getUpdatedHtlcState and changed such that it won't change the HTLC's state and resolve time but instead returns whether the change is needed. This change is part of a multi-commit refactor to ensure that all changes to the invoice will be tracked individually.
This commit is contained in:
2 files changed
+56
-32
No files matched your search
@@ -2997,7 +2997,14 @@ func TestUpdateHTLC(t *testing.T) {
|
||||
|
||||
func testUpdateHTLC(t *testing.T, test updateHTLCTest) {
|
||||
htlc := test.input.Copy()
|
||||
_, err := updateHtlc(testNow, htlc, test.invState, test.setID)
|
||||
stateChanged, state, err := getUpdatedHtlcState(
|
||||
htlc, test.invState, test.setID,
|
||||
)
|
||||
if stateChanged {
|
||||
htlc.State = state
|
||||
htlc.ResolveTime = testNow
|
||||
}
|
||||
|
||||
require.Equal(t, test.expErr, err)
|
||||
require.Equal(t, test.output, *htlc)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user