Skip to content

Commit b4dbee3

Browse files
committed
itest: add <354sats payment coverage for custom channels
1 parent e14ada2 commit b4dbee3

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

itest/assets_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ func createAndPayNormalInvoiceWithBtc(t *testing.T, src, dst *HarnessNode,
682682
})
683683
require.NoError(t, err)
684684

685-
payInvoiceWithSatoshi(t, src, invoiceResp)
685+
payInvoiceWithSatoshi(t, src, invoiceResp, lnrpc.Payment_SUCCEEDED)
686686
}
687687

688688
func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
@@ -706,7 +706,8 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
706706
}
707707

708708
func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
709-
invoice *lnrpc.AddInvoiceResponse) {
709+
invoice *lnrpc.AddInvoiceResponse,
710+
expectedStatus lnrpc.Payment_PaymentStatus) {
710711

711712
ctxb := context.Background()
712713
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -723,7 +724,7 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
723724

724725
result, err := getPaymentResult(stream)
725726
require.NoError(t, err)
726-
require.Equal(t, lnrpc.Payment_SUCCEEDED, result.Status)
727+
require.Equal(t, expectedStatus, result.Status)
727728
}
728729

729730
func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,

itest/litd_custom_channels_test.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,9 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
481481
invoiceResp = createAssetInvoice(
482482
t.t, charlie, dave, daveInvoiceAssetAmount, assetID,
483483
)
484-
payInvoiceWithSatoshi(t.t, charlie, invoiceResp)
484+
payInvoiceWithSatoshi(
485+
t.t, charlie, invoiceResp, lnrpc.Payment_SUCCEEDED,
486+
)
485487
logBalance(t.t, nodes, assetID, "after asset invoice paid with sats")
486488

487489
// We don't need to update the asset balances of Charlie and Dave here
@@ -524,7 +526,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
524526
invoiceResp = createAssetInvoice(
525527
t.t, erin, fabia, fabiaInvoiceAssetAmount2, assetID,
526528
)
527-
payInvoiceWithSatoshi(t.t, dave, invoiceResp)
529+
payInvoiceWithSatoshi(t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED)
528530
logBalance(t.t, nodes, assetID, "after invoice")
529531

530532
erinAssetBalance -= fabiaInvoiceAssetAmount2
@@ -952,7 +954,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
952954
invoiceResp = createAssetInvoice(
953955
t.t, erin, fabia, fabiaInvoiceAssetAmount2, assetID,
954956
)
955-
payInvoiceWithSatoshi(t.t, dave, invoiceResp)
957+
payInvoiceWithSatoshi(t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED)
956958
logBalance(t.t, nodes, assetID, "after invoice")
957959

958960
erinAssetBalance -= fabiaInvoiceAssetAmount2
@@ -1940,4 +1942,17 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
19401942

19411943
logBalance(t.t, nodes, assetID, "after big asset payment (asset "+
19421944
"invoice, multi-hop)")
1945+
1946+
// Edge case: Now Charlie creates a tiny asset invoice to be paid for by
1947+
// Yara with satoshi. This is a multi-hop payment going over 2 asset
1948+
// channels, where the total asset value is less than the default anchor
1949+
// amount of 354 sats.
1950+
invoiceResp = createAssetInvoice(
1951+
t.t, dave, charlie, 1, assetID,
1952+
)
1953+
1954+
payInvoiceWithSatoshi(t.t, yara, invoiceResp, lnrpc.Payment_FAILED)
1955+
1956+
logBalance(t.t, nodes, assetID, "after small payment (asset "+
1957+
"invoice, <354sats)")
19431958
}

0 commit comments

Comments
 (0)