Skip to content

Commit f3c6e15

Browse files
committed
test: script checking skipped in reindex assumevalid
1 parent 010aa53 commit f3c6e15

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

test/functional/feature_assumevalid.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
block #1 that is not part of the assumevalid chain.
3434
- node5 starts with no -assumevalid parameter. Reindex to hit
3535
"assumevalid hash not in headers" and "below minimum chainwork".
36+
- node6 has -assumevalid set to the hash of block 102. Reindex
37+
with assumevalid to check that script verification is skipped during
38+
reindexing.
3639
"""
3740

3841
from test_framework.blocktools import (
@@ -69,7 +72,7 @@ def send_header_for_blocks(self, new_blocks):
6972
class AssumeValidTest(BitcoinTestFramework):
7073
def set_test_params(self):
7174
self.setup_clean_chain = True
72-
self.num_nodes = 6
75+
self.num_nodes = 7
7376
self.rpc_timeout = 120
7477

7578
def setup_network(self):
@@ -148,6 +151,7 @@ def run_test(self):
148151
self.start_node(3, extra_args=[f"-assumevalid={block102.hash_hex}"])
149152
self.start_node(4, extra_args=[f"-assumevalid={block102.hash_hex}"])
150153
self.start_node(5)
154+
self.start_node(6, extra_args=[f"-assumevalid={block102.hash_hex}"])
151155

152156

153157
# nodes[0]
@@ -253,6 +257,27 @@ def run_test(self):
253257
self.restart_node(5, extra_args=["-reindex-chainstate", f"-assumevalid={block102.hash_hex}", "-minimumchainwork=0xffff"])
254258
assert_equal(self.nodes[5].getblockcount(), 1)
255259

260+
# nodes[6]
261+
# Reindex with assumevalid set to block102. Should skip script verification
262+
p2p6 = self.nodes[6].add_p2p_connection(BaseNode())
263+
p2p6.send_header_for_blocks(self.blocks[0:2000])
264+
p2p6.send_header_for_blocks(self.blocks[2000:])
265+
for block in self.blocks[0:101]:
266+
p2p6.send_without_ping(msg_block(block))
267+
self.wait_until(lambda: self.nodes[6].getblockcount() == 101)
268+
# Set minimumchainwork > 2000 blocks to force background init thread
269+
# to wait for best_header to reach 2 weeks before connecting blocks.
270+
self.restart_node(6, extra_args=["-reindex", f"-assumevalid={block102.hash_hex}", "-minimumchainwork=0x0fd2"])
271+
p2p6 = self.nodes[6].add_p2p_connection(BaseNode())
272+
with self.nodes[6].assert_debug_log(expected_msgs=[
273+
f"Disabling script verification at block #1 ({self.blocks[0].hash_hex}).",
274+
]):
275+
p2p6.send_header_for_blocks(self.blocks[0:2000])
276+
p2p6.send_header_for_blocks(self.blocks[2000:])
277+
# Resend headers because HeadersSync m_download_state will be in REDOWNLOAD
278+
p2p6.send_header_for_blocks(self.blocks[0:2000])
279+
p2p6.send_header_for_blocks(self.blocks[2000:])
280+
self.wait_until(lambda: self.nodes[6].getblockcount() == 101)
256281

257282
if __name__ == '__main__':
258283
AssumeValidTest(__file__).main()

0 commit comments

Comments
 (0)