@@ -2163,6 +2163,41 @@ func testCustomChannelsLiquidityEdgeCases(ctx context.Context,
21632163 )
21642164
21652165 logBalance (t .t , nodes , assetID , "after small manual rfq" )
2166+
2167+ // Edge case: Fabia creates an invoice which Erin cannot satisfy with
2168+ // his side of asset liquidity. This tests that Erin will not try to
2169+ // add an HTLC with more asset units than what his local balance is. To
2170+ // validate that the channel is still healthy, we follow up with a
2171+ // smaller invoice payment which is meant to succeed.
2172+
2173+ // We now create a hodl invoice on Fabia, for 125k assets.
2174+ hodlInv = createAssetHodlInvoice (t .t , erin , fabia , 125_000 , assetID )
2175+
2176+ // Charlie tries to pay, this is not meant to succeed.
2177+ payInvoiceWithAssets (
2178+ t .t , charlie , dave , hodlInv .payReq , assetID ,
2179+ withFailure (lnrpc .Payment_IN_FLIGHT , failureNone ),
2180+ )
2181+
2182+ payHash = hodlInv .preimage .Hash ()
2183+ _ , err = fabia .InvoicesClient .CancelInvoice (
2184+ ctx , & invoicesrpc.CancelInvoiceMsg {
2185+ PaymentHash : payHash [:],
2186+ },
2187+ )
2188+ require .NoError (t .t , err )
2189+
2190+ // Now let's create a smaller invoice and pay it, to validate that the
2191+ // channel is still healthy.
2192+ invoiceResp = createAssetInvoice (
2193+ t .t , erin , fabia , 100 , assetID ,
2194+ )
2195+
2196+ payInvoiceWithAssets (
2197+ t .t , charlie , dave , invoiceResp .PaymentRequest , assetID ,
2198+ )
2199+
2200+ logBalance (t .t , nodes , assetID , "after safe htlc failure" )
21662201}
21672202
21682203// testCustomChannelsStrictForwarding is a test that tests the strict forwarding
0 commit comments