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
|
return cdb, cleanUp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const testInvoiceCltvExpiry = 4
|
||||||
|
|
||||||
type mockInvoiceRegistry struct {
|
type mockInvoiceRegistry struct {
|
||||||
settleChan chan lntypes.Hash
|
settleChan chan lntypes.Hash
|
||||||
|
|
||||||
@ -743,7 +745,7 @@ func newMockRegistry(minDelta uint32) *mockInvoiceRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decodeExpiry := func(invoice string) (uint32, error) {
|
decodeExpiry := func(invoice string) (uint32, error) {
|
||||||
return 3, nil
|
return testInvoiceCltvExpiry, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
registry := invoices.NewRegistry(cdb, decodeExpiry)
|
registry := invoices.NewRegistry(cdb, decodeExpiry)
|
||||||
|
@ -527,6 +527,12 @@ func generatePaymentWithPreimage(invoiceAmt, htlcAmt lnwire.MilliSatoshi,
|
|||||||
preimage, rhash [32]byte) (*channeldb.Invoice, *lnwire.UpdateAddHTLC,
|
preimage, rhash [32]byte) (*channeldb.Invoice, *lnwire.UpdateAddHTLC,
|
||||||
error) {
|
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{
|
invoice := &channeldb.Invoice{
|
||||||
CreationDate: time.Now(),
|
CreationDate: time.Now(),
|
||||||
Terms: channeldb.ContractTerm{
|
Terms: channeldb.ContractTerm{
|
||||||
@ -602,8 +608,6 @@ type threeHopNetwork struct {
|
|||||||
func generateHops(payAmt lnwire.MilliSatoshi, startingHeight uint32,
|
func generateHops(payAmt lnwire.MilliSatoshi, startingHeight uint32,
|
||||||
path ...*channelLink) (lnwire.MilliSatoshi, uint32, []ForwardingInfo) {
|
path ...*channelLink) (lnwire.MilliSatoshi, uint32, []ForwardingInfo) {
|
||||||
|
|
||||||
lastHop := path[len(path)-1]
|
|
||||||
|
|
||||||
totalTimelock := startingHeight
|
totalTimelock := startingHeight
|
||||||
runningAmt := payAmt
|
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
|
// If this is the last, hop, then the time lock will be their
|
||||||
// specified delta policy plus our starting height.
|
// specified delta policy plus our starting height.
|
||||||
if i == len(path)-1 {
|
if i == len(path)-1 {
|
||||||
totalTimelock += lastHop.cfg.FwrdingPolicy.TimeLockDelta
|
totalTimelock += testInvoiceCltvExpiry
|
||||||
timeLock = totalTimelock
|
timeLock = totalTimelock
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, the outgoing time lock should be the
|
// Otherwise, the outgoing time lock should be the
|
||||||
|
Loading…
Reference in New Issue
Block a user