Skip to content

Commit fa32097

Browse files
author
MarcoFalke
committed
test: Create cached blocks not in the future
1 parent 4702cad commit fa32097

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/functional/test_framework/test_framework.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,13 @@ def _initialize_chain(self):
549549
cwd=self.options.tmpdir,
550550
))
551551
self.start_node(CACHE_NODE_ID)
552+
cache_node = self.nodes[CACHE_NODE_ID]
552553

553554
# Wait for RPC connections to be ready
554-
self.nodes[CACHE_NODE_ID].wait_for_rpc_connection()
555+
cache_node.wait_for_rpc_connection()
556+
557+
# Set a time in the past, so that blocks don't end up in the future
558+
cache_node.setmocktime(cache_node.getblockheader(cache_node.getbestblockhash())['time'])
555559

556560
# Create a 199-block-long chain; each of the 4 first nodes
557561
# gets 25 mature blocks and 25 immature.
@@ -560,12 +564,12 @@ def _initialize_chain(self):
560564
# This is needed so that we are out of IBD when the test starts,
561565
# see the tip age check in IsInitialBlockDownload().
562566
for i in range(8):
563-
self.nodes[CACHE_NODE_ID].generatetoaddress(
567+
cache_node.generatetoaddress(
564568
nblocks=25 if i != 7 else 24,
565569
address=TestNode.PRIV_KEYS[i % 4].address,
566570
)
567571

568-
assert_equal(self.nodes[CACHE_NODE_ID].getblockchaininfo()["blocks"], 199)
572+
assert_equal(cache_node.getblockchaininfo()["blocks"], 199)
569573

570574
# Shut it down, and clean up cache directories:
571575
self.stop_nodes()

0 commit comments

Comments
 (0)