diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index a72dd897..a4d8f1bb 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -728,6 +728,8 @@ func newDB() (*channeldb.DB, func(), error) { return cdb, cleanUp, nil } +const testInvoiceCltvExpiry = 4 + type mockInvoiceRegistry struct { settleChan chan lntypes.Hash @@ -743,7 +745,7 @@ func newMockRegistry(minDelta uint32) *mockInvoiceRegistry { } decodeExpiry := func(invoice string) (uint32, error) { - return 3, nil + return testInvoiceCltvExpiry, nil } registry := invoices.NewRegistry(cdb, decodeExpiry) diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index 960ac08e..89762d75 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -527,6 +527,12 @@ func generatePaymentWithPreimage(invoiceAmt, htlcAmt lnwire.MilliSatoshi, preimage, rhash [32]byte) (*channeldb.Invoice, *lnwire.UpdateAddHTLC, error) { + // Create the db invoice. Normally the payment requests needs to be set, + // because it is decoded in InvoiceRegistry to obtain the cltv expiry. + // But because the mock registry used in tests is mocking the decode + // step and always returning the value of testInvoiceCltvExpiry, we + // don't need to bother here with creating and signing a payment + // request. invoice := &channeldb.Invoice{ CreationDate: time.Now(), Terms: channeldb.ContractTerm{ @@ -602,8 +608,6 @@ type threeHopNetwork struct { func generateHops(payAmt lnwire.MilliSatoshi, startingHeight uint32, path ...*channelLink) (lnwire.MilliSatoshi, uint32, []ForwardingInfo) { - lastHop := path[len(path)-1] - totalTimelock := startingHeight runningAmt := payAmt @@ -620,7 +624,7 @@ func generateHops(payAmt lnwire.MilliSatoshi, startingHeight uint32, // If this is the last, hop, then the time lock will be their // specified delta policy plus our starting height. if i == len(path)-1 { - totalTimelock += lastHop.cfg.FwrdingPolicy.TimeLockDelta + totalTimelock += testInvoiceCltvExpiry timeLock = totalTimelock } else { // Otherwise, the outgoing time lock should be the