Skip to content

Commit fd9adaf

Browse files
authored
Merge pull request #7646 from yyforyongyu/itest-reduce-blocks
itest: mine less blocks to speed up tests
2 parents ae30581 + 1dc6630 commit fd9adaf

File tree

3 files changed

+85
-66
lines changed

3 files changed

+85
-66
lines changed

itest/list_on_test.go

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,10 @@ var allTestCases = []*lntest.TestCase{
1313
Name: "basic funding flow",
1414
TestFunc: testBasicChannelFunding,
1515
},
16-
{
17-
Name: "multi hop htlc local timeout",
18-
TestFunc: testMultiHopHtlcLocalTimeout,
19-
},
2016
{
2117
Name: "multi hop receiver chain claim",
2218
TestFunc: testMultiHopReceiverChainClaim,
2319
},
24-
{
25-
Name: "multi hop local force close on-chain htlc timeout",
26-
TestFunc: testMultiHopLocalForceCloseOnChainHtlcTimeout,
27-
},
28-
{
29-
Name: "multi hop remote force close on-chain htlc timeout",
30-
TestFunc: testMultiHopRemoteForceCloseOnChainHtlcTimeout,
31-
},
32-
{
33-
Name: "multi hop htlc local chain claim",
34-
TestFunc: testMultiHopHtlcLocalChainClaim,
35-
},
36-
{
37-
Name: "multi hop htlc remote chain claim",
38-
TestFunc: testMultiHopHtlcRemoteChainClaim,
39-
},
40-
{
41-
Name: "multi hop htlc aggregation",
42-
TestFunc: testMultiHopHtlcAggregation,
43-
},
4420
{
4521
Name: "external channel funding",
4622
TestFunc: testExternalFundingChanPoint,
@@ -145,14 +121,6 @@ var allTestCases = []*lntest.TestCase{
145121
Name: "send update disable channel",
146122
TestFunc: testSendUpdateDisableChannel,
147123
},
148-
{
149-
Name: "private channel update policy",
150-
TestFunc: testUpdateChannelPolicyForPrivateChannel,
151-
},
152-
{
153-
Name: "update channel policy fee rate accuracy",
154-
TestFunc: testUpdateChannelPolicyFeeRateAccuracy,
155-
},
156124
{
157125
Name: "connection timeout",
158126
TestFunc: testNetworkConnectionTimeout,
@@ -165,6 +133,26 @@ var allTestCases = []*lntest.TestCase{
165133
Name: "addpeer config",
166134
TestFunc: testAddPeerConfig,
167135
},
136+
{
137+
Name: "multi hop htlc local timeout",
138+
TestFunc: testMultiHopHtlcLocalTimeout,
139+
},
140+
{
141+
Name: "multi hop local force close on-chain htlc timeout",
142+
TestFunc: testMultiHopLocalForceCloseOnChainHtlcTimeout,
143+
},
144+
{
145+
Name: "multi hop remote force close on-chain htlc timeout",
146+
TestFunc: testMultiHopRemoteForceCloseOnChainHtlcTimeout,
147+
},
148+
{
149+
Name: "private channel update policy",
150+
TestFunc: testUpdateChannelPolicyForPrivateChannel,
151+
},
152+
{
153+
Name: "update channel policy fee rate accuracy",
154+
TestFunc: testUpdateChannelPolicyFeeRateAccuracy,
155+
},
168156
{
169157
Name: "unannounced channels",
170158
TestFunc: testUnannouncedChannels,
@@ -297,6 +285,18 @@ var allTestCases = []*lntest.TestCase{
297285
Name: "REST API",
298286
TestFunc: testRestAPI,
299287
},
288+
{
289+
Name: "multi hop htlc local chain claim",
290+
TestFunc: testMultiHopHtlcLocalChainClaim,
291+
},
292+
{
293+
Name: "multi hop htlc remote chain claim",
294+
TestFunc: testMultiHopHtlcRemoteChainClaim,
295+
},
296+
{
297+
Name: "multi hop htlc aggregation",
298+
TestFunc: testMultiHopHtlcAggregation,
299+
},
300300
{
301301
Name: "revoked uncooperative close retribution",
302302
TestFunc: testRevokedCloseRetribution,
@@ -310,11 +310,6 @@ var allTestCases = []*lntest.TestCase{
310310
Name: "revoked uncooperative close retribution remote hodl",
311311
TestFunc: testRevokedCloseRetributionRemoteHodl,
312312
},
313-
{
314-
Name: "revoked uncooperative close retribution altruist " +
315-
"watchtower",
316-
TestFunc: testRevokedCloseRetributionAltruistWatchtower,
317-
},
318313
{
319314
Name: "single-hop send to route",
320315
TestFunc: testSingleHopSendToRoute,
@@ -519,6 +514,14 @@ var allTestCases = []*lntest.TestCase{
519514
Name: "watchtower session management",
520515
TestFunc: testWatchtowerSessionManagement,
521516
},
517+
{
518+
// NOTE: this test must be put in the same tranche as
519+
// `testWatchtowerSessionManagement` to avoid parallel use of
520+
// the default watchtower port.
521+
Name: "revoked uncooperative close retribution altruist " +
522+
"watchtower",
523+
TestFunc: testRevokedCloseRetributionAltruistWatchtower,
524+
},
522525
{
523526
Name: "channel fundmax",
524527
TestFunc: testChannelFundMax,

itest/lnd_multi-hop_test.go

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,31 +1779,15 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
17791779
)
17801780
}
17811781

1782-
var (
1783-
cancel context.CancelFunc
1784-
acceptStream rpc.AcceptorClient
1785-
)
1786-
// If a zero-conf channel is being opened, the nodes are signalling the
1787-
// zero-conf feature bit. Setup a ChannelAcceptor for the fundee.
1788-
if zeroConf {
1789-
acceptStream, cancel = bob.RPC.ChannelAcceptor()
1790-
go acceptChannel(ht.T, true, acceptStream)
1791-
}
1792-
1782+
// Prepare params for Alice.
17931783
aliceParams := lntest.OpenChannelParams{
17941784
Amt: chanAmt,
17951785
CommitmentType: c,
17961786
FundingShim: aliceFundingShim,
17971787
ZeroConf: zeroConf,
17981788
}
1799-
aliceChanPoint := ht.OpenChannel(alice, bob, aliceParams)
18001789

1801-
// Remove the ChannelAcceptor for Bob.
1802-
if zeroConf {
1803-
cancel()
1804-
}
1805-
1806-
// We'll then create a channel from Bob to Carol. After this channel is
1790+
// We'll create a channel from Bob to Carol. After this channel is
18071791
// open, our topology looks like: A -> B -> C.
18081792
var bobFundingShim *lnrpc.FundingShim
18091793
if c == lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE {
@@ -1812,24 +1796,44 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
18121796
)
18131797
}
18141798

1815-
// Setup a ChannelAcceptor for Carol if a zero-conf channel open is
1816-
// being attempted.
1817-
if zeroConf {
1818-
acceptStream, cancel = carol.RPC.ChannelAcceptor()
1819-
go acceptChannel(ht.T, true, acceptStream)
1820-
}
1821-
1799+
// Prepare params for Bob.
18221800
bobParams := lntest.OpenChannelParams{
18231801
Amt: chanAmt,
18241802
CommitmentType: c,
18251803
FundingShim: bobFundingShim,
18261804
ZeroConf: zeroConf,
18271805
}
1828-
bobChanPoint := ht.OpenChannel(bob, carol, bobParams)
18291806

1830-
// Remove the ChannelAcceptor for Carol.
1807+
var (
1808+
acceptStreamBob rpc.AcceptorClient
1809+
acceptStreamCarol rpc.AcceptorClient
1810+
cancelBob context.CancelFunc
1811+
cancelCarol context.CancelFunc
1812+
)
1813+
1814+
// If a zero-conf channel is being opened, the nodes are signalling the
1815+
// zero-conf feature bit. Setup a ChannelAcceptor for the fundee.
1816+
if zeroConf {
1817+
acceptStreamBob, cancelBob = bob.RPC.ChannelAcceptor()
1818+
go acceptChannel(ht.T, true, acceptStreamBob)
1819+
1820+
acceptStreamCarol, cancelCarol = carol.RPC.ChannelAcceptor()
1821+
go acceptChannel(ht.T, true, acceptStreamCarol)
1822+
}
1823+
1824+
// Open channels in batch to save blocks mined.
1825+
reqs := []*lntest.OpenChannelRequest{
1826+
{Local: alice, Remote: bob, Param: aliceParams},
1827+
{Local: bob, Remote: carol, Param: bobParams},
1828+
}
1829+
resp := ht.OpenMultiChannelsAsync(reqs)
1830+
aliceChanPoint := resp[0]
1831+
bobChanPoint := resp[1]
1832+
1833+
// Remove the ChannelAcceptor for Bob and Carol.
18311834
if zeroConf {
1832-
cancel()
1835+
cancelBob()
1836+
cancelCarol()
18331837
}
18341838

18351839
// Make sure alice and carol know each other's channels.
@@ -1932,6 +1936,11 @@ func runExtraPreimageFromRemoteCommit(ht *lntest.HarnessTest,
19321936
// notice the force close from Carol.
19331937
require.NoError(ht, restartBob())
19341938

1939+
// For anchor channels, Bob should sweep his anchor output.
1940+
if lntest.CommitTypeHasAnchors(c) {
1941+
ht.Miner.AssertNumTxsInMempool(1)
1942+
}
1943+
19351944
// Get the current height to compute number of blocks to mine to
19361945
// trigger the htlc timeout resolver from Bob.
19371946
_, height := ht.Miner.GetBestBlock()

lntest/node/harness_node.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,14 @@ func (hn *HarnessNode) Stop() error {
732732
// manually.
733733
hn.printErrf("found nil RPC clients")
734734
if err := hn.Kill(); err != nil {
735-
return fmt.Errorf("killing process got: %v", err)
735+
// Skip the error if the process is already dead.
736+
if !strings.Contains(
737+
err.Error(), "process already finished",
738+
) {
739+
740+
return fmt.Errorf("killing process got: %w",
741+
err)
742+
}
736743
}
737744
}
738745

0 commit comments

Comments
 (0)