Skip to content

Commit 6e22b52

Browse files
author
MarcoFalke
committed
Merge #21373: test: generate fewer blocks in feature_nulldummy to fix timeouts, speed up
ccd976d test: use 327 fewer blocks in feature_nulldummy (Jon Atack) 68c280f test, refactor: abstract the feature_nulldummy blockheight values (Jon Atack) Pull request description: The resolved timeout issue seen in the CI can be reproduced locally by running `test/functional/feature_nulldummy.py --valgrind --loglevel=debug` Speeds up the normal test runtime for me from 3.8 to 2.2 seconds (debug build). Thanks to Marco Falke for the approach suggestion. ACKs for top commit: AnthonyRonning: reACK ccd976d - ran a few times with the rest of the tests and still passing for me with just the fewer block change. MarcoFalke: review ACK ccd976d 🏝 Tree-SHA512: 38339dca4276d1972e3a5a5ee436da64e9e58fd3b50b186e34b07ade9523ac4c03f6c3869c5f2a59c23b43c44f87e712f8297a01a8d83202049c081e3eeb4445
2 parents ee35532 + ccd976d commit 6e22b52

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

test/functional/feature_nulldummy.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
77
Connect to a single node.
88
Generate 2 blocks (save the coinbases for later).
9-
Generate 427 more blocks.
10-
[Policy/Consensus] Check that NULLDUMMY compliant transactions are accepted in the 430th block.
9+
Generate COINBASE_MATURITY (CB) more blocks to ensure the coinbases are mature.
10+
[Policy/Consensus] Check that NULLDUMMY compliant transactions are accepted in block CB + 3.
1111
[Policy] Check that non-NULLDUMMY transactions are rejected before activation.
12-
[Consensus] Check that the new NULLDUMMY rules are not enforced on the 431st block.
13-
[Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block.
12+
[Consensus] Check that the new NULLDUMMY rules are not enforced on block CB + 4.
13+
[Policy/Consensus] Check that the new NULLDUMMY rules are enforced on block CB + 5.
1414
"""
1515
import time
1616

@@ -20,13 +20,14 @@
2020
from test_framework.test_framework import BitcoinTestFramework
2121
from test_framework.util import assert_equal, assert_raises_rpc_error
2222

23+
COINBASE_MATURITY = 100
2324
NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)"
2425

2526
def trueDummy(tx):
2627
scriptSig = CScript(tx.vin[0].scriptSig)
2728
newscript = []
2829
for i in scriptSig:
29-
if (len(newscript) == 0):
30+
if len(newscript) == 0:
3031
assert len(i) == 0
3132
newscript.append(b'\x51')
3233
else:
@@ -37,13 +38,13 @@ def trueDummy(tx):
3738
class NULLDUMMYTest(BitcoinTestFramework):
3839

3940
def set_test_params(self):
40-
# Need two nodes only so GBT doesn't complain that it's not connected
41+
# Need two nodes so GBT (getblocktemplate) doesn't complain that it's not connected.
4142
self.num_nodes = 2
4243
self.setup_clean_chain = True
4344
# This script tests NULLDUMMY activation, which is part of the 'segwit' deployment, so we go through
4445
# normal segwit activation here (and don't use the default always-on behaviour).
4546
self.extra_args = [[
46-
'-segwitheight=432',
47+
f'-segwitheight={COINBASE_MATURITY + 5}',
4748
'-addresstype=legacy',
4849
]] * 2
4950

@@ -64,16 +65,16 @@ def run_test(self):
6465
wmulti.importaddress(self.ms_address)
6566
wmulti.importaddress(self.wit_ms_address)
6667

67-
self.coinbase_blocks = self.nodes[0].generate(2) # Block 2
68+
self.coinbase_blocks = self.nodes[0].generate(2) # block height = 2
6869
coinbase_txid = []
6970
for i in self.coinbase_blocks:
7071
coinbase_txid.append(self.nodes[0].getblock(i)['tx'][0])
71-
self.nodes[0].generate(427) # Block 429
72+
self.nodes[0].generate(COINBASE_MATURITY) # block height = COINBASE_MATURITY + 2
7273
self.lastblockhash = self.nodes[0].getbestblockhash()
73-
self.lastblockheight = 429
74-
self.lastblocktime = int(time.time()) + 429
74+
self.lastblockheight = COINBASE_MATURITY + 2
75+
self.lastblocktime = int(time.time()) + self.lastblockheight
7576

76-
self.log.info("Test 1: NULLDUMMY compliant base transactions should be accepted to mempool and mined before activation [430]")
77+
self.log.info(f"Test 1: NULLDUMMY compliant base transactions should be accepted to mempool and mined before activation [{COINBASE_MATURITY + 3}]")
7778
test1txs = [create_transaction(self.nodes[0], coinbase_txid[0], self.ms_address, amount=49)]
7879
txid1 = self.nodes[0].sendrawtransaction(test1txs[0].serialize_with_witness().hex(), 0)
7980
test1txs.append(create_transaction(self.nodes[0], txid1, self.ms_address, amount=48))
@@ -87,7 +88,7 @@ def run_test(self):
8788
trueDummy(test2tx)
8889
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test2tx.serialize_with_witness().hex(), 0)
8990

90-
self.log.info("Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [431]")
91+
self.log.info(f"Test 3: Non-NULLDUMMY base transactions should be accepted in a block before activation [{COINBASE_MATURITY + 4}]")
9192
self.block_submit(self.nodes[0], [test2tx], False, True)
9293

9394
self.log.info("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation")
@@ -104,7 +105,7 @@ def run_test(self):
104105
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, test5tx.serialize_with_witness().hex(), 0)
105106
self.block_submit(self.nodes[0], [test5tx], True)
106107

107-
self.log.info("Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [432]")
108+
self.log.info(f"Test 6: NULLDUMMY compliant base/witness transactions should be accepted to mempool and in block after activation [{COINBASE_MATURITY + 5}]")
108109
for i in test6txs:
109110
self.nodes[0].sendrawtransaction(i.serialize_with_witness().hex(), 0)
110111
self.block_submit(self.nodes[0], test6txs, True, True)
@@ -130,5 +131,6 @@ def block_submit(self, node, txs, witness=False, accept=False):
130131
else:
131132
assert_equal(node.getbestblockhash(), self.lastblockhash)
132133

134+
133135
if __name__ == '__main__':
134136
NULLDUMMYTest().main()

0 commit comments

Comments
 (0)