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 | |
parent | fab0d858027844f602e9e6103a66d97fdacc13ab (diff) |
qa: Always refresh stale cache to be out of ibd
-rwxr-xr-x | test/functional/feature_proxy.py | 3 | ||||
-rwxr-xr-x | test/functional/mempool_accept.py | 4 | ||||
-rwxr-xr-x | test/functional/test_framework/test_framework.py | 24 |
3 files changed, 25 insertions, 6 deletions
diff --git a/test/functional/feature_proxy.py b/test/functional/feature_proxy.py index 31d2ee8e13..5453f0be3b 100755 --- a/test/functional/feature_proxy.py +++ b/test/functional/feature_proxy.py @@ -41,9 +41,11 @@ from test_framework.netutil import test_ipv6_local RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports + class ProxyTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 4 + self.setup_clean_chain = True def setup_nodes(self): self.have_ipv6 = test_ipv6_local() @@ -198,4 +200,3 @@ class ProxyTest(BitcoinTestFramework): if __name__ == '__main__': ProxyTest().main() - diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py index e2a219b85a..efe720b9b1 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -29,7 +29,6 @@ from test_framework.util import ( assert_raises_rpc_error, bytes_to_hex_str, hex_str_to_bytes, - wait_until, ) @@ -38,7 +37,6 @@ class MempoolAcceptanceTest(BitcoinTestFramework): self.num_nodes = 1 self.extra_args = [[ '-txindex', - '-reindex', # Need reindex for txindex '-acceptnonstdtxn=0', # Try to mimic main-net ]] * self.num_nodes @@ -56,7 +54,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework): self.log.info('Start with empty mempool, and 200 blocks') self.mempool_size = 0 - wait_until(lambda: node.getblockcount() == 200) + assert_equal(node.getblockcount(), 200) assert_equal(node.getmempoolinfo()['size'], self.mempool_size) coins = node.listunspent() 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 = [] |