Skip to content

Commit 96d912b

Browse files
author
MarcoFalke
committed
Merge #14738: Tests: Fix running wallet_listtransactions.py individually through test_runner.py
2474de0 Fix running individually through test_runner.py, as suggested by @MarcoFalke (#14732) (Kristaps Kaupe) Pull request description: As suggested by @MarcoFalke. Resolves #14732. Tree-SHA512: b4e400ba06075e218dbd97d0390845f1c55be42a2b6fd70513381318cfc2693473ba1d0f9d7f379a96939d1960b53801fad7c02e06bddc50c5a835ad024c37ef
2 parents a1fd876 + 2474de0 commit 96d912b

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
@@ -388,21 +388,6 @@ def sync_all(self, node_groups=None):
388388
sync_blocks(group)
389389
sync_mempools(group)
390390

391-
def enable_mocktime(self):
392-
"""Enable mocktime for the script.
393-
394-
mocktime may be needed for scripts that use the cached version of the
395-
blockchain. If the cached version of the blockchain is used without
396-
mocktime then the mempools will not sync due to IBD.
397-
398-
For backward compatibility of the python scripts with previous
399-
versions of the cache, this helper function sets mocktime to Jan 1,
400-
2014 + (201 * 10 * 60)"""
401-
self.mocktime = 1388534400 + (201 * 10 * 60)
402-
403-
def disable_mocktime(self):
404-
self.mocktime = 0
405-
406391
# Private helper methods. These should not be accessed by the subclass test scripts.
407392

408393
def _start_logging(self):
@@ -468,14 +453,18 @@ def _initialize_chain(self):
468453
for node in self.nodes:
469454
node.wait_for_rpc_connection()
470455

456+
# For backward compatibility of the python scripts with previous
457+
# versions of the cache, set mocktime to Jan 1,
458+
# 2014 + (201 * 10 * 60)"""
459+
self.mocktime = 1388534400 + (201 * 10 * 60)
460+
471461
# Create a 200-block-long chain; each of the 4 first nodes
472462
# gets 25 mature blocks and 25 immature.
473463
# Note: To preserve compatibility with older versions of
474464
# initialize_chain, only 4 nodes will generate coins.
475465
#
476466
# blocks are created with timestamps 10 minutes apart
477467
# starting from 2010 minutes in the past
478-
self.enable_mocktime()
479468
block_time = self.mocktime - (201 * 10 * 60)
480469
for i in range(2):
481470
for peer in range(4):
@@ -489,7 +478,7 @@ def _initialize_chain(self):
489478
# Shut them down, and clean up cache directories:
490479
self.stop_nodes()
491480
self.nodes = []
492-
self.disable_mocktime()
481+
self.mocktime = 0
493482

494483
def cache_path(n, *paths):
495484
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)