@@ -23,6 +23,7 @@ import (
2323 "github.com/lightninglabs/taproot-assets/tapscript"
2424 "github.com/lightningnetwork/lnd/fn"
2525 "github.com/lightningnetwork/lnd/lnrpc"
26+ "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
2627 "github.com/lightningnetwork/lnd/lntest"
2728 "github.com/lightningnetwork/lnd/lntest/port"
2829 "github.com/lightningnetwork/lnd/lntest/wait"
@@ -499,18 +500,20 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
499500
500501 // ------------
501502 // Test case 3.5: Pay an asset invoice from Dave by Charlie with normal
502- // payment flow.
503+ // satoshi payment flow. We expect that payment to fail, since it's a
504+ // direct channel payment and the invoice is for assets, not sats. So
505+ // without a conversion, it is rejected by the receiver.
503506 // ------------
504507 invoiceResp = createAssetInvoice (
505508 t .t , charlie , dave , daveInvoiceAssetAmount , assetID ,
506509 )
507510 payInvoiceWithSatoshi (
508- t .t , charlie , invoiceResp , lnrpc .Payment_SUCCEEDED ,
511+ t .t , charlie , invoiceResp , lnrpc .Payment_FAILED ,
509512 )
510513 logBalance (t .t , nodes , assetID , "after asset invoice paid with sats" )
511514
512515 // We don't need to update the asset balances of Charlie and Dave here
513- // as the invoice was paid with sats .
516+ // as the invoice payment failed .
514517
515518 // ------------
516519 // Test case 4: Pay a normal invoice from Erin by Charlie.
@@ -1937,13 +1940,13 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
19371940 logBalance (t .t , nodes , assetID , "after big asset payment (btc " +
19381941 "invoice, direct)" )
19391942
1940- // Dave sends 200k assets and 2k sats to Yara.
1943+ // Dave sends 200k assets and 5k sats to Yara.
19411944 sendAssetKeySendPayment (
19421945 t .t , dave , yara , 2 * bigAssetAmount , assetID ,
19431946 fn .None [int64 ](), lnrpc .Payment_SUCCEEDED ,
19441947 fn .None [lnrpc.PaymentFailureReason ](),
19451948 )
1946- sendKeySendPayment (t .t , dave , yara , 2000 )
1949+ sendKeySendPayment (t .t , dave , yara , 5_000 )
19471950
19481951 logBalance (t .t , nodes , assetID , "after 200k assets to Yara" )
19491952
@@ -1969,6 +1972,33 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
19691972
19701973 logBalance (t .t , nodes , assetID , "after small payment (asset " +
19711974 "invoice, <354sats)" )
1975+
1976+ // Edge case: Now Charlie creates an asset invoice to be paid for by
1977+ // Yara with satoshi. For the last hop we try to settle the invoice in
1978+ // satoshi, where we will check whether Charlie's strict forwarding
1979+ // works as expected.
1980+ invoiceResp = createAssetInvoice (
1981+ t .t , charlie , dave , 1 , assetID ,
1982+ )
1983+
1984+ ctxb := context .Background ()
1985+ stream , err := dave .InvoicesClient .SubscribeSingleInvoice (
1986+ ctxb , & invoicesrpc.SubscribeSingleInvoiceRequest {
1987+ RHash : invoiceResp .RHash ,
1988+ },
1989+ )
1990+ require .NoError (t .t , err )
1991+
1992+ // Yara pays Dave with enough satoshis, but Charlie will not settle as
1993+ // he expects assets.
1994+ payInvoiceWithSatoshiLastHop (
1995+ t .t , yara , invoiceResp , dave .PubKey [:], lnrpc .Payment_FAILED ,
1996+ )
1997+
1998+ t .lndHarness .LNDHarness .AssertInvoiceState (stream , lnrpc .Invoice_OPEN )
1999+
2000+ logBalance (t .t , nodes , assetID , "after failed payment (asset " +
2001+ "invoice, strict forwarding)" )
19722002}
19732003
19742004// testCustomChannelsBalanceConsistency is a test that test the balance of nodes
0 commit comments