invoice/test: move payment address optional into test using it

No need for a global when this is only used once.
This commit is contained in:
Carla Kirk-Cohen
2023-07-12 16:57:26 -04:00
parent ceff879f37
commit 40f695743a
2 changed files with 19 additions and 19 deletions

View File

@@ -1504,10 +1504,26 @@ func TestSettleInvoicePaymentAddrRequiredOptionalGrace(t *testing.T) {
require.Equal(t, subscription.PayHash(), &testInvoicePaymentHash)
// Add the invoice, which requires the MPP payload to always be
invoice := &invpkg.Invoice{
Terms: invpkg.ContractTerm{
PaymentPreimage: &testInvoicePreimage,
Value: testInvoiceAmt,
Expiry: time.Hour,
Features: lnwire.NewFeatureVector(
lnwire.NewRawFeatureVector(
lnwire.TLVOnionPayloadOptional,
lnwire.PaymentAddrOptional,
),
lnwire.Features,
),
},
CreationDate: testInvoiceCreationDate,
}
// Add the invoice, which does not require the MPP payload to always be
// included due to its set of feature bits.
addIdx, err := ctx.registry.AddInvoice(
testPayAddrOptionalInvoice, testInvoicePaymentHash,
invoice, testInvoicePaymentHash,
)
require.NoError(t, err)
require.Equal(t, int(addIdx), 1)
@@ -1560,7 +1576,7 @@ func TestSettleInvoicePaymentAddrRequiredOptionalGrace(t *testing.T) {
t.Fatalf("expected state ContractOpen, but got %v",
update.State)
}
if update.AmtPaid != testPayAddrOptionalInvoice.Terms.Value {
if update.AmtPaid != invoice.Terms.Value {
t.Fatal("invoice AmtPaid incorrect")
}
case <-time.After(testTimeout):

View File

@@ -149,22 +149,6 @@ var (
},
CreationDate: testInvoiceCreationDate,
}
testPayAddrOptionalInvoice = &invpkg.Invoice{
Terms: invpkg.ContractTerm{
PaymentPreimage: &testInvoicePreimage,
Value: testInvoiceAmt,
Expiry: time.Hour,
Features: lnwire.NewFeatureVector(
lnwire.NewRawFeatureVector(
lnwire.TLVOnionPayloadOptional,
lnwire.PaymentAddrOptional,
),
lnwire.Features,
),
},
CreationDate: testInvoiceCreationDate,
}
)
func newTestChannelDB(t *testing.T, clock clock.Clock) (*channeldb.DB, error) {