mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
htlcswitch/test: align test invoice cltv expiry
This commit is contained in:
parent
af7d0e5ff5
commit
1b2816006f
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user