Skip to content

Commit f055328

Browse files
committed
wip
1 parent e0ab462 commit f055328

File tree

2 files changed

+60
-16
lines changed

2 files changed

+60
-16
lines changed

itest/assets_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,9 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
709709

710710
result, err := getAssetPaymentResult(stream, false)
711711
require.NoError(t, err)
712+
if result.Status == lnrpc.Payment_FAILED {
713+
t.Logf("Failure reason: %v", result.FailureReason)
714+
}
712715
require.Equal(t, expectedStatus, result.Status)
713716

714717
expectedReason := failReason.UnwrapOr(

itest/litd_custom_channels_test.go

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var (
5050

5151
shortTimeout = time.Second * 5
5252

53-
defaultPaymentStatus = fn.None[lnrpc.Payment_PaymentStatus]()
53+
defaultPaymentStatusOpt = fn.None[lnrpc.Payment_PaymentStatus]()
5454
)
5555

5656
var (
@@ -230,7 +230,7 @@ func testCustomChannelsLarge(_ context.Context, net *NetworkHarness,
230230
)
231231
payInvoiceWithAssets(
232232
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, false,
233-
defaultPaymentStatus,
233+
defaultPaymentStatusOpt,
234234
)
235235
logBalance(t.t, nodes, assetID, "after invoice")
236236

@@ -245,7 +245,7 @@ func testCustomChannelsLarge(_ context.Context, net *NetworkHarness,
245245

246246
payInvoiceWithAssets(
247247
t.t, fabia, erin, invoiceResp2.PaymentRequest, assetID, false,
248-
defaultPaymentStatus,
248+
defaultPaymentStatusOpt,
249249
)
250250
logBalance(t.t, nodes, assetID, "after invoice 2")
251251

@@ -256,7 +256,7 @@ func testCustomChannelsLarge(_ context.Context, net *NetworkHarness,
256256
)
257257
payInvoiceWithAssets(
258258
t.t, charlie, dave, invoiceResp3.PaymentRequest, assetID, false,
259-
defaultPaymentStatus,
259+
defaultPaymentStatusOpt,
260260
)
261261
logBalance(t.t, nodes, assetID, "after invoice 3")
262262

@@ -448,7 +448,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
448448
)
449449
payInvoiceWithAssets(
450450
t.t, dave, charlie, invoiceResp.PaymentRequest, assetID, true,
451-
defaultPaymentStatus,
451+
defaultPaymentStatusOpt,
452452
)
453453
logBalance(t.t, nodes, assetID, "after invoice back")
454454

@@ -513,7 +513,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
513513
)
514514
payInvoiceWithAssets(
515515
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, true,
516-
defaultPaymentStatus,
516+
defaultPaymentStatusOpt,
517517
)
518518
logBalance(t.t, nodes, assetID, "after invoice")
519519

@@ -558,7 +558,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
558558
)
559559
payInvoiceWithAssets(
560560
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, true,
561-
defaultPaymentStatus,
561+
defaultPaymentStatusOpt,
562562
)
563563
logBalance(t.t, nodes, assetID, "after invoice")
564564

@@ -595,7 +595,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
595595
)
596596
payInvoiceWithAssets(
597597
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, true,
598-
defaultPaymentStatus,
598+
defaultPaymentStatusOpt,
599599
)
600600
logBalance(t.t, nodes, assetID, "after invoice")
601601

@@ -616,7 +616,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
616616
)
617617
payInvoiceWithAssets(
618618
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, true,
619-
defaultPaymentStatus,
619+
defaultPaymentStatusOpt,
620620
)
621621
logBalance(t.t, nodes, assetID, "after asset-to-asset")
622622

@@ -952,7 +952,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
952952
)
953953
payInvoiceWithAssets(
954954
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, true,
955-
defaultPaymentStatus,
955+
defaultPaymentStatusOpt,
956956
)
957957
logBalance(t.t, nodes, assetID, "after invoice")
958958

@@ -990,7 +990,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
990990
)
991991
payInvoiceWithAssets(
992992
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, true,
993-
defaultPaymentStatus,
993+
defaultPaymentStatusOpt,
994994
)
995995
logBalance(t.t, nodes, assetID, "after invoice")
996996

