Skip to content

Commit

Permalink
itest: add <354sats payment coverage for custom channels
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeTsagk authored and guggero committed Nov 25, 2024
1 parent 5fe92bd commit 389b092
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
7 changes: 4 additions & 3 deletions itest/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ func createAndPayNormalInvoiceWithBtc(t *testing.T, src, dst *HarnessNode,
})
require.NoError(t, err)

payInvoiceWithSatoshi(t, src, invoiceResp)
payInvoiceWithSatoshi(t, src, invoiceResp, lnrpc.Payment_SUCCEEDED)
}

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

func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
invoice *lnrpc.AddInvoiceResponse) {
invoice *lnrpc.AddInvoiceResponse,
expectedStatus lnrpc.Payment_PaymentStatus) {

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

result, err := getPaymentResult(stream)
require.NoError(t, err)
require.Equal(t, lnrpc.Payment_SUCCEEDED, result.Status)
require.Equal(t, expectedStatus, result.Status)
}

func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
Expand Down
18 changes: 15 additions & 3 deletions itest/litd_custom_channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
invoiceResp = createAssetInvoice(
t.t, charlie, dave, daveInvoiceAssetAmount, assetID,
)
payInvoiceWithSatoshi(t.t, charlie, invoiceResp)
payInvoiceWithSatoshi(
t.t, charlie, invoiceResp, lnrpc.Payment_SUCCEEDED,
)
logBalance(t.t, nodes, assetID, "after asset invoice paid with sats")

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

erinAssetBalance -= fabiaInvoiceAssetAmount2
Expand Down Expand Up @@ -967,7 +969,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
invoiceResp = createAssetInvoice(
t.t, erin, fabia, fabiaInvoiceAssetAmount2, assetID,
)
payInvoiceWithSatoshi(t.t, dave, invoiceResp)
payInvoiceWithSatoshi(t.t, dave, invoiceResp, lnrpc.Payment_SUCCEEDED)
logBalance(t.t, nodes, assetID, "after invoice")

erinAssetBalance -= fabiaInvoiceAssetAmount2
Expand Down Expand Up @@ -1957,6 +1959,16 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,

logBalance(t.t, nodes, assetID, "after big asset payment (asset "+
"invoice, multi-hop)")

// Edge case: Now Charlie creates a tiny asset invoice to be paid for by
// Yara with satoshi. This is a multi-hop payment going over 2 asset
// channels, where the total asset value is less than the default anchor
// amount of 354 sats.
invoiceResp = createAssetInvoice(t.t, dave, charlie, 1, assetID)
payInvoiceWithSatoshi(t.t, yara, invoiceResp, lnrpc.Payment_FAILED)

logBalance(t.t, nodes, assetID, "after small payment (asset "+
"invoice, <354sats)")
}

// testCustomChannelsBalanceConsistency is a test that test the balance of nodes
Expand Down

0 comments on commit 389b092

Please sign in to comment.