From 94e434d2f1d7380fb53e5dc8151c7265e9efd038 Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Wed, 12 Jul 2023 17:09:32 -0400 Subject: [PATCH] invoices/test: move payment address required global into test using it --- invoices/invoiceregistry_test.go | 19 +++++++++++++++++-- invoices/test_utils_test.go | 18 ------------------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/invoices/invoiceregistry_test.go b/invoices/invoiceregistry_test.go index ad47647d1..36591c0d6 100644 --- a/invoices/invoiceregistry_test.go +++ b/invoices/invoiceregistry_test.go @@ -1431,10 +1431,25 @@ func TestSettleInvoicePaymentAddrRequired(t *testing.T) { require.Equal(t, subscription.PayHash(), &testInvoicePaymentHash) + invoice := &invpkg.Invoice{ + Terms: invpkg.ContractTerm{ + PaymentPreimage: &testInvoicePreimage, + Value: testInvoiceAmount, + Expiry: time.Hour, + Features: lnwire.NewFeatureVector( + lnwire.NewRawFeatureVector( + lnwire.TLVOnionPayloadOptional, + lnwire.PaymentAddrRequired, + ), + lnwire.Features, + ), + }, + CreationDate: testInvoiceCreationDate, + } // Add the invoice, which requires the MPP payload to always be // included due to its set of feature bits. addIdx, err := ctx.registry.AddInvoice( - testPayAddrReqInvoice, testInvoicePaymentHash, + invoice, testInvoicePaymentHash, ) require.NoError(t, err) require.Equal(t, int(addIdx), 1) @@ -1467,7 +1482,7 @@ func TestSettleInvoicePaymentAddrRequired(t *testing.T) { // information, so it should be forced to the updateLegacy path then // fail as a required feature bit exists. resolution, err := ctx.registry.NotifyExitHopHtlc( - testInvoicePaymentHash, testPayAddrReqInvoice.Terms.Value, + testInvoicePaymentHash, invoice.Terms.Value, uint32(testCurrentHeight)+testInvoiceCltvDelta-1, testCurrentHeight, getCircuitKey(10), hodlChan, testPayload, ) diff --git a/invoices/test_utils_test.go b/invoices/test_utils_test.go index 854dae92f..13cd11184 100644 --- a/invoices/test_utils_test.go +++ b/invoices/test_utils_test.go @@ -131,24 +131,6 @@ var ( testInvoiceCreationDate = testTime ) -var ( - testPayAddrReqInvoice = &invpkg.Invoice{ - Terms: invpkg.ContractTerm{ - PaymentPreimage: &testInvoicePreimage, - Value: testInvoiceAmount, - Expiry: time.Hour, - Features: lnwire.NewFeatureVector( - lnwire.NewRawFeatureVector( - lnwire.TLVOnionPayloadOptional, - lnwire.PaymentAddrRequired, - ), - lnwire.Features, - ), - }, - CreationDate: testInvoiceCreationDate, - } -) - func newTestChannelDB(t *testing.T, clock clock.Clock) (*channeldb.DB, error) { t.Helper()