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:
Andras Banki-Horvath committed 2024-02-19 20:47:23 +01:00
1 parent ef5a31733e
commit 342eb4eac2
2 files changed
+56 -32

No files matched your search

+8 -1
View File
@@ -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)
}