@@ -23,6 +23,7 @@ import (
23
23
"github.com/lightninglabs/taproot-assets/tapscript"
24
24
"github.com/lightningnetwork/lnd/fn"
25
25
"github.com/lightningnetwork/lnd/lnrpc"
26
+ "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
26
27
"github.com/lightningnetwork/lnd/lntest"
27
28
"github.com/lightningnetwork/lnd/lntest/port"
28
29
"github.com/lightningnetwork/lnd/lntest/wait"
@@ -499,18 +500,20 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
499
500
500
501
// ------------
501
502
// 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.
503
506
// ------------
504
507
invoiceResp = createAssetInvoice (
505
508
t .t , charlie , dave , daveInvoiceAssetAmount , assetID ,
506
509
)
507
510
payInvoiceWithSatoshi (
508
- t .t , charlie , invoiceResp , lnrpc .Payment_SUCCEEDED ,
511
+ t .t , charlie , invoiceResp , lnrpc .Payment_FAILED ,
509
512
)
510
513
logBalance (t .t , nodes , assetID , "after asset invoice paid with sats" )
511
514
512
515
// 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 .
514
517
515
518
// ------------
516
519
// Test case 4: Pay a normal invoice from Erin by Charlie.
@@ -1937,13 +1940,13 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
1937
1940
logBalance (t .t , nodes , assetID , "after big asset payment (btc " +
1938
1941
"invoice, direct)" )
1939
1942
1940
- // Dave sends 200k assets and 2k sats to Yara.
1943
+ // Dave sends 200k assets and 5k sats to Yara.
1941
1944
sendAssetKeySendPayment (
1942
1945
t .t , dave , yara , 2 * bigAssetAmount , assetID ,
1943
1946
fn .None [int64 ](), lnrpc .Payment_SUCCEEDED ,
1944
1947
fn .None [lnrpc.PaymentFailureReason ](),
1945
1948
)
1946
- sendKeySendPayment (t .t , dave , yara , 2000 )
1949
+ sendKeySendPayment (t .t , dave , yara , 5_000 )
1947
1950
1948
1951
logBalance (t .t , nodes , assetID , "after 200k assets to Yara" )
1949
1952
@@ -1969,6 +1972,33 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
1969
1972
1970
1973
logBalance (t .t , nodes , assetID , "after small payment (asset " +
1971
1974
"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)" )
1972
2002
}
1973
2003
1974
2004
// testCustomChannelsBalanceConsistency is a test that test the balance of nodes
0 commit comments