Skip to content

Commit 4f6b510

Browse files
authored
Merge pull request #9248 from yyforyongyu/fix-itest
lntest: fix edge assertion and reset min relay fee
2 parents 5a8026a + 7dd9a17 commit 4f6b510

13 files changed

+302
-128
lines changed

itest/lnd_channel_graph_test.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,23 @@ import (
4242
// thus a following operation will fail if it relies on the channel being
4343
// enabled.
4444
func testUpdateChanStatus(ht *lntest.HarnessTest) {
45-
// Create two fresh nodes and open a channel between them.
46-
alice, bob := ht.Alice, ht.Bob
47-
args := []string{
45+
// Prepare params.
46+
chanAmt := btcutil.Amount(100_000)
47+
openChannelParams := lntest.OpenChannelParams{
48+
Amt: chanAmt,
49+
}
50+
cfg := []string{
4851
"--minbackoff=60s",
4952
"--chan-enable-timeout=3s",
5053
"--chan-disable-timeout=6s",
5154
"--chan-status-sample-interval=0.5s",
5255
}
53-
ht.RestartNodeWithExtraArgs(alice, args)
54-
ht.RestartNodeWithExtraArgs(bob, args)
55-
ht.EnsureConnected(alice, bob)
56+
cfgs := [][]string{cfg, cfg}
5657

57-
// Open a channel with 100k satoshis between Alice and Bob with Alice
58-
// being the sole funder of the channel.
59-
chanAmt := btcutil.Amount(100000)
60-
chanPoint := ht.OpenChannel(
61-
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
62-
)
63-
defer ht.CloseChannel(alice, chanPoint)
58+
// Create two fresh nodes and open a channel between them.
59+
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
60+
chanPoint := chanPoints[0]
61+
alice, bob := nodes[0], nodes[1]
6462

6563
// assertEdgeDisabled ensures that Alice has the correct Disabled state
6664
// for given channel from her DescribeGraph.
@@ -237,17 +235,17 @@ func testUnannouncedChannels(ht *lntest.HarnessTest) {
237235
fundingChanPoint := ht.WaitForChannelOpenEvent(chanOpenUpdate)
238236

239237
// Alice should have 1 edge in her graph.
240-
ht.AssertNumEdges(alice, 1, true)
238+
ht.AssertNumActiveEdges(alice, 1, true)
241239

242240
// Channels should not be announced yet, hence Alice should have no
243241
// announced edges in her graph.
244-
ht.AssertNumEdges(alice, 0, false)
242+
ht.AssertNumActiveEdges(alice, 0, false)
245243

246244
// Mine 4 more blocks, and check that the channel is now announced.
247245
ht.MineBlocks(4)
248246

249247
// Give the network a chance to learn that auth proof is confirmed.
250-
ht.AssertNumEdges(alice, 1, false)
248+
ht.AssertNumActiveEdges(alice, 1, false)
251249

252250
// Close the channel used during the test.
253251
ht.CloseChannel(alice, fundingChanPoint)

itest/lnd_misc_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,9 +1421,10 @@ func testSendSelectedCoinsChannelReserve(ht *lntest.HarnessTest) {
14211421
// Create a two-hop network: Alice -> Bob.
14221422
//
14231423
// NOTE: Alice will have one UTXO after the funding.
1424-
_, nodes := createSimpleNetwork(
1425-
ht, []string{"--protocol.anchors"}, 2,
1426-
lntest.OpenChannelParams{
1424+
cfg := []string{"--protocol.anchors"}
1425+
cfgs := [][]string{cfg, cfg}
1426+
_, nodes := ht.CreateSimpleNetwork(
1427+
cfgs, lntest.OpenChannelParams{
14271428
Amt: chanAmt,
14281429
},
14291430
)

itest/lnd_mpp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (m *mppTestScenario) openChannels(r *mppOpenChannelRequest) {
299299
}
300300

301301
// Each node should have exactly 6 edges.
302-
m.ht.AssertNumEdges(hn, len(m.channelPoints), false)
302+
m.ht.AssertNumActiveEdges(hn, len(m.channelPoints), false)
303303
}
304304
}
305305

itest/lnd_open_channel_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
8484
ht.AssertTopologyChannelOpen(bob, chanPoint)
8585

8686
// Alice should now have 1 edge in her graph.
87-
ht.AssertNumEdges(alice, 1, true)
87+
ht.AssertNumActiveEdges(alice, 1, true)
8888

8989
// Now we disconnect Alice's chain backend from the original miner, and
9090
// connect the two miners together. Since the temporary miner knows
@@ -112,7 +112,7 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
112112

113113
// Since the fundingtx was reorged out, Alice should now have no edges
114114
// in her graph.
115-
ht.AssertNumEdges(alice, 0, true)
115+
ht.AssertNumActiveEdges(alice, 0, true)
116116

117117
// Cleanup by mining the funding tx again, then closing the channel.
118118
block = ht.MineBlocksAndAssertNumTxes(1, 1)[0]

itest/lnd_payment_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ func testPaymentSucceededHTLCRemoteSwept(ht *lntest.HarnessTest) {
4141
openChannelParams := lntest.OpenChannelParams{
4242
Amt: chanAmt,
4343
}
44+
cfgs := [][]string{nil, nil}
4445

4546
// Create a two hop network: Alice -> Bob.
46-
chanPoints, nodes := createSimpleNetwork(ht, nil, 2, openChannelParams)
47+
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
4748
chanPoint := chanPoints[0]
4849
alice, bob := nodes[0], nodes[1]
4950

@@ -197,9 +198,10 @@ func runTestPaymentHTLCTimeout(ht *lntest.HarnessTest, restartAlice bool) {
197198
openChannelParams := lntest.OpenChannelParams{
198199
Amt: chanAmt,
199200
}
201+
cfgs := [][]string{nil, nil}
200202

201203
// Create a two hop network: Alice -> Bob.
202-
chanPoints, nodes := createSimpleNetwork(ht, nil, 2, openChannelParams)
204+
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
203205
chanPoint := chanPoints[0]
204206
alice, bob := nodes[0], nodes[1]
205207

@@ -1247,9 +1249,10 @@ func runSendToRouteFailHTLCTimeout(ht *lntest.HarnessTest, restartAlice bool) {
12471249
openChannelParams := lntest.OpenChannelParams{
12481250
Amt: chanAmt,
12491251
}
1252+
cfgs := [][]string{nil, nil}
12501253

12511254
// Create a two hop network: Alice -> Bob.
1252-
chanPoints, nodes := createSimpleNetwork(ht, nil, 2, openChannelParams)
1255+
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
12531256
chanPoint := chanPoints[0]
12541257
alice, bob := nodes[0], nodes[1]
12551258

itest/lnd_route_blinding_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) {
985985
}
986986

987987
// Each node should have exactly numPublic edges.
988-
ht.AssertNumEdges(hn, numPublic, false)
988+
ht.AssertNumActiveEdges(hn, numPublic, false)
989989
}
990990

991991
// Make Dave create an invoice with a blinded path for Alice to pay.
@@ -1156,7 +1156,7 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
11561156
}
11571157

11581158
// Each node should have exactly 5 edges.
1159-
ht.AssertNumEdges(hn, len(channelPoints), false)
1159+
ht.AssertNumActiveEdges(hn, len(channelPoints), false)
11601160
}
11611161

11621162
// Make Dave create an invoice with a blinded path for Alice to pay.
@@ -1325,7 +1325,7 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
13251325
}
13261326

13271327
// Each node should have exactly 5 edges.
1328-
ht.AssertNumEdges(hn, len(channelPoints), false)
1328+
ht.AssertNumActiveEdges(hn, len(channelPoints), false)
13291329
}
13301330

13311331
// Ok now make a payment that must be split to succeed.

itest/lnd_routing_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,12 @@ func testPrivateChannels(ht *lntest.HarnessTest) {
591591

592592
// Carol and Alice should know about 4, while Bob and Dave should only
593593
// know about 3, since one channel is private.
594-
ht.AssertNumEdges(alice, 4, true)
595-
ht.AssertNumEdges(alice, 3, false)
596-
ht.AssertNumEdges(bob, 3, true)
597-
ht.AssertNumEdges(carol, 4, true)
598-
ht.AssertNumEdges(carol, 3, false)
599-
ht.AssertNumEdges(dave, 3, true)
594+
ht.AssertNumActiveEdges(alice, 4, true)
595+
ht.AssertNumActiveEdges(alice, 3, false)
596+
ht.AssertNumActiveEdges(bob, 3, true)
597+
ht.AssertNumActiveEdges(carol, 4, true)
598+
ht.AssertNumActiveEdges(carol, 3, false)
599+
ht.AssertNumActiveEdges(dave, 3, true)
600600

601601
// Close all channels.
602602
ht.CloseChannel(alice, chanPointAlice)
@@ -1525,8 +1525,9 @@ func testRouteFeeCutoff(ht *lntest.HarnessTest) {
15251525
func testFeeLimitAfterQueryRoutes(ht *lntest.HarnessTest) {
15261526
// Create a three hop network: Alice -> Bob -> Carol.
15271527
chanAmt := btcutil.Amount(100000)
1528-
chanPoints, nodes := createSimpleNetwork(
1529-
ht, []string{}, 3, lntest.OpenChannelParams{Amt: chanAmt},
1528+
cfgs := [][]string{nil, nil, nil}
1529+
chanPoints, nodes := ht.CreateSimpleNetwork(
1530+
cfgs, lntest.OpenChannelParams{Amt: chanAmt},
15301531
)
15311532
alice, bob, carol := nodes[0], nodes[1], nodes[2]
15321533
chanPointAliceBob, chanPointBobCarol := chanPoints[0], chanPoints[1]

itest/lnd_sweep_test.go

Lines changed: 14 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ func testSweepCPFPAnchorOutgoingTimeout(ht *lntest.HarnessTest) {
9898
// swept so we can focus on testing HTLCs.
9999
fmt.Sprintf("--bitcoin.defaultremotedelay=%v", cltvDelta*10),
100100
}
101+
cfgs := [][]string{cfg, cfg, cfg}
102+
101103
openChannelParams := lntest.OpenChannelParams{
102104
Amt: invoiceAmt * 10,
103105
}
104106

105107
// Create a three hop network: Alice -> Bob -> Carol.
106-
chanPoints, nodes := createSimpleNetwork(ht, cfg, 3, openChannelParams)
108+
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
107109

108110
// Unwrap the results.
109111
abChanPoint, bcChanPoint := chanPoints[0], chanPoints[1]
@@ -426,12 +428,14 @@ func testSweepCPFPAnchorIncomingTimeout(ht *lntest.HarnessTest) {
426428
// swept so we can focus on testing HTLCs.
427429
fmt.Sprintf("--bitcoin.defaultremotedelay=%v", cltvDelta*10),
428430
}
431+
cfgs := [][]string{cfg, cfg, cfg}
432+
429433
openChannelParams := lntest.OpenChannelParams{
430434
Amt: invoiceAmt * 10,
431435
}
432436

433437
// Create a three hop network: Alice -> Bob -> Carol.
434-
chanPoints, nodes := createSimpleNetwork(ht, cfg, 3, openChannelParams)
438+
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
435439

436440
// Unwrap the results.
437441
abChanPoint, bcChanPoint := chanPoints[0], chanPoints[1]
@@ -771,12 +775,14 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
771775
// swept so we can focus on testing HTLCs.
772776
fmt.Sprintf("--bitcoin.defaultremotedelay=%v", cltvDelta*10),
773777
}
778+
cfgs := [][]string{cfg, cfg, cfg}
779+
774780
openChannelParams := lntest.OpenChannelParams{
775781
Amt: invoiceAmt * 10,
776782
}
777783

778784
// Create a three hop network: Alice -> Bob -> Carol.
779-
chanPoints, nodes := createSimpleNetwork(ht, cfg, 3, openChannelParams)
785+
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
780786

781787
// Unwrap the results.
782788
abChanPoint, bcChanPoint := chanPoints[0], chanPoints[1]
@@ -1298,13 +1304,15 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
12981304
fmt.Sprintf("--sweeper.nodeadlineconftarget=%v", deadline),
12991305
fmt.Sprintf("--bitcoin.defaultremotedelay=%v", toLocalCSV),
13001306
}
1307+
cfgs := [][]string{cfg, cfg}
1308+
13011309
openChannelParams := lntest.OpenChannelParams{
13021310
Amt: fundAmt,
13031311
PushAmt: bobBalance,
13041312
}
13051313

13061314
// Create a two hop network: Alice -> Bob.
1307-
chanPoints, nodes := createSimpleNetwork(ht, cfg, 2, openChannelParams)
1315+
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
13081316

13091317
// Unwrap the results.
13101318
chanPoint := chanPoints[0]
@@ -1780,67 +1788,6 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
17801788
ht.MineBlocksAndAssertNumTxes(1, 2)
17811789
}
17821790

1783-
// createSimpleNetwork creates the specified number of nodes and makes a
1784-
// topology of `node1 -> node2 -> node3...`. Each node is created using the
1785-
// specified config, the neighbors are connected, and the channels are opened.
1786-
// Each node will be funded with a single UTXO of 1 BTC except the last one.
1787-
func createSimpleNetwork(ht *lntest.HarnessTest, nodeCfg []string,
1788-
numNodes int, p lntest.OpenChannelParams) ([]*lnrpc.ChannelPoint,
1789-
[]*node.HarnessNode) {
1790-
1791-
// Make a slice of nodes.
1792-
nodes := make([]*node.HarnessNode, numNodes)
1793-
1794-
// Create new nodes.
1795-
for i := range nodes {
1796-
nodeName := fmt.Sprintf("Node%q", string(rune('A'+i)))
1797-
n := ht.NewNode(nodeName, nodeCfg)
1798-
nodes[i] = n
1799-
}
1800-
1801-
// Connect the nodes in a chain.
1802-
for i := 1; i < len(nodes); i++ {
1803-
nodeA := nodes[i-1]
1804-
nodeB := nodes[i]
1805-
ht.EnsureConnected(nodeA, nodeB)
1806-
}
1807-
1808-
// Fund all the nodes expect the last one.
1809-
for i := 0; i < len(nodes)-1; i++ {
1810-
node := nodes[i]
1811-
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, node)
1812-
}
1813-
1814-
// Mine 1 block to get the above coins confirmed.
1815-
ht.MineBlocksAndAssertNumTxes(1, numNodes-1)
1816-
1817-
// Open channels in batch to save blocks mined.
1818-
reqs := make([]*lntest.OpenChannelRequest, 0, len(nodes)-1)
1819-
for i := 0; i < len(nodes)-1; i++ {
1820-
nodeA := nodes[i]
1821-
nodeB := nodes[i+1]
1822-
1823-
req := &lntest.OpenChannelRequest{
1824-
Local: nodeA,
1825-
Remote: nodeB,
1826-
Param: p,
1827-
}
1828-
reqs = append(reqs, req)
1829-
}
1830-
resp := ht.OpenMultiChannelsAsync(reqs)
1831-
1832-
// Make sure the nodes know each other's channels if they are public.
1833-
if !p.Private {
1834-
for _, node := range nodes {
1835-
for _, chanPoint := range resp {
1836-
ht.AssertTopologyChannelOpen(node, chanPoint)
1837-
}
1838-
}
1839-
}
1840-
1841-
return resp, nodes
1842-
}
1843-
18441791
// testBumpFee checks that when a new input is requested, it's first bumped via
18451792
// CPFP, then RBF. Along the way, we check the `BumpFee` can properly update
18461793
// the fee function used by supplying new params.
@@ -2185,9 +2132,10 @@ func testBumpForceCloseFee(ht *lntest.HarnessTest) {
21852132
cfg := []string{
21862133
"--protocol.anchors",
21872134
}
2135+
cfgs := [][]string{cfg, cfg}
21882136

21892137
// Create a two hop network: Alice -> Bob.
2190-
chanPoints, nodes := createSimpleNetwork(ht, cfg, 2, openChannelParams)
2138+
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, openChannelParams)
21912139

21922140
// Unwrap the results.
21932141
chanPoint := chanPoints[0]

0 commit comments

Comments
 (0)