Fix running individually through test_runner.py, as suggested by @MarcoFalke (#14732)
This commit is contained in:
parent
35739976c1
commit
2474de0265
2 changed files with 8 additions and 18 deletions
|
@ -371,21 +371,6 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
sync_blocks(group)
|
sync_blocks(group)
|
||||||
sync_mempools(group)
|
sync_mempools(group)
|
||||||
|
|
||||||
def enable_mocktime(self):
|
|
||||||
"""Enable mocktime for the script.
|
|
||||||
|
|
||||||
mocktime may be needed for scripts that use the cached version of the
|
|
||||||
blockchain. If the cached version of the blockchain is used without
|
|
||||||
mocktime then the mempools will not sync due to IBD.
|
|
||||||
|
|
||||||
For backward compatibility of the python scripts with previous
|
|
||||||
versions of the cache, this helper function sets mocktime to Jan 1,
|
|
||||||
2014 + (201 * 10 * 60)"""
|
|
||||||
self.mocktime = 1388534400 + (201 * 10 * 60)
|
|
||||||
|
|
||||||
def disable_mocktime(self):
|
|
||||||
self.mocktime = 0
|
|
||||||
|
|
||||||
# Private helper methods. These should not be accessed by the subclass test scripts.
|
# Private helper methods. These should not be accessed by the subclass test scripts.
|
||||||
|
|
||||||
def _start_logging(self):
|
def _start_logging(self):
|
||||||
|
@ -451,6 +436,11 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
node.wait_for_rpc_connection()
|
node.wait_for_rpc_connection()
|
||||||
|
|
||||||
|
# For backward compatibility of the python scripts with previous
|
||||||
|
# versions of the cache, set mocktime to Jan 1,
|
||||||
|
# 2014 + (201 * 10 * 60)"""
|
||||||
|
self.mocktime = 1388534400 + (201 * 10 * 60)
|
||||||
|
|
||||||
# Create a 200-block-long chain; each of the 4 first nodes
|
# Create a 200-block-long chain; each of the 4 first nodes
|
||||||
# gets 25 mature blocks and 25 immature.
|
# gets 25 mature blocks and 25 immature.
|
||||||
# Note: To preserve compatibility with older versions of
|
# Note: To preserve compatibility with older versions of
|
||||||
|
@ -458,7 +448,6 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
#
|
#
|
||||||
# blocks are created with timestamps 10 minutes apart
|
# blocks are created with timestamps 10 minutes apart
|
||||||
# starting from 2010 minutes in the past
|
# starting from 2010 minutes in the past
|
||||||
self.enable_mocktime()
|
|
||||||
block_time = self.mocktime - (201 * 10 * 60)
|
block_time = self.mocktime - (201 * 10 * 60)
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
for peer in range(4):
|
for peer in range(4):
|
||||||
|
@ -472,7 +461,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
# Shut them down, and clean up cache directories:
|
# Shut them down, and clean up cache directories:
|
||||||
self.stop_nodes()
|
self.stop_nodes()
|
||||||
self.nodes = []
|
self.nodes = []
|
||||||
self.disable_mocktime()
|
self.mocktime = 0
|
||||||
|
|
||||||
def cache_path(n, *paths):
|
def cache_path(n, *paths):
|
||||||
return os.path.join(get_datadir_path(self.options.cachedir, n), "regtest", *paths)
|
return os.path.join(get_datadir_path(self.options.cachedir, n), "regtest", *paths)
|
||||||
|
|
|
@ -25,12 +25,13 @@ def tx_from_hex(hexstring):
|
||||||
class ListTransactionsTest(BitcoinTestFramework):
|
class ListTransactionsTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 2
|
self.num_nodes = 2
|
||||||
self.enable_mocktime()
|
|
||||||
|
|
||||||
def skip_test_if_missing_module(self):
|
def skip_test_if_missing_module(self):
|
||||||
self.skip_if_no_wallet()
|
self.skip_if_no_wallet()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
|
self.nodes[0].generate(1) # Get out of IBD
|
||||||
|
self.sync_all()
|
||||||
# Simple send, 0 to 1:
|
# Simple send, 0 to 1:
|
||||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
Loading…
Reference in a new issue