Skip to content

Commit b8decb8

Browse files
Merge #6521: test: optimization of functional tests
9bec526 test: speed up feature_maxuploadtarget.py - missing changes from backport bitcoin#18494 (Konstantin Akimov) 4d4a1f5 test: speed up feature_mnehf.py a bit more (Konstantin Akimov) 1b3b546 test: speed up feature_mnehf.py functional test (Konstantin Akimov) 0219735 test: speed up functional test feature_llmq_chainlocks.py (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented Functional tests running locally takes too long time; and limitation is not even CPU and RAM for many of them. This PR helps to speed some of the functional tests. ## What was done? Not much has been done, but some of the low-hanging fruit has been picked: - add missing changes from backport bitcoin#18494 which makes `feature_maxuploadtarget.py` much faster - optimize feature_mnehf.py - no need to restart all nodes that often to be sure they work correctly; replaced some sleeps to `wait_until` - optimize feature_llmq_chainlocks.py - change sleeps to `wait_until` with timeout ## How Has This Been Tested? Before this PR: ``` TEST | STATUS | DURATION feature_llmq_chainlocks.py | ✓ Passed | 230 s feature_maxuploadtarget.py | ✓ Passed | 291 s feature_mnehf.py | ✓ Passed | 109 s ALL | ✓ Passed | 630 s (accumulated) ``` With these optimizations: ``` TEST | STATUS | DURATION feature_llmq_chainlocks.py | ✓ Passed | 123 s feature_maxuploadtarget.py | ✓ Passed | 191 s feature_mnehf.py | ✓ Passed | 86 s ALL | ✓ Passed | 400 s (accumulated) ``` CI finishes 2 minutes faster (for non-tsan): https://gitlab.com/dashpay/dash/-/jobs/8739701280 https://gitlab.com/dashpay/dash/-/jobs/8776172870 Size of artefacts on CI is slightly smaller (4 MB smaller for ubsan): 759 -> 755MB. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 9bec526 PastaPastaPasta: utACK 9bec526 Tree-SHA512: 82bab74266733fc231321210e56c3e9d79504b1259b30ad9cd98e5e063ce48dcd7549dec7e4a0297242bc201708a57eb159a2938ba049eab5d3f616a9ead605d
2 parents 1c7039f + 9bec526 commit b8decb8

File tree

3 files changed

+29
-36
lines changed

3 files changed

+29
-36
lines changed

