Skip to content

Commit 9aef462

Browse files
committed
itest: add large payment integration test
1 parent 083650a commit 9aef462

File tree

3 files changed

+152
-0
lines changed

3 files changed

+152
-0
lines changed

itest/assets_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func createTestAssetNetwork(t *harnessTest, net *NetworkHarness, charlieTap,
154154
AssetId: assetID,
155155
PeerPubkey: fabiaTap.node.PubKey[:],
156156
FeeRateSatPerVbyte: 5,
157+
PushSat: 1065,
157158
},
158159
)
159160
require.NoError(t.t, err)

itest/litd_custom_channels_test.go

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,153 @@ const (
8080
startAmount = fundingAmount * 2
8181
)
8282

83+
// testCustomChannelsLarge tests that we can create a network with custom
84+
// channels and send large asset payments over them.
85+
func testCustomChannelsLarge(_ context.Context, net *NetworkHarness,
86+
t *harnessTest) {
87+
88+
lndArgs := slices.Clone(lndArgsTemplate)
89+
litdArgs := slices.Clone(litdArgsTemplate)
90+
91+
// Explicitly set the proof courier as Alice (how has no other role
92+
// other than proof shuffling), otherwise a hashmail courier will be
93+
// used. For the funding transaction, we're just posting it and don't
94+
// expect a true receiver.
95+
zane, err := net.NewNode(
96+
t.t, "Zane", lndArgs, false, true, litdArgs...,
97+
)
98+
require.NoError(t.t, err)
99+
100+
litdArgs = append(litdArgs, fmt.Sprintf(
101+
"--taproot-assets.proofcourieraddr=%s://%s",
102+
proof.UniverseRpcCourierType, zane.Cfg.LitAddr(),
103+
))
104+
105+
// The topology we are going for looks like the following:
106+
//
107+
// Charlie --[assets]--> Dave --[sats]--> Erin --[assets]--> Fabia
108+
// |
109+
// |
110+
// [assets]
111+
// |
112+
// v
113+
// Yara
114+
//
115+
// With [assets] being a custom channel and [sats] being a normal, BTC
116+
// only channel.
117+
// All 5 nodes need to be full litd nodes running in integrated mode
118+
// with tapd included. We also need specific flags to be enabled, so we
119+
// create 5 completely new nodes, ignoring the two default nodes that
120+
// are created by the harness.
121+
charlie, err := net.NewNode(
122+
t.t, "Charlie", lndArgs, false, true, litdArgs...,
123+
)
124+
require.NoError(t.t, err)
125+
126+
dave, err := net.NewNode(t.t, "Dave", lndArgs, false, true, litdArgs...)
127+
require.NoError(t.t, err)
128+
erin, err := net.NewNode(t.t, "Erin", lndArgs, false, true, litdArgs...)
129+
require.NoError(t.t, err)
130+
fabia, err := net.NewNode(
131+
t.t, "Fabia", lndArgs, false, true, litdArgs...,
132+
)
133+
require.NoError(t.t, err)
134+
yara, err := net.NewNode(
135+
t.t, "Yara", lndArgs, false, true, litdArgs...,
136+
)
137+
require.NoError(t.t, err)
138+
139+
nodes := []*HarnessNode{charlie, dave, erin, fabia, yara}
140+
connectAllNodes(t.t, net, nodes)
141+
fundAllNodes(t.t, net, nodes)
142+
143+
// Create the normal channel between Dave and Erin.
144+
t.Logf("Opening normal channel between Dave and Erin...")
145+
channelOp := openChannelAndAssert(
146+
t, net, dave, erin, lntest.OpenChannelParams{
147+
Amt: 10_000_000,
148+
SatPerVByte: 5,
149+
},
150+
)
151+
defer closeChannelAndAssert(t, net, dave, channelOp, false)
152+
153+
// This is the only public channel, we need everyone to be aware of it.
154+
assertChannelKnown(t.t, charlie, channelOp)
155+
assertChannelKnown(t.t, fabia, channelOp)
156+
157+
universeTap := newTapClient(t.t, zane)
158+
charlieTap := newTapClient(t.t, charlie)
159+
daveTap := newTapClient(t.t, dave)
160+
erinTap := newTapClient(t.t, erin)
161+
fabiaTap := newTapClient(t.t, fabia)
162+
yaraTap := newTapClient(t.t, yara)
163+
164+
// Mint an asset on Charlie and sync all nodes to Charlie as the
165+
// universe.
166+
mintedAssets := itest.MintAssetsConfirmBatch(
167+
t.t, t.lndHarness.Miner.Client, charlieTap,
168+
[]*mintrpc.MintAssetRequest{
169+
{
170+
Asset: itestAsset,
171+
},
172+
},
173+
)
174+
cents := mintedAssets[0]
175+
assetID := cents.AssetGenesis.AssetId
176+
177+
t.Logf("Minted %d lightning cents, syncing universes...", cents.Amount)
178+
syncUniverses(t.t, charlieTap, dave, erin, fabia, yara)
179+
t.Logf("Universes synced between all nodes, distributing assets...")
180+
181+
const (
182+
daveFundingAmount = uint64(400_000)
183+
erinFundingAmount = uint64(200_000)
184+
)
185+
charlieFundingAmount := cents.Amount - uint64(2*400_000)
186+
187+
createTestAssetNetwork(
188+
t, net, charlieTap, daveTap, erinTap, fabiaTap, yaraTap,
189+
universeTap, cents, 400_000, charlieFundingAmount,
190+
daveFundingAmount, erinFundingAmount,
191+
)
192+
193+
// Before we start sending out payments, let's make sure each node can
194+
// see the other one in the graph and has all required features.
195+
require.NoError(t.t, t.lndHarness.AssertNodeKnown(charlie, dave))
196+
require.NoError(t.t, t.lndHarness.AssertNodeKnown(dave, charlie))
197+
require.NoError(t.t, t.lndHarness.AssertNodeKnown(dave, yara))
198+
require.NoError(t.t, t.lndHarness.AssertNodeKnown(yara, dave))
199+
require.NoError(t.t, t.lndHarness.AssertNodeKnown(erin, fabia))
200+
require.NoError(t.t, t.lndHarness.AssertNodeKnown(fabia, erin))
201+
require.NoError(t.t, t.lndHarness.AssertNodeKnown(charlie, erin))
202+
203+
// Print initial channel balances.
204+
logBalance(t.t, nodes, assetID, "initial")
205+
206+
// Try larger invoice payments, first from Charlie to Erin, then half
207+
// of the amount back in the other direction.
208+
const fabiaInvoiceAssetAmount = 20_000
209+
invoiceResp := createAssetInvoice(
210+
t.t, erin, fabia, fabiaInvoiceAssetAmount, assetID,
211+
)
212+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp, assetID)
213+
logBalance(t.t, nodes, assetID, "after invoice")
214+
215+
invoiceResp2 := createAssetInvoice(
216+
t.t, dave, charlie, fabiaInvoiceAssetAmount/2, assetID,
217+
)
218+
payInvoiceWithAssets(t.t, fabia, erin, invoiceResp2, assetID)
219+
logBalance(t.t, nodes, assetID, "after invoice 2")
220+
221+
// Now we send a large invoice from Charlie to Dave.
222+
const largeInvoiceAmount = 100_000
223+
invoiceResp3 := createAssetInvoice(
224+
t.t, charlie, dave, largeInvoiceAmount, assetID,
225+
)
226+
payInvoiceWithAssets(t.t, charlie, dave, invoiceResp3, assetID)
227+
logBalance(t.t, nodes, assetID, "after invoice 3")
228+
}
229+
83230
// testCustomChannels tests that we can create a network with custom channels
84231
// and send asset payments over them.
85232
func testCustomChannels(_ context.Context, net *NetworkHarness,

itest/litd_test_list_on_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ var allTestCases = []*testCase{
2424
name: "test custom channels",
2525
test: testCustomChannels,
2626
},
27+
{
28+
name: "test custom channels large",
29+
test: testCustomChannelsLarge,
30+
},
2731
{
2832
name: "test custom channels grouped asset",
2933
test: testCustomChannelsGroupedAsset,

0 commit comments

Comments
 (0)