Skip to content

Commit 2474de0

Browse files
committed
Fix running individually through test_runner.py, as suggested by @MarcoFalke (#14732)
1 parent 3573997 commit 2474de0

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -371,21 +371,6 @@ def sync_all(self, node_groups=None):
371371
sync_blocks(group)
372372
sync_mempools(group)
373373

374-
def enable_mocktime(self):
375-
"""Enable mocktime for the script.
376-
377-
mocktime may be needed for scripts that use the cached version of the
378-
blockchain. If the cached version of the blockchain is used without
379-
mocktime then the mempools will not sync due to IBD.
380-
381-
For backward compatibility of the python scripts with previous
382-
versions of the cache, this helper function sets mocktime to Jan 1,
383-
2014 + (201 * 10 * 60)"""
384-
self.mocktime = 1388534400 + (201 * 10 * 60)
385-
386-
def disable_mocktime(self):
387-
self.mocktime = 0
388-
389374
# Private helper methods. These should not be accessed by the subclass test scripts.
390375

391376
def _start_logging(self):
@@ -451,14 +436,18 @@ def _initialize_chain(self):
451436
for node in self.nodes:
452437
node.wait_for_rpc_connection()
453438

439+
# For backward compatibility of the python scripts with previous
440+
# versions of the cache, set mocktime to Jan 1,
441+
# 2014 + (201 * 10 * 60)"""
442+
self.mocktime = 1388534400 + (201 * 10 * 60)
443+
454444
# Create a 200-block-long chain; each of the 4 first nodes
455445
# gets 25 mature blocks and 25 immature.
456446
# Note: To preserve compatibility with older versions of
457447
# initialize_chain, only 4 nodes will generate coins.
458448
#
459449
# blocks are created with timestamps 10 minutes apart
460450
# starting from 2010 minutes in the past
461-
self.enable_mocktime()
462451
block_time = self.mocktime - (201 * 10 * 60)
463452
for i in range(2):
464453
for peer in range(4):
@@ -472,7 +461,7 @@ def _initialize_chain(self):
472461
# Shut them down, and clean up cache directories:
473462
self.stop_nodes()
474463
self.nodes = []
475-
self.disable_mocktime()
464+
self.mocktime = 0
476465

477466
def cache_path(n, *paths):
478467
return os.path.join(get_datadir_path(self.options.cachedir, n), "regtest", *paths)

test/functional/wallet_listtransactions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ def tx_from_hex(hexstring):
2525
class ListTransactionsTest(BitcoinTestFramework):
2626
def set_test_params(self):
2727
self.num_nodes = 2
28-
self.enable_mocktime()
2928

3029
def skip_test_if_missing_module(self):
3130
self.skip_if_no_wallet()
3231

3332
def run_test(self):
33+
self.nodes[0].generate(1) # Get out of IBD
34+
self.sync_all()
3435
# Simple send, 0 to 1:
3536
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
3637
self.sync_all()

0 commit comments

Comments
 (0)