test/functional/feature_llmq_chainlocks.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
1111
'''
1212

13-
import time
1413
from io import BytesIO
1514

1615
from test_framework.messages import CBlock, CCbTx
@@ -84,7 +83,7 @@ def run_test(self):
8483
previous_block_hash = self.nodes[0].getbestblockhash()
8584
for _ in range(2):
8685
block_hash = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
87-
self.wait_for_chainlocked_block_all_nodes(block_hash, expected=False)
86+
self.wait_for_chainlocked_block_all_nodes(block_hash, timeout=5, expected=False)
8887
assert self.nodes[0].getblock(previous_block_hash)["chainlock"]
8988

9089
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 0)
@@ -157,12 +156,10 @@ def run_test(self):
157156
self.nodes[0].invalidateblock(good_tip)
158157
self.log.info("Now try to reorg the chain")
159158
self.generate(self.nodes[0], 2, sync_fun=self.no_op)
160-
time.sleep(6)
161-
assert self.nodes[1].getbestblockhash() == good_tip
159+
self.wait_until(lambda: self.nodes[1].getbestblockhash() == good_tip, timeout=6)
162160
bad_tip = self.generate(self.nodes[0], 2, sync_fun=self.no_op)[-1]
163-
time.sleep(6)
164-
assert self.nodes[0].getbestblockhash() == bad_tip
165-
assert self.nodes[1].getbestblockhash() == good_tip
161+
self.wait_until(lambda: self.nodes[1].getbestblockhash() == good_tip and
162+
self.nodes[0].getbestblockhash() == bad_tip, timeout=6)
166163

167164
self.log.info("Now let the node which is on the wrong chain reorg back to the locked chain")
168165
self.nodes[0].reconsiderblock(good_tip)
@@ -185,8 +182,7 @@ def run_test(self):
185182
self.restart_node(0)
186183
self.nodes[0].invalidateblock(good_fork)
187184
self.restart_node(0)
188-
time.sleep(1)
189-
assert self.nodes[0].getbestblockhash() == good_tip
185+
self.wait_until(lambda: self.nodes[0].getbestblockhash() == good_tip, timeout=5)
190186

191187
self.log.info("Isolate a node and let it create some transactions which won't get IS locked")
192188
force_finish_mnsync(self.nodes[0])
@@ -200,10 +196,15 @@ def run_test(self):
200196
for txid in txs:
201197
tx = self.nodes[0].getrawtransaction(txid, 1)
202198
assert "confirmations" not in tx
203-
time.sleep(1)
204-
node0_tip_block = self.nodes[0].getblock(node0_tip)
205-
assert not node0_tip_block["chainlock"]
206-
assert node0_tip_block["previousblockhash"] == good_tip
199+
200+
def test_cb(self):
201+
node0_tip_block = self.nodes[0].getblock(node0_tip)
202+
if node0_tip_block["chainlock"]:
203+
return False
204+
return node0_tip_block["previousblockhash"] == good_tip
205+
self.wait_until(lambda: test_cb(self), timeout=5)
206+
207+
207208
self.log.info("Disable LLMQ based InstantSend for a very short time (this never gets propagated to other nodes)")
208209
self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 4070908800)
209210
self.log.info("Now the TXs should be included")

test/functional/feature_maxuploadtarget.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ def run_test(self):
121121
getdata_request.inv = [CInv(MSG_BLOCK, big_new_block)]
122122
for i in range(200):
123123
p2p_conns[1].send_and_ping(getdata_request)
124-
p2p_conns[1].sync_with_ping()
125124
assert_equal(p2p_conns[1].block_receive_map[big_new_block], i+1)
126125

127126
self.log.info("Peer 1 able to repeatedly download new block")

test/functional/feature_mnehf.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
66

77
import struct
8-
import time
98
from io import BytesIO
109

1110
from test_framework.authproxy import JSONRPCException
@@ -25,7 +24,7 @@
2524

2625
class MnehfTest(DashTestFramework):
2726
def set_test_params(self):
28-
extra_args = [["-vbparams=testdummy:0:999999999999:0:4:4:4:5:1", "-persistmempool=0"] for _ in range(4)]
27+
extra_args = [["-vbparams=testdummy:0:999999999999:0:4:4:4:5:1", "-persistmempool=0"]] * 4
2928
self.set_dash_test_params(4, 3, extra_args=extra_args)
3029

3130
def skip_test_if_missing_module(self):
@@ -122,8 +121,8 @@ def run_test(self):
122121
node = self.nodes[0]
123122

124123
self.set_sporks()
124+
self.log.info("Consensus rules assume there're no EHF signal before V20")
125125
self.activate_v20()
126-
self.log.info(f"After v20 activation should be plenty of blocks: {node.getblockcount()}")
127126

128127
self.log.info("Mine a quorum...")
129128
self.mine_quorum()
@@ -164,17 +163,15 @@ def run_test(self):
164163
self.generate(node, 1)
165164

166165

167-
self.restart_all_nodes()
168-
169-
for _ in range(4):
166+
for _ in range(4 // 2):
170167
self.check_fork('started')
171-
self.generate(node, 1)
168+
self.generate(node, 2)
172169

173170

174-
for i in range(4):
171+
for i in range(4 // 2):
175172
self.check_fork('locked_in')
176-
self.generate(node, 1)
177-
if i == 7:
173+
self.generate(node, 2)
174+
if i == 1:
178175
self.restart_all_nodes()
179176

180177
self.check_fork('active')
@@ -185,9 +182,8 @@ def run_test(self):
185182
inode.invalidateblock(ehf_blockhash)
186183

187184
self.log.info("Expecting for fork to be defined in next blocks because no MnEHF tx here")
188-
for _ in range(4):
189-
self.check_fork('defined')
190-
self.generate(node, 1)
185+
self.generate(node, 4)
186+
self.check_fork('defined')
191187

192188

193189
self.log.info("Re-sending MnEHF for new fork")
@@ -198,10 +194,9 @@ def run_test(self):
198194
assert tx_sent_2 in node.getblock(ehf_blockhash_2)['tx']
199195

200196
self.log.info(f"Generate some more block to jump to `started` status")
201-
for _ in range(4):
202-
self.generate(node, 1)
197+
self.generate(node, 4)
203198
self.check_fork('started')
204-
self.restart_all_nodes()
199+
self.restart_node(0)
205200
self.check_fork('started')
206201

207202

@@ -226,17 +221,15 @@ def run_test(self):
226221
self.restart_all_nodes(params=[self.mocktime, self.mocktime + 1000000])
227222
self.check_fork('defined')
228223

224+
self.log.info("Wait MNs to sign EHF message")
229225
self.mine_quorum()
230226
self.check_fork('defined')
231227

232-
self.log.info("Waiting a bit to make EHF activating...")
233-
self.mine_quorum()
234-
for _ in range(4 * 4):
235-
time.sleep(1)
228+
def check_ehf_activated(self):
236229
self.bump_mocktime(1)
237230
self.generate(self.nodes[1], 1)
238-
self.check_fork('active')
239-
231+
return get_bip9_details(self.nodes[0], 'testdummy')['status'] == 'active'
232+
self.wait_until(lambda: check_ehf_activated(self))
240233

241234
if __name__ == '__main__':
242235
MnehfTest().main()

0 commit comments

Comments
 (0)