Skip to content

Commit 4454c52

Browse files
committed
QA: Adapt BitcoinTestFramework for chains other than "regtest"
1 parent a06be15 commit 4454c52

17 files changed

+72
-68
lines changed

test/functional/combine_logs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def main():
2323
parser = argparse.ArgumentParser(usage='%(prog)s [options] <test temporary directory>', description=__doc__)
2424
parser.add_argument('-c', '--color', dest='color', action='store_true', help='outputs the combined log with events colored by source (requires posix terminal colors. Use less -r for viewing)')
2525
parser.add_argument('--html', dest='html', action='store_true', help='outputs the combined log as html. Requires jinja2. pip install jinja2')
26+
parser.add_argument('--chain', dest='chain', help='selected chain in the tests (default: regtest)', default='regtest')
2627
args, unknown_args = parser.parse_known_args()
2728

2829
if args.color and os.name != 'posix':
@@ -38,19 +39,19 @@ def main():
3839
print("Unexpected arguments" + str(unknown_args))
3940
sys.exit(1)
4041

41-
log_events = read_logs(unknown_args[0])
42+
log_events = read_logs(unknown_args[0], args.chain)
4243

4344
print_logs(log_events, color=args.color, html=args.html)
4445

45-
def read_logs(tmp_dir):
46+
def read_logs(tmp_dir, chain):
4647
"""Reads log files.
4748
4849
Delegates to generator function get_log_events() to provide individual log events
4950
for each of the input log files."""
5051

5152
files = [("test", "%s/test_framework.log" % tmp_dir)]
5253
for i in itertools.count():
53-
logfile = "{}/node{}/regtest/debug.log".format(tmp_dir, i)
54+
logfile = "{}/node{}/{}/debug.log".format(tmp_dir, i, chain)
5455
if not os.path.isfile(logfile):
5556
break
5657
files.append(("node%d" % i, logfile))

test/functional/feature_blocksdir.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def set_test_params(self):
1919
def run_test(self):
2020
self.stop_node(0)
2121
shutil.rmtree(self.nodes[0].datadir)
22-
initialize_datadir(self.options.tmpdir, 0)
22+
initialize_datadir(self.options.tmpdir, 0, self.chain)
2323
self.log.info("Starting with non exiting blocksdir ...")
2424
blocksdir_path = os.path.join(self.options.tmpdir, 'blocksdir')
2525
self.nodes[0].assert_start_raises_init_error(["-blocksdir=" + blocksdir_path], 'Error: Specified blocks directory "{}" does not exist.'.format(blocksdir_path))
@@ -28,8 +28,8 @@ def run_test(self):
2828
self.start_node(0, ["-blocksdir=" + blocksdir_path])
2929
self.log.info("mining blocks..")
3030
self.nodes[0].generate(10)
31-
assert os.path.isfile(os.path.join(blocksdir_path, "regtest", "blocks", "blk00000.dat"))
32-
assert os.path.isdir(os.path.join(self.nodes[0].datadir, "regtest", "blocks", "index"))
31+
assert os.path.isfile(os.path.join(blocksdir_path, self.chain, "blocks", "blk00000.dat"))
32+
assert os.path.isdir(os.path.join(self.nodes[0].datadir, self.chain, "blocks", "index"))
3333

3434

3535
if __name__ == '__main__':

test/functional/feature_config_args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ def run_test(self):
6565
# Temporarily disabled, because this test would access the user's home dir (~/.bitcoin)
6666
#self.start_node(0, ['-conf='+conf_file, '-wallet=w1'])
6767
#self.stop_node(0)
68-
#assert os.path.exists(os.path.join(new_data_dir, 'regtest', 'wallets', 'w1'))
68+
#assert os.path.exists(os.path.join(new_data_dir, self.chain, 'wallets', 'w1'))
6969

7070
# Ensure command line argument overrides datadir in conf
7171
os.mkdir(new_data_dir_2)
7272
self.nodes[0].datadir = new_data_dir_2
7373
self.start_node(0, ['-datadir='+new_data_dir_2, '-conf='+conf_file, '-wallet=w2'])
74-
assert os.path.exists(os.path.join(new_data_dir_2, 'regtest', 'wallets', 'w2'))
74+
assert os.path.exists(os.path.join(new_data_dir_2, self.chain, 'wallets', 'w2'))
7575

7676
if __name__ == '__main__':
7777
ConfArgsTest().main()

test/functional/feature_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def set_test_params(self):
1616
self.setup_clean_chain = True
1717

