Skip to content

Commit 9e81c43

Browse files
Roasbeefguggero
authored andcommitted
itest: make shard size configurable
We don't need to set the shard size in every test, as the max_htlc value in the actual routing network will force splits if needed. When we go to send a large payment, with this value, and the default max parts value of 16, we'll never be able to send enough shards to finalize a payment amount.
1 parent 96da2e9 commit 9e81c43

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

itest/assets_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ func createAndPayNormalInvoiceWithBtc(t *testing.T, src, dst *HarnessNode,
663663
}
664664

665665
func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
666-
amountSat btcutil.Amount, assetID []byte) uint64 {
666+
amountSat btcutil.Amount, assetID []byte, smallShards bool) uint64 {
667667

668668
ctxb := context.Background()
669669
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -677,7 +677,9 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
677677
})
678678
require.NoError(t, err)
679679

680-
return payInvoiceWithAssets(t, src, rfqPeer, invoiceResp, assetID)
680+
return payInvoiceWithAssets(
681+
t, src, rfqPeer, invoiceResp, assetID, smallShards,
682+
)
681683
}
682684

683685
func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
@@ -704,7 +706,8 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
704706
}
705707

706708
func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
707-
invoice *lnrpc.AddInvoiceResponse, assetID []byte) uint64 {
709+
invoice *lnrpc.AddInvoiceResponse, assetID []byte,
710+
smallShards bool) uint64 {
708711

709712
ctxb := context.Background()
710713
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -783,9 +786,13 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
783786
PaymentRequest: invoice.PaymentRequest,
784787
TimeoutSeconds: 2,
785788
FirstHopCustomRecords: encodeResp.CustomRecords,
786-
MaxShardSizeMsat: 80_000_000,
787789
FeeLimitMsat: 1_000_000,
788790
}
791+
792+
if smallShards {
793+
sendReq.MaxShardSizeMsat = 80_000_000
794+
}
795+
789796
stream, err := payer.RouterClient.SendPaymentV2(ctxt, sendReq)
790797
require.NoError(t, err)
791798

itest/litd_custom_channels_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,21 +209,21 @@ func testCustomChannelsLarge(_ context.Context, net *NetworkHarness,
209209
invoiceResp := createAssetInvoice(
210210
t.t, erin, fabia, fabiaInvoiceAssetAmount, assetID,
211211
)
212-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
212+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID, false)
213213
logBalance(t.t, nodes, assetID, "after invoice")
214214

215215
invoiceResp2 := createAssetInvoice(
216216
t.t, dave, charlie, fabiaInvoiceAssetAmount/2, assetID,
217217
)
218-
payInvoiceWithAssets(t.t, fabia, erin, invoiceResp2, assetID)
218+
payInvoiceWithAssets(t.t, fabia, erin, invoiceResp2, assetID, false)
219219
logBalance(t.t, nodes, assetID, "after invoice 2")
220220

221221
// Now we send a large invoice from Charlie to Dave.
222222
const largeInvoiceAmount = 100_000
223223
invoiceResp3 := createAssetInvoice(
224224
t.t, charlie, dave, largeInvoiceAmount, assetID,
225225
)
226-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp3, assetID)
226+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp3, assetID, false)
227227
logBalance(t.t, nodes, assetID, "after invoice 3")
228228
}
229229

@@ -380,7 +380,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
380380
invoiceResp := createAssetInvoice(
381381
t.t, dave, charlie, keySendAmount, assetID,
382382
)
383-
payInvoiceWithAssets(t.t, dave, charlie, invoiceResp, assetID)
383+
payInvoiceWithAssets(t.t, dave, charlie, invoiceResp, assetID, true)
384384

385385
charlieAssetBalance += keySendAmount
386386
daveAssetBalance -= keySendAmount
@@ -395,7 +395,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
395395
// invoice.
396396
// ------------
397397
paidAssetAmount := createAndPayNormalInvoice(
398-
t.t, charlie, dave, dave, 20_000, assetID,
398+
t.t, charlie, dave, dave, 20_000, assetID, true,
399399
)
400400
logBalance(t.t, nodes, assetID, "after invoice")
401401

