mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 08:02:25 +02:00
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:
@@ -1504,10 +1504,26 @@ func TestSettleInvoicePaymentAddrRequiredOptionalGrace(t *testing.T) {
|
|||||||
|
|
||||||
require.Equal(t, subscription.PayHash(), &testInvoicePaymentHash)
|
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.
|
// included due to its set of feature bits.
|
||||||
addIdx, err := ctx.registry.AddInvoice(
|
addIdx, err := ctx.registry.AddInvoice(
|
||||||
testPayAddrOptionalInvoice, testInvoicePaymentHash,
|
invoice, testInvoicePaymentHash,
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, int(addIdx), 1)
|
require.Equal(t, int(addIdx), 1)
|
||||||
@@ -1560,7 +1576,7 @@ func TestSettleInvoicePaymentAddrRequiredOptionalGrace(t *testing.T) {
|
|||||||
t.Fatalf("expected state ContractOpen, but got %v",
|
t.Fatalf("expected state ContractOpen, but got %v",
|
||||||
update.State)
|
update.State)
|
||||||
}
|
}
|
||||||
if update.AmtPaid != testPayAddrOptionalInvoice.Terms.Value {
|
if update.AmtPaid != invoice.Terms.Value {
|
||||||
t.Fatal("invoice AmtPaid incorrect")
|
t.Fatal("invoice AmtPaid incorrect")
|
||||||
}
|
}
|
||||||
case <-time.After(testTimeout):
|
case <-time.After(testTimeout):
|
||||||
|
@@ -149,22 +149,6 @@ var (
|
|||||||
},
|
},
|
||||||
CreationDate: testInvoiceCreationDate,
|
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) {
|
func newTestChannelDB(t *testing.T, clock clock.Clock) (*channeldb.DB, error) {
|
||||||
|
Reference in New Issue
Block a user