Skip to content

Commit f557d86

Browse files
committed
itest: assert failure reason for normal invoice payments
1 parent 66f0af1 commit f557d86

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-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: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ 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
5155
)
5256

5357
var (
@@ -528,6 +532,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
528532
)
529533
payInvoiceWithSatoshi(
530534
t.t, charlie, invoiceResp, lnrpc.Payment_FAILED,
535+
fn.None[lnrpc.PaymentFailureReason](),
531536
)
532537
logBalance(t.t, nodes, assetID, "after asset invoice paid with sats")
533538

@@ -574,7 +579,10 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
574579
invoiceResp = createAssetInvoice(
575580
t.t, erin, fabia, fabiaInvoiceAssetAmount2, assetID,
576581
)
577-
payInvoiceWithSatoshi(t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED)
582+
payInvoiceWithSatoshi(
583+
t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED,
584+
fn.None[lnrpc.PaymentFailureReason](),
585+
)
578586
logBalance(t.t, nodes, assetID, "after invoice")
579587

580588
erinAssetBalance -= fabiaInvoiceAssetAmount2
@@ -1006,7 +1014,10 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
10061014
invoiceResp = createAssetInvoice(
10071015
t.t, erin, fabia, fabiaInvoiceAssetAmount2, assetID,
10081016
)
1009-
payInvoiceWithSatoshi(t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED)
1017+
payInvoiceWithSatoshi(
1018+
t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED,
1019+
fn.None[lnrpc.PaymentFailureReason](),
1020+
)
10101021
logBalance(t.t, nodes, assetID, "after invoice")
10111022

10121023
erinAssetBalance -= fabiaInvoiceAssetAmount2
@@ -2015,7 +2026,10 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
20152026
// channels, where the total asset value is less than the default anchor
20162027
// amount of 354 sats.
20172028
invoiceResp = createAssetInvoice(t.t, dave, charlie, 1, assetID)
2018-
payInvoiceWithSatoshi(t.t, yara, invoiceResp, lnrpc.Payment_FAILED)
2029+
payInvoiceWithSatoshi(
2030+
t.t, yara, invoiceResp, lnrpc.Payment_FAILED,
2031+
fn.Some(lnrpc.PaymentFailureReason_FAILURE_REASON_NO_ROUTE),
2032+
)
20192033

20202034
logBalance(t.t, nodes, assetID, "after small payment (asset "+
20212035
"invoice, <354sats)")
@@ -2686,7 +2700,7 @@ func testCustomChannelsOraclePricing(_ context.Context,
26862700
)
26872701
}
26882702

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

0 commit comments

Comments
 (0)