Skip to content

Commit a9504a5

Browse files
ZZiigguurraattZZiigguurraatt
ZZiigguurraatt
authored and
ZZiigguurraatt
committed
litd_custom_channels_test.go: better commenting of test cases
1 parent c0e0097 commit a9504a5

File tree

1 file changed

+70
-15
lines changed

1 file changed

+70
-15
lines changed

itest/litd_custom_channels_test.go

+70-15
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,11 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
419419
logBalance(t.t, nodes, assetID, "initial")
420420

421421
// ------------
422-
// Test case 1: Send a direct keysend payment from Charlie to Dave,
423-
// sending the whole balance.
422+
// Test case 1: Send a direct asset keysend payment from Charlie to Dave,
423+
// sending the whole asset balance.
424+
//
425+
// Charlie --[assets]--> Dave
426+
//
424427
// ------------
425428
keySendAmount := charlieFundingAmount
426429
sendAssetKeySendPayment(
@@ -466,7 +469,7 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
466469
sendKeySendPayment(t.t, charlie, dave, 2000)
467470
logBalance(t.t, nodes, assetID, "after BTC only keysend")
468471

469-
// Let's keysend the rest of the balance back to Charlie.
472+
// Let's keysend the rest of the asset balance back to Charlie.
470473
sendAssetKeySendPayment(
471474
t.t, dave, charlie, charlieFundingAmount-charlieInvoiceAmount,
472475
assetID, fn.None[int64](),
@@ -477,9 +480,18 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
477480
daveAssetBalance -= charlieFundingAmount - charlieInvoiceAmount
478481

479482
// ------------
480-
// Test case 2: Pay a normal invoice from Dave by Charlie, making it
481-
// a direct channel invoice payment with no RFQ SCID present in the
482-
// invoice.
483+
// Test case 2: Pay a normal sats invoice from Dave by
484+
// Charlie using an asset,
485+
// making it a direct channel invoice payment with no RFQ SCID present in
486+
// the invoice (but an RFQ is used when trying to send the payment). In this
487+
// case, Charlie gets to choose if he wants to pay Dave using assets or
488+
// sats. In contrast, test case 3.5 we have the opposite scenario where
489+
// an asset invoice is used and Charlie must pay with assets and not have
490+
// a choice (and that case is supposed to fail because Charlie tries to
491+
// pay with sats instead).
492+
//
493+
// Charlie --[assets]--> Dave
494+
//
483495
// ------------
484496
createAndPayNormalInvoice(
485497
t.t, charlie, dave, dave, 20_000, assetID, withSmallShards(),
@@ -489,13 +501,17 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
489501

490502
// We should also be able to do a multi-hop BTC only payment, paying an
491503
// invoice from Erin by Charlie.
504+
// Charlie --[assets]--> Dave --[sats]--> Erin
492505
createAndPayNormalInvoiceWithBtc(t.t, charlie, erin, 2000)
493506
logBalance(t.t, nodes, assetID, "after BTC only invoice")
494507

495508
// ------------
496509
// Test case 3: Pay an asset invoice from Dave by Charlie, making it
497510
// a direct channel invoice payment with an RFQ SCID present in the
498511
// invoice.
512+
//
513+
// Charlie --[assets]--> Dave
514+
//
499515
// ------------
500516
const daveInvoiceAssetAmount = 2_000
501517
invoiceResp = createAssetInvoice(
@@ -511,10 +527,20 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
511527
daveAssetBalance += daveInvoiceAssetAmount
512528

513529
// ------------
514-
// Test case 3.5: Pay an asset invoice from Dave by Charlie with normal
530+
// Test case 3.5: Pay an asset invoice with an RFQ SCID present from Dave
531+
// by Charlie with normal
515532
// satoshi payment flow. We expect that payment to fail, since it's a
516533
// direct channel payment and the invoice is for assets, not sats. So
517534
// without a conversion, it is rejected by the receiver.
535+
// Normally, sats is the standard and we can always pay a taproot assets
536+
// invoice with sats, but this special case where it is a direct channel
537+
// payment, the fact that Dave requested specifically to receive a
538+
// taproot asset from Charlie, that must be honored because Charlie did
539+
// an RFQ with Dave when that invoice was created agreeing that when it
540+
// was paid that Dave would receive taproot asset instead of sats.
541+
//
542+
// Charlie --[assets]--> Dave
543+
//
518544
// ------------
519545
invoiceResp = createAssetInvoice(
520546
t.t, charlie, dave, daveInvoiceAssetAmount, assetID,
@@ -530,7 +556,11 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
530556
// as the invoice payment failed.
531557

532558
// ------------
533-
// Test case 4: Pay a normal invoice from Erin by Charlie.
559+
// Test case 4: Pay a normal sats invoice from Erin by Charlie
560+
// using an asset.
561+
//
562+
// Charlie --[assets]--> Dave --[sats]--> Erin
563+
//
534564
// ------------
535565
paidAssetAmount := createAndPayNormalInvoice(
536566
t.t, charlie, dave, erin, 20_000, assetID, withSmallShards(),
@@ -542,7 +572,10 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
542572

543573
// ------------
544574
// Test case 5: Create an asset invoice on Fabia and pay it from
545-
// Charlie.
575+
// Charlie using an asset.
576+
//
577+
// Charlie --[assets]--> Dave --[sats]--> Erin --[assets]--> Fabia
578+
//
546579
// ------------
547580
const fabiaInvoiceAssetAmount1 = 1000
548581
invoiceResp = createAssetInvoice(
@@ -563,7 +596,13 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
563596
// Test case 6: Create an asset invoice on Fabia and pay it with just
564597
// BTC from Dave, making sure it ends up being a multipart payment (we
565598
// set the maximum shard size to 80k sat and 15k asset units will be
566-
// more than a single shard).
599+
// more than a single shard). The purpose here is to force testing of multi
600+
// part payments so that we can do so with a simple network instead of
601+
// building a more complicated one that actually needs multi part paymemts
602+
// in order to get the payment to successfully route.
603+
//
604+
// Dave --[sats]--> Erin --[assets]--> Fabia
605+
//
567606
// ------------
568607
const fabiaInvoiceAssetAmount2 = 15_000
569608
invoiceResp = createAssetInvoice(
@@ -579,7 +618,11 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
579618
// Test case 7: Create an asset invoice on Fabia and pay it with assets
580619
// from Charlie, making sure it ends up being a multipart payment as
581620
// well, with the high amount of asset units to send and the hard coded
582-
// 80k sat max shard size.
621+
// 80k sat max shard size. Again, as in test case 6 above, we are doing
622+
// this here to test multi part payments in a simpler way.
623+
//
624+
// Charlie --[assets]--> Dave --[sats]--> Erin --[assets]--> Fabia
625+
//
583626
// ------------
584627
const fabiaInvoiceAssetAmount3 = 10_000
585628
invoiceResp = createAssetInvoice(
@@ -599,6 +642,15 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
599642
// ------------
600643
// Test case 8: An invoice payment over two channels that are both asset
601644
// channels.
645+
//
646+
// Charlie --[assets]--> Dave
647+
// |
648+
// |
649+
// [assets]
650+
// |
651+
// v
652+
// Yara
653+
//
602654
// ------------
603655
logBalance(t.t, nodes, assetID, "before asset-to-asset")
604656

@@ -616,8 +668,11 @@ func testCustomChannels(ctx context.Context, net *NetworkHarness,
616668
yaraAssetBalance += yaraInvoiceAssetAmount1
617669

618670
// ------------
619-
// Test case 8: Now we'll close each of the channels, starting with the
671+
// Test case 9: Now we'll close each of the channels, starting with the
620672
// Charlie -> Dave custom channel.
673+
//
674+
// Charlie --[assets]--> Dave
675+
//
621676
// ------------
622677
t.Logf("Closing Charlie -> Dave channel")
623678
closeAssetChannelAndAssert(
@@ -1044,7 +1099,7 @@ func testCustomChannelsGroupedAsset(ctx context.Context, net *NetworkHarness,
10441099
yaraAssetBalance += yaraInvoiceAssetAmount1
10451100

10461101
// ------------
1047-
// Test case 8: Now we'll close each of the channels, starting with the
1102+
// Test case 9: Now we'll close each of the channels, starting with the
10481103
// Charlie -> Dave custom channel.
10491104
// ------------
10501105
t.Logf("Closing Charlie -> Dave channel")
@@ -2899,8 +2954,8 @@ func testCustomChannelsOraclePricing(ctx context.Context, net *NetworkHarness,
28992954
const charlieInvoiceAmount = 104_081_638
29002955
require.EqualValues(t.t, charlieInvoiceAmount, numUnits)
29012956

2902-
// The default routing fees are 1ppm + 1msat per hop, and we have 2
2903-
// hops in total.
2957+
// The default routing fees are 1ppm + 1msat per hop, and we have 3
2958+
// hops in total, but only 1 hop where routing fees are collected in sats.
29042959
charliePaidMSat := addRoutingFee(addRoutingFee(lnwire.MilliSatoshi(
29052960
decodedInvoice.NumMsat,
29062961
)))

0 commit comments

Comments
 (0)