aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-17 14:04:08 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-04-17 14:04:14 -0400
commitc54295c1a2068aab5ea99c0a40eb716e1194d5b6 (patch)
treef49937113a695af97a3b8ed36545b407b5ea88d1 /test
parentd7bdba460cc05a139a1bb67e16cafeb209b206ee (diff)
parentfa320975411af4f0e41771d89958a77fd7a2284b (diff)
Merge #18641: test: Create cached blocks not in the future
fa320975411af4f0e41771d89958a77fd7a2284b test: Create cached blocks not in the future (MarcoFalke) Pull request description: This avoids test failures when tests assume blocks are not from the future, like in wallet_dump: https://cirrus-ci.com/task/6607130193035264?command=ci#L3306 ACKs for top commit: jonatack: ACK fa320975411af4f0e41771d89958a77fd7a2284b Tree-SHA512: 60b6882e0e1df8c5d67f034533407a45d3685983891b67ff4631072bfd0a93a325c7ca18758d7a2df252e4fcdb7c87321cb1e84458b22782e57e719eec634c22
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/test_framework/test_framework.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index e36fb350c6..d4cf5f8896 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -549,9 +549,13 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
cwd=self.options.tmpdir,
))
self.start_node(CACHE_NODE_ID)
+ cache_node = self.nodes[CACHE_NODE_ID]
# Wait for RPC connections to be ready
- self.nodes[CACHE_NODE_ID].wait_for_rpc_connection()
+ cache_node.wait_for_rpc_connection()
+
+ # Set a time in the past, so that blocks don't end up in the future
+ cache_node.setmocktime(cache_node.getblockheader(cache_node.getbestblockhash())['time'])
# Create a 199-block-long chain; each of the 4 first nodes
# gets 25 mature blocks and 25 immature.
@@ -560,12 +564,12 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
# This is needed so that we are out of IBD when the test starts,
# see the tip age check in IsInitialBlockDownload().
for i in range(8):
- self.nodes[CACHE_NODE_ID].generatetoaddress(
+ cache_node.generatetoaddress(
nblocks=25 if i != 7 else 24,
address=TestNode.PRIV_KEYS[i % 4].address,
)
- assert_equal(self.nodes[CACHE_NODE_ID].getblockchaininfo()["blocks"], 199)
+ assert_equal(cache_node.getblockchaininfo()["blocks"], 199)
# Shut it down, and clean up cache directories:
self.stop_nodes()