mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 15:11:09 +02:00
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:
@@ -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