@@ -416,7 +416,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
416416
invoiceResp = createAssetInvoice(
417417
t.t, charlie, dave, daveInvoiceAssetAmount, assetID,
418418
)
419-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
419+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID, true)
420420
logBalance(t.t, nodes, assetID, "after invoice")
421421

422422
charlieAssetBalance -= daveInvoiceAssetAmount
@@ -426,7 +426,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
426426
// Test case 4: Pay a normal invoice from Erin by Charlie.
427427
// ------------
428428
paidAssetAmount = createAndPayNormalInvoice(
429-
t.t, charlie, dave, erin, 20_000, assetID,
429+
t.t, charlie, dave, erin, 20_000, assetID, true,
430430
)
431431
logBalance(t.t, nodes, assetID, "after invoice")
432432

@@ -441,7 +441,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
441441
invoiceResp = createAssetInvoice(
442442
t.t, erin, fabia, fabiaInvoiceAssetAmount1, assetID,
443443
)
444-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
444+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID, true)
445445
logBalance(t.t, nodes, assetID, "after invoice")
446446

447447
charlieAssetBalance -= fabiaInvoiceAssetAmount1
@@ -475,7 +475,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
475475
invoiceResp = createAssetInvoice(
476476
t.t, erin, fabia, fabiaInvoiceAssetAmount3, assetID,
477477
)
478-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
478+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID, true)
479479
logBalance(t.t, nodes, assetID, "after invoice")
480480

481481
charlieAssetBalance -= fabiaInvoiceAssetAmount3
@@ -493,7 +493,7 @@ func testCustomChannels(_ context.Context, net *NetworkHarness,
493493
invoiceResp = createAssetInvoice(
494494
t.t, dave, yara, yaraInvoiceAssetAmount1, assetID,
495495
)
496-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
496+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID, true)
497497
logBalance(t.t, nodes, assetID, "after asset-to-asset")
498498

499499
charlieAssetBalance -= yaraInvoiceAssetAmount1
@@ -821,7 +821,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
821821
// invoice.
822822
// ------------
823823
paidAssetAmount := createAndPayNormalInvoice(
824-
t.t, charlie, dave, dave, 20_000, assetID,
824+
t.t, charlie, dave, dave, 20_000, assetID, true,
825825
)
826826
logBalance(t.t, nodes, assetID, "after invoice")
827827

@@ -842,7 +842,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
842842
invoiceResp := createAssetInvoice(
843843
t.t, charlie, dave, daveInvoiceAssetAmount, assetID,
844844
)
845-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
845+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID, true)
846846
logBalance(t.t, nodes, assetID, "after invoice")
847847

848848
charlieAssetBalance -= daveInvoiceAssetAmount
@@ -852,7 +852,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
852852
// Test case 4: Pay a normal invoice from Erin by Charlie.
853853
// ------------
854854
paidAssetAmount = createAndPayNormalInvoice(
855-
t.t, charlie, dave, erin, 20_000, assetID,
855+
t.t, charlie, dave, erin, 20_000, assetID, true,
856856
)
857857
logBalance(t.t, nodes, assetID, "after invoice")
858858

@@ -867,7 +867,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
867867
invoiceResp = createAssetInvoice(
868868
t.t, erin, fabia, fabiaInvoiceAssetAmount1, assetID,
869869
)
870-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
870+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID, true)
871871
logBalance(t.t, nodes, assetID, "after invoice")
872872

873873
charlieAssetBalance -= fabiaInvoiceAssetAmount1
@@ -901,7 +901,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
901901
invoiceResp = createAssetInvoice(
902902
t.t, erin, fabia, fabiaInvoiceAssetAmount3, assetID,
903903
)
904-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
904+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID, true)
905905
logBalance(t.t, nodes, assetID, "after invoice")
906906

907907
charlieAssetBalance -= fabiaInvoiceAssetAmount3
@@ -919,7 +919,7 @@ func testCustomChannelsGroupedAsset(_ context.Context, net *NetworkHarness,
919919
invoiceResp = createAssetInvoice(
920920
t.t, dave, yara, yaraInvoiceAssetAmount1, assetID,
921921
)
922-
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
922+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID, true)
923923
logBalance(t.t, nodes, assetID, "after asset-to-asset")
924924

925925
charlieAssetBalance -= yaraInvoiceAssetAmount1

0 commit comments

Comments
 (0)