Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 478 Lines • ▼ Show 20 Lines | def _initialize_chain(self): | ||||
emulator=self.options.emulator, | emulator=self.options.emulator, | ||||
)) | )) | ||||
if self.options.phononactivation: | if self.options.phononactivation: | ||||
self.nodes[CACHE_NODE_ID].extend_default_args( | self.nodes[CACHE_NODE_ID].extend_default_args( | ||||
["-phononactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) | ["-phononactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) | ||||
self.start_node(CACHE_NODE_ID) | self.start_node(CACHE_NODE_ID) | ||||
cache_node = self.nodes[CACHE_NODE_ID] | |||||
# Wait for RPC connections to be ready | # 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 | # Create a 199-block-long chain; each of the 4 first nodes | ||||
# gets 25 mature blocks and 25 immature. | # gets 25 mature blocks and 25 immature. | ||||
# The 4th node gets only 24 immature blocks so that the very last | # 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). | # 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, | # This is needed so that we are out of IBD when the test starts, | ||||
# see the tip age check in IsInitialBlockDownload(). | # see the tip age check in IsInitialBlockDownload(). | ||||
for i in range(8): | for i in range(8): | ||||
self.nodes[CACHE_NODE_ID].generatetoaddress( | cache_node.generatetoaddress( | ||||
nblocks=25 if i != 7 else 24, | nblocks=25 if i != 7 else 24, | ||||
address=TestNode.PRIV_KEYS[i % 4].address, | address=TestNode.PRIV_KEYS[i % 4].address, | ||||
) | ) | ||||
assert_equal( | assert_equal(cache_node.getblockchaininfo()["blocks"], 199) | ||||
self.nodes[CACHE_NODE_ID].getblockchaininfo()["blocks"], 199) | |||||
# Shut it down, and clean up cache directories: | # Shut it down, and clean up cache directories: | ||||
self.stop_nodes() | self.stop_nodes() | ||||
self.nodes = [] | self.nodes = [] | ||||
def cache_path(*paths): | def cache_path(*paths): | ||||
return os.path.join(cache_node_dir, "regtest", *paths) | return os.path.join(cache_node_dir, "regtest", *paths) | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |