Skip to content

Commit 6e8592e

Browse files
GeorgeTsagkguggero
authored andcommitted
itest: add <354sats payment coverage for custom channels
1 parent c98a70d commit 6e8592e

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

itest/assets_test.go

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

768-
payInvoiceWithSatoshi(t, src, invoiceResp)
768+
payInvoiceWithSatoshi(t, src, invoiceResp, lnrpc.Payment_SUCCEEDED)
769769
}
770770

771771
func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
@@ -791,7 +791,8 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
791791
}
792792

793793
func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
794-
invoice *lnrpc.AddInvoiceResponse) {
794+
invoice *lnrpc.AddInvoiceResponse,
795+
expectedStatus lnrpc.Payment_PaymentStatus) {
795796

796797
ctxb := context.Background()
797798
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -808,7 +809,7 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
808809

809810
result, err := getPaymentResult(stream)
810811
require.NoError(t, err)
811-
require.Equal(t, lnrpc.Payment_SUCCEEDED, result.Status)
812+
require.Equal(t, expectedStatus, result.Status)
812813
}
813814

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

itest/litd_custom_channels_test.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,9 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
504504
invoiceResp = createAssetInvoice(
505505
t.t, charlie, dave, daveInvoiceAssetAmount, assetID,
506506
)
507-
payInvoiceWithSatoshi(t.t, charlie, invoiceResp)
507+
payInvoiceWithSatoshi(
508+
t.t, charlie, invoiceResp, lnrpc.Payment_SUCCEEDED,
509+
)
508510
logBalance(t.t, nodes, assetID, "after asset invoice paid with sats")
509511

510512
// We don't need to update the asset balances of Charlie and Dave here
@@ -547,7 +549,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
547549
invoiceResp = createAssetInvoice(
548550
t.t, erin, fabia, fabiaInvoiceAssetAmount2, assetID,
549551
)
550-
payInvoiceWithSatoshi(t.t, dave, invoiceResp)
552+
payInvoiceWithSatoshi(t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED)
551553
logBalance(t.t, nodes, assetID, "after invoice")
552554

553555
erinAssetBalance -= fabiaInvoiceAssetAmount2
@@ -967,7 +969,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
967969
invoiceResp = createAssetInvoice(
968970
t.t, erin, fabia, fabiaInvoiceAssetAmount2, assetID,
969971
)
970-
payInvoiceWithSatoshi(t.t, dave, invoiceResp)
972+
payInvoiceWithSatoshi(t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED)
971973
logBalance(t.t, nodes, assetID, "after invoice")
972974

973975
erinAssetBalance -= fabiaInvoiceAssetAmount2
@@ -1957,6 +1959,16 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
19571959

19581960
logBalance(t.t, nodes, assetID, "after big asset payment (asset "+
19591961
"invoice, multi-hop)")
1962+
1963+
// Edge case: Now Charlie creates a tiny asset invoice to be paid for by
1964+
// Yara with satoshi. This is a multi-hop payment going over 2 asset
1965+
// channels, where the total asset value is less than the default anchor
1966+
// amount of 354 sats.
1967+
invoiceResp = createAssetInvoice(t.t, dave, charlie, 1, assetID)
1968+
payInvoiceWithSatoshi(t.t, yara, invoiceResp, lnrpc.Payment_FAILED)
1969+
1970+
logBalance(t.t, nodes, assetID, "after small payment (asset "+
1971+
"invoice, <354sats)")
19601972
}
19611973

19621974
// testCustomChannelsBalanceConsistency is a test that test the balance of nodes

0 commit comments

Comments
 (0)