Skip to content

Commit 1abcecc

Browse files
committed
Tests: Use self.chain instead of 'regtest' in almost all current tests
1 parent be50469 commit 1abcecc

16 files changed

+44
-44
lines changed

test/functional/feature_abortnode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def run_test(self):
2929
datadir = get_datadir_path(self.options.tmpdir, 0)
3030

3131
# Deleting the undo file will result in reorg failure
32-
os.unlink(os.path.join(datadir, 'regtest', 'blocks', 'rev00000.dat'))
32+
os.unlink(os.path.join(datadir, self.chain, 'blocks', 'rev00000.dat'))
3333

3434
# Connecting to a node with a more work chain will trigger a reorg
3535
# attempt.

test/functional/feature_config_args.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_config_file_parser(self):
3838
if self.is_wallet_compiled():
3939
with open(inc_conf_file_path, 'w', encoding='utf8') as conf:
4040
conf.write("wallet=foo\n")
41-
self.nodes[0].assert_start_raises_init_error(expected_msg='Error: Config setting for -wallet only applied on regtest network when in [regtest] section.')
41+
self.nodes[0].assert_start_raises_init_error(expected_msg='Error: Config setting for -wallet only applied on %s network when in [%s] section.' % (self.chain, self.chain))
4242

4343
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
4444
conf.write('regtest=0\n') # mainnet
@@ -103,7 +103,7 @@ def run_test(self):
103103
# Check that using non-existent datadir in conf file fails
104104
conf_file = os.path.join(default_data_dir, "bitcoin.conf")
105105

106-
# datadir needs to be set before [regtest] section
106+
# datadir needs to be set before [chain] section
107107
conf_file_contents = open(conf_file, encoding='utf8').read()
108108
with open(conf_file, 'w', encoding='utf8') as f:
109109
f.write("datadir=" + new_data_dir + "\n")
@@ -115,17 +115,17 @@ def run_test(self):
115115
os.mkdir(new_data_dir)
116116
self.start_node(0, ['-conf='+conf_file, '-wallet=w1'])
117117
self.stop_node(0)
118-
assert os.path.exists(os.path.join(new_data_dir, 'regtest', 'blocks'))
118+
assert os.path.exists(os.path.join(new_data_dir, self.chain, 'blocks'))
119119
if self.is_wallet_compiled():
120-
assert os.path.exists(os.path.join(new_data_dir, 'regtest', 'wallets', 'w1'))
120+
assert os.path.exists(os.path.join(new_data_dir, self.chain, 'wallets', 'w1'))
121121

122122
# Ensure command line argument overrides datadir in conf
123123
os.mkdir(new_data_dir_2)
124124
self.nodes[0].datadir = new_data_dir_2
125125
self.start_node(0, ['-datadir='+new_data_dir_2, '-conf='+conf_file, '-wallet=w2'])
126-
assert os.path.exists(os.path.join(new_data_dir_2, 'regtest', 'blocks'))
126+
assert os.path.exists(os.path.join(new_data_dir_2, self.chain, 'blocks'))
127127
if self.is_wallet_compiled():
128-
assert os.path.exists(os.path.join(new_data_dir_2, 'regtest', 'wallets', 'w2'))
128+
assert os.path.exists(os.path.join(new_data_dir_2, self.chain, 'wallets', 'w2'))
129129

130130

131131
if __name__ == '__main__':

test/functional/feature_filelock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def setup_network(self):
1919
self.nodes[0].wait_for_rpc_connection()
2020

2121
def run_test(self):
22-
datadir = os.path.join(self.nodes[0].datadir, 'regtest')
22+
datadir = os.path.join(self.nodes[0].datadir, self.chain)
2323
self.log.info("Using datadir {}".format(datadir))
2424

2525
self.log.info("Check that we can't start a second bitcoind instance using the same datadir")

test/functional/feature_loadblock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def run_test(self):
3737
cfg_file = os.path.join(data_dir, "linearize.cfg")
3838
bootstrap_file = os.path.join(self.options.tmpdir, "bootstrap.dat")
3939
genesis_block = self.nodes[0].getblockhash(0)
40-
blocks_dir = os.path.join(data_dir, "regtest", "blocks")
40+
blocks_dir = os.path.join(data_dir, self.chain, "blocks")
4141
hash_list = tempfile.NamedTemporaryFile(dir=data_dir,
4242
mode='w',
4343
delete=False,

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
@@ -100,7 +100,7 @@ def skip_test_if_missing_module(self):
100100
def setup_network(self):
101101
self.setup_nodes()
102102

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

105105
connect_nodes(self.nodes[0], 1)
106106
connect_nodes(self.nodes[1], 2)
@@ -278,7 +278,7 @@ def prune(index):
278278
assert_equal(ret, node.getblockchaininfo()['pruneheight'])
279279

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

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

test/functional/interface_rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_getrpcinfo(self):
3232
command = info['active_commands'][0]
3333
assert_equal(command['method'], 'getrpcinfo')
3434
assert_greater_than_or_equal(command['duration'], 0)
35-
assert_equal(info['logpath'], os.path.join(self.nodes[0].datadir, 'regtest', 'debug.log'))
35+
assert_equal(info['logpath'], os.path.join(self.nodes[0].datadir, self.chain, 'debug.log'))
3636

3737
def test_batch_request(self):
3838
self.log.info("Testing basic JSON-RPC batch request...")

test/functional/mempool_persist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def run_test(self):
117117
wait_until(lambda: self.nodes[0].getmempoolinfo()["loaded"])
118118
assert_equal(len(self.nodes[0].getrawmempool()), 5)
119119

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

test/functional/mining_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
6969
self.log.info('getmininginfo')
7070
mining_info = node.getmininginfo()
7171
assert_equal(mining_info['blocks'], 200)
72-
assert_equal(mining_info['chain'], 'regtest')
72+
assert_equal(mining_info['chain'], self.chain)
7373
assert 'currentblocktx' not in mining_info
7474
assert 'currentblockweight' not in mining_info
7575
assert_equal(mining_info['difficulty'], Decimal('4.656542373906925E-10'))

test/functional/rpc_scantxoutset.py

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

5555
self.log.info("Stop node, remove wallet, mine again some blocks...")
5656
self.stop_node(0)
57-
shutil.rmtree(os.path.join(self.nodes[0].datadir, "regtest", 'wallets'))
57+
shutil.rmtree(os.path.join(self.nodes[0].datadir, self.chain, 'wallets'))
5858
self.start_node(0)
5959
self.nodes[0].generate(110)
6060

0 commit comments

Comments
 (0)