@@ -17,7 +17,6 @@ import (
1717 "github.com/lightninglabs/taproot-assets/proof"
1818 "github.com/lightninglabs/taproot-assets/rfqmath"
1919 "github.com/lightninglabs/taproot-assets/rfqmsg"
20- "github.com/lightninglabs/taproot-assets/tapchannel"
2120 "github.com/lightninglabs/taproot-assets/taprpc"
2221 "github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
2322 oraclerpc "github.com/lightninglabs/taproot-assets/taprpc/priceoraclerpc"
@@ -1983,20 +1982,61 @@ func testCustomChannelsLiquidityEdgeCases(ctxb context.Context,
19831982 // Yara with satoshi. This is a multi-hop payment going over 2 asset
19841983 // channels, where the total asset value is less than the default anchor
19851984 // amount of 354 sats.
1986- invoiceResp = createAssetInvoice (t .t , dave , charlie , 1 , assetID )
1987- payInvoiceWithSatoshi ( t . t , yara , invoiceResp , withFailure (
1988- lnrpc . Payment_FAILED , failureNoRoute ,
1985+ createAssetInvoice (t .t , dave , charlie , 1 , assetID , withInvoiceErrSubStr (
1986+ "cannot create invoice over 1 asset units, as the minimal " +
1987+ "transportable amount" ,
19891988 ))
19901989
19911990 logBalance (t .t , nodes , assetID , "after small payment (asset " +
19921991 "invoice, <354sats)" )
19931992
1993+ // Edge case: We now create a small BTC invoice on Erin and ask Charlie
1994+ // to pay it with assets. We should get a payment failure as the amount
1995+ // is too small to be paid with assets economically. But a payment is
1996+ // still possible, since the amount is large enough to represent a
1997+ // single unit (17.1 sat per unit).
1998+ btcInvoiceResp , err := erin .AddInvoice (ctxb , & lnrpc.Invoice {
1999+ Memo : "small BTC invoice" ,
2000+ ValueMsat : 18_000 ,
2001+ })
2002+ require .NoError (t .t , err )
2003+ payInvoiceWithAssets (
2004+ t .t , charlie , dave , btcInvoiceResp .PaymentRequest , assetID ,
2005+ withFeeLimit (2_000 ), withPayErrSubStr (
2006+ "rejecting payment of 20000 mSAT" ,
2007+ ),
2008+ )
2009+
2010+ // When we override the uneconomical payment, it should succeed.
2011+ payInvoiceWithAssets (
2012+ t .t , charlie , dave , btcInvoiceResp .PaymentRequest , assetID ,
2013+ withFeeLimit (2_000 ), withAllowOverpay (),
2014+ )
2015+ logBalance (
2016+ t .t , nodes , assetID , "after small payment (BTC invoice 1 sat)" ,
2017+ )
2018+
2019+ // When we try to pay an invoice amount that's smaller than the
2020+ // corresponding value of a single asset unit, the payment will always
2021+ // be rejected, even if we set the allow_uneconomical flag.
2022+ btcInvoiceResp , err = erin .AddInvoice (ctxb , & lnrpc.Invoice {
2023+ Memo : "very small BTC invoice" ,
2024+ ValueMsat : 1_000 ,
2025+ })
2026+ require .NoError (t .t , err )
2027+ payInvoiceWithAssets (
2028+ t .t , charlie , dave , btcInvoiceResp .PaymentRequest , assetID ,
2029+ withFeeLimit (1_000 ), withAllowOverpay (), withPayErrSubStr (
2030+ "rejecting payment of 2000 mSAT" ,
2031+ ),
2032+ )
2033+
19942034 // Edge case: Now Dave creates an asset invoice to be paid for by
19952035 // Yara with satoshi. For the last hop we try to settle the invoice in
19962036 // satoshi, where we will check whether Dave's strict forwarding works
19972037 // as expected. Charlie is only used as a dummy RFQ peer in this case,
19982038 // Yara totally ignored the RFQ hint and pays agnostically with sats.
1999- invoiceResp = createAssetInvoice (t .t , charlie , dave , 1 , assetID )
2039+ invoiceResp = createAssetInvoice (t .t , charlie , dave , 22 , assetID )
20002040
20012041 stream , err := dave .InvoicesClient .SubscribeSingleInvoice (
20022042 ctxb , & invoicesrpc.SubscribeSingleInvoiceRequest {
@@ -2149,7 +2189,7 @@ func testCustomChannelsLiquidityEdgeCases(ctxb context.Context,
21492189 // Now Erin tries to pay the invoice. Since rfq quote cannot satisfy the
21502190 // total amount of the invoice this payment will fail.
21512191 payInvoiceWithSatoshi (
2152- t .t , erin , iResp , withExpectTimeout ( ),
2192+ t .t , erin , iResp , withPayErrSubStr ( "context deadline exceeded" ),
21532193 withFailure (lnrpc .Payment_FAILED , failureNone ),
21542194 )
21552195
@@ -2702,7 +2742,7 @@ func testCustomChannelsOraclePricing(_ context.Context,
27022742 commitFeeP2WSH int64 = 2810
27032743 anchorAmount int64 = 330
27042744 assetHtlcCarryAmount = int64 (
2705- tapchannel . DefaultOnChainHtlcAmount ,
2745+ rfqmath . DefaultOnChainHtlcSat ,
27062746 )
27072747 unbalancedLocalAmount = channelFundingAmount - commitFeeP2TR -
27082748 anchorAmount
0 commit comments