diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-02-11 13:56:19 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-02-19 14:22:13 -0500 |
commit | 1111aecbb58d6e37d430d477ac43f52811fd97d9 (patch) | |
tree | 2ab2e86f5155279ca30701ca1eb03b510bcf347f /test/functional/test_framework | |
parent | fab0d858027844f602e9e6103a66d97fdacc13ab (diff) |
qa: Always refresh stale cache to be out of ibd
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/test_framework.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 49c15112b3..24e1a21a28 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -274,6 +274,17 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): self.add_nodes(self.num_nodes, extra_args) self.start_nodes() self.import_deterministic_coinbase_privkeys() + if not self.setup_clean_chain: + for n in self.nodes: + assert_equal(n.getblockchaininfo()["blocks"], 199) + self.log.debug('Generate a block with current time to finalize the cache and assert we are out of IBD') + block_hash = self.nodes[0].generate(1)[0] + block = self.nodes[0].getblock(blockhash=block_hash, verbosity=0) + for n in self.nodes: + n.submitblock(block) + chain_info = n.getblockchaininfo() + assert_equal(chain_info["blocks"], 200) + assert_equal(chain_info["initialblockdownload"], False) def import_deterministic_coinbase_privkeys(self): for n in self.nodes: @@ -433,7 +444,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): def _initialize_chain(self): """Initialize a pre-mined blockchain for use by the test. - Create a cache of a 200-block-long chain (with wallet) for MAX_NODES + Create a cache of a 199-block-long chain (with wallet) for MAX_NODES Afterward, create num_nodes copies from the cache.""" assert self.num_nodes <= MAX_NODES @@ -476,15 +487,24 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): for node in self.nodes: node.wait_for_rpc_connection() - # Create a 200-block-long chain; each of the 4 first nodes + # Create a 199-block-long chain; each of the 4 first nodes # gets 25 mature blocks and 25 immature. + # The 4th node gets only 24 immature blocks so that the very last + # block in the cache does not age too much (have an old tip age). + # 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(2): for peer in range(4): for j in range(25): + if i == 1 and peer == 3 and j == 24: + break self.nodes[peer].generatetoaddress(1, self.nodes[peer].get_deterministic_priv_key().address) # Must sync before next peer starts generating blocks sync_blocks(self.nodes) + for n in self.nodes: + assert_equal(n.getblockchaininfo()["blocks"], 199) + # Shut them down, and clean up cache directories: self.stop_nodes() self.nodes = [] |