@@ -1027,7 +1027,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
10271027
)
10281028
payInvoiceWithAssets(
10291029
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, true,
1030-
defaultPaymentStatus,
1030+
defaultPaymentStatusOpt,
10311031
)
10321032
logBalance(t.t, nodes, assetID, "after invoice")
10331033

@@ -1048,7 +1048,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
10481048
)
10491049
payInvoiceWithAssets(
10501050
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, true,
1051-
defaultPaymentStatus,
1051+
defaultPaymentStatusOpt,
10521052
)
10531053
logBalance(t.t, nodes, assetID, "after asset-to-asset")
10541054

@@ -1961,7 +1961,7 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
19611961

19621962
payInvoiceWithAssets(
19631963
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, false,
1964-
defaultPaymentStatus,
1964+
defaultPaymentStatusOpt,
19651965
)
19661966

19671967
logBalance(t.t, nodes, assetID, "after big asset payment (asset "+
@@ -2007,7 +2007,7 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
20072007

20082008
payInvoiceWithAssets(
20092009
t.t, yara, dave, invoiceResp.PaymentRequest, assetID, false,
2010-
defaultPaymentStatus,
2010+
defaultPaymentStatusOpt,
20112011
)
20122012

20132013
logBalance(t.t, nodes, assetID, "after big asset payment (asset "+
@@ -2051,6 +2051,47 @@ func testCustomChannelsLiquidityEdgeCases(_ context.Context,
20512051
logBalance(t.t, nodes, assetID, "after failed payment (asset "+
20522052
"invoice, strict forwarding)")
20532053

2054+
// Edge case: Fabia gets all the asset liquidity on her side. Then
2055+
// generates an asset invoice to be paid for with assets by Charlie.
2056+
// Charlie will unleash multiple shards towards Fabia, exhausting the
2057+
// liquidity in the Erin<->Fabia channel. Dave should be able to detect
2058+
// those failures and account for those cancelled HTLCs in the RFQ
2059+
// tracking mechanism. Eventually we will slosh some funds from Fabia
2060+
// back to Erin in order for Erin to be able to forward the rest of the
2061+
// HTLCs, leading to the release of the preimage.
2062+
2063+
// Erin starts by sending half of the assets to Fabia's side. He also
2064+
// sends some raw sats to be used by Fabia later for the sloshing.
2065+
sendAssetKeySendPayment(
2066+
t.t, erin, fabia, 2*bigAssetAmount, assetID,
2067+
fn.None[int64](), lnrpc.Payment_SUCCEEDED,
2068+
fn.None[lnrpc.PaymentFailureReason](),
2069+
)
2070+
sendKeySendPayment(t.t, erin, fabia, 20_000)
2071+
2072+
logBalance(t.t, nodes, assetID, "balance after 1st slosh")
2073+
2074+
invoiceResp = createAssetInvoice(t.t, erin, fabia, 1_000, assetID)
2075+
2076+
go func() {
2077+
// After a small delay (less than the payment timeout) Fabia
2078+
// sloshes back the liquidity to Erin. This should allow the
2079+
// payment by Charlie to eventually complete.
2080+
time.Sleep(time.Second * 2)
2081+
sendAssetKeySendPayment(
2082+
t.t, fabia, erin, 2_000, assetID,
2083+
fn.None[int64](), lnrpc.Payment_SUCCEEDED,
2084+
fn.None[lnrpc.PaymentFailureReason](),
2085+
)
2086+
}()
2087+
2088+
payInvoiceWithAssets(
2089+
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, true,
2090+
defaultPaymentStatusOpt,
2091+
)
2092+
2093+
logBalance(t.t, nodes, assetID, "after htlc track cancel")
2094+
20542095
// Edge case: Charlie negotiates a quote with Dave which has a low max
20552096
// amount (~170k sats). Then Charlie creates an invoice with a total
20562097
// amount slightly larger than the max allowed in the quote (200k sats).
@@ -2652,7 +2693,7 @@ func testCustomChannelsOraclePricing(_ context.Context,
26522693

26532694
numUnits, rate := payInvoiceWithAssets(
26542695
t.t, charlie, dave, invoiceResp.PaymentRequest, assetID, false,
2655-
defaultPaymentStatus,
2696+
defaultPaymentStatusOpt,
26562697
)
26572698
logBalance(t.t, nodes, assetID, "after invoice")
26582699

0 commit comments

Comments
 (0)