Skip to content

Commit 3b66307

Browse files
committed
itest: assert failure reason for normal invoice payments
1 parent 6d85f72 commit 3b66307

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

itest/assets_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
719719
expectedReason := failReason.UnwrapOr(
720720
lnrpc.PaymentFailureReason_FAILURE_REASON_NONE,
721721
)
722-
require.Equal(t, result.FailureReason, expectedReason)
722+
require.Equal(t, expectedReason, result.FailureReason)
723723
}
724724

725725
func sendKeySendPayment(t *testing.T, src, dst *HarnessNode,
@@ -772,7 +772,10 @@ func createAndPayNormalInvoiceWithBtc(t *testing.T, src, dst *HarnessNode,
772772
})
773773
require.NoError(t, err)
774774

775-
payInvoiceWithSatoshi(t, src, invoiceResp, lnrpc.Payment_SUCCEEDED)
775+
payInvoiceWithSatoshi(
776+
t, src, invoiceResp, lnrpc.Payment_SUCCEEDED,
777+
fn.None[lnrpc.PaymentFailureReason](),
778+
)
776779
}
777780

778781
func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
@@ -800,7 +803,8 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
800803

801804
func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
802805
invoice *lnrpc.AddInvoiceResponse,
803-
expectedStatus lnrpc.Payment_PaymentStatus) {
806+
expectedStatus lnrpc.Payment_PaymentStatus,
807+
failReason fn.Option[lnrpc.PaymentFailureReason]) {
804808

805809
ctxb := context.Background()
806810
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -818,6 +822,11 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
818822
result, err := getPaymentResult(stream)
819823
require.NoError(t, err)
820824
require.Equal(t, expectedStatus, result.Status)
825+
826+
expectedReason := failReason.UnwrapOr(
827+
lnrpc.PaymentFailureReason_FAILURE_REASON_NONE,
828+
)
829+
require.Equal(t, expectedReason, result.FailureReason)
821830
}
822831

823832
func payInvoiceWithSatoshiLastHop(t *testing.T, payer *HarnessNode,

itest/litd_custom_channels_test.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ var (
4848
shortTimeout = time.Second * 5
4949

5050
defaultPaymentStatus = fn.None[lnrpc.Payment_PaymentStatus]()
51+
52+
// nolint: lll
53+
errNoBalance = lnrpc.PaymentFailureReason_FAILURE_REASON_INSUFFICIENT_BALANCE
54+
errNoRoute = lnrpc.PaymentFailureReason_FAILURE_REASON_NO_ROUTE
55+
errIncorrectDetails = lnrpc.PaymentFailureReason_FAILURE_REASON_INCORRECT_PAYMENT_DETAILS
5156
)
5257

5358
var (
@@ -528,6 +533,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
528533
)
529534
payInvoiceWithSatoshi(
530535
t.t, charlie, invoiceResp, lnrpc.Payment_FAILED,
536+
fn.Some(errIncorrectDetails),
531537
)
532538
logBalance(t.t, nodes, assetID, "after asset invoice paid with sats")
533539

@@ -574,7 +580,10 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
574580
invoiceResp = createAssetInvoice(
575581
t.t, erin, fabia, fabiaInvoiceAssetAmount2, assetID,
576582
)
577-
payInvoiceWithSatoshi(t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED)
583+
payInvoiceWithSatoshi(
584+
t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED,
585+
fn.None[lnrpc.PaymentFailureReason](),
586+
)
578587
logBalance(t.t, nodes, assetID, "after invoice")
579588

580589
erinAssetBalance -= fabiaInvoiceAssetAmount2
@@ -1006,7 +1015,10 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
10061015
invoiceResp = createAssetInvoice(
10071016
t.t, erin, fabia, fabiaInvoiceAssetAmount2, assetID,
10081017
)
1009-
payInvoiceWithSatoshi(t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED)
1018+
payInvoiceWithSatoshi(
1019+
t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED,
1020+
fn.None[lnrpc.PaymentFailureReason](),
1021+
)
10101022
logBalance(t.t, nodes, assetID, "after invoice")
10111023

10121024
erinAssetBalance -= fabiaInvoiceAssetAmount2
@@ -2015,7 +2027,10 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
20152027
// channels, where the total asset value is less than the default anchor
20162028
// amount of 354 sats.
20172029
invoiceResp = createAssetInvoice(t.t, dave, charlie, 1, assetID)
2018-
payInvoiceWithSatoshi(t.t, yara, invoiceResp, lnrpc.Payment_FAILED)
2030+
payInvoiceWithSatoshi(
2031+
t.t, yara, invoiceResp, lnrpc.Payment_FAILED,
2032+
fn.Some(errNoRoute),
2033+
)
20192034

20202035
logBalance(t.t, nodes, assetID, "after small payment (asset "+
20212036
"invoice, <354sats)")
@@ -2686,7 +2701,7 @@ func testCustomChannelsOraclePricing(_ context.Context,
26862701
)
26872702
}
26882703

2689-
// testCustomChannelsFee tests the whether the custom channel funding process
2704+
// testCustomChannelsFee tests whether the custom channel funding process
26902705
// fails if the proposed fee rate is lower than the minimum relay fee.
26912706
func testCustomChannelsFee(_ context.Context,
26922707
net *NetworkHarness, t *harnessTest) {

0 commit comments

Comments
 (0)