1818
def relative_log_path(self, name):
19-
return os.path.join(self.nodes[0].datadir, "regtest", name)
19+
return os.path.join(self.nodes[0].datadir, self.chain, name)
2020

2121
def run_test(self):
2222
# test default log file name

test/functional/feature_pruning.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def set_test_params(self):
4646
def setup_network(self):
4747
self.setup_nodes()
4848

49-
self.prunedir = os.path.join(self.nodes[2].datadir, 'regtest', 'blocks', '')
49+
self.prunedir = os.path.join(self.nodes[2].datadir, self.chain, 'blocks', '')
5050

5151
connect_nodes(self.nodes[0], 1)
5252
connect_nodes(self.nodes[1], 2)
@@ -257,7 +257,7 @@ def prune(index, expected_ret=None):
257257
assert_equal(ret, expected_ret)
258258

259259
def has_block(index):
260-
return os.path.isfile(os.path.join(self.nodes[node_number].datadir, "regtest", "blocks", "blk{:05}.dat".format(index)))
260+
return os.path.isfile(os.path.join(self.nodes[node_number].datadir, self.chain, "blocks", "blk{:05}.dat".format(index)))
261261

262262
# should not prune because chain tip of node 3 (995) < PruneAfterHeight (1000)
263263
assert_raises_rpc_error(-1, "Blockchain is too short for pruning", node.pruneblockchain, height(500))

test/functional/interface_bitcoin_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run_test(self):
2828
rpc_response = self.nodes[0].getblockchaininfo()
2929
assert_equal(cli_response, rpc_response)
3030

31-
user, password = get_auth_cookie(self.nodes[0].datadir)
31+
user, password = get_auth_cookie(self.nodes[0].datadir, self.chain)
3232

3333
self.log.info("Test -stdinrpcpass option")
3434
assert_equal(0, self.nodes[0].cli('-rpcuser=%s' % user, '-stdinrpcpass', input=password).getblockcount())

test/functional/mempool_persist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def run_test(self):
9494
self.start_node(0)
9595
wait_until(lambda: len(self.nodes[0].getrawmempool()) == 5)
9696

97-
mempooldat0 = os.path.join(self.nodes[0].datadir, 'regtest', 'mempool.dat')
98-
mempooldat1 = os.path.join(self.nodes[1].datadir, 'regtest', 'mempool.dat')
97+
mempooldat0 = os.path.join(self.nodes[0].datadir, self.chain, 'mempool.dat')
98+
mempooldat1 = os.path.join(self.nodes[1].datadir, self.chain, 'mempool.dat')
9999
self.log.debug("Remove the mempool.dat file. Verify that savemempool to disk via RPC re-creates it")
100100
os.remove(mempooldat0)
101101
self.nodes[0].savemempool()

test/functional/mining_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def run_test(self):
3737
self.log.info('getmininginfo')
3838
mining_info = node.getmininginfo()
3939
assert_equal(mining_info['blocks'], 200)
40-
assert_equal(mining_info['chain'], 'regtest')
40+
assert_equal(mining_info['chain'], self.chain)
4141
assert_equal(mining_info['currentblocktx'], 0)
4242
assert_equal(mining_info['currentblockweight'], 0)
4343
assert_equal(mining_info['difficulty'], Decimal('4.656542373906925E-10'))

test/functional/rpc_bind.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def run_allowip_test(self, allow_ips, rpchost, rpcport):
5252
self.nodes[0].rpchost = None
5353
self.start_nodes([base_args])
5454
# connect to node through non-loopback interface
55-
node = get_rpc_proxy(rpc_url(self.nodes[0].datadir, 0, "%s:%d" % (rpchost, rpcport)), 0, coveragedir=self.options.coveragedir)
55+
node = get_rpc_proxy(rpc_url(self.nodes[0].datadir, 0, self.chain, "%s:%d" % (rpchost, rpcport)), 0, coveragedir=self.options.coveragedir)
5656
node.getnetworkinfo()
5757
self.stop_nodes()
5858

test/functional/rpc_scantxoutset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def run_test(self):
4747

4848
self.log.info("Stop node, remove wallet, mine again some blocks...")
4949
self.stop_node(0)
50-
shutil.rmtree(os.path.join(self.nodes[0].datadir, "regtest", 'wallets'))
50+
shutil.rmtree(os.path.join(self.nodes[0].datadir, self.chain, 'wallets'))
5151
self.start_node(0)
5252
self.nodes[0].generate(110)
5353

0 commit comments

Comments
 (0)