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

+1-1
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

+6-6
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

+1-1
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

+1-1
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

+1-1
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

+2-2
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

+1-1
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

+2-2
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

+1-1
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

+1-1
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

test/functional/tool_wallet.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def skip_test_if_missing_module(self):
2626

2727
def bitcoin_wallet_process(self, *args):
2828
binary = self.config["environment"]["BUILDDIR"] + '/src/bitcoin-wallet' + self.config["environment"]["EXEEXT"]
29-
args = ['-datadir={}'.format(self.nodes[0].datadir), '-regtest'] + list(args)
29+
args = ['-datadir={}'.format(self.nodes[0].datadir), '-chain=%s' % self.chain] + list(args)
3030
return subprocess.Popen([binary] + args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
3131

3232
def assert_raises_tool_error(self, error, *args):
@@ -197,7 +197,7 @@ def test_getwalletinfo_on_different_wallet(self):
197197
self.log.debug('Wallet file shasum unchanged\n')
198198

199199
def run_test(self):
200-
self.wallet_path = os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', 'wallet.dat')
200+
self.wallet_path = os.path.join(self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat')
201201
self.test_invalid_tool_commands_and_args()
202202
# Warning: The following tests are order-dependent.
203203
self.test_tool_wallet_info()

test/functional/wallet_backup.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def stop_three(self):
107107
self.stop_node(2)
108108

109109
def erase_three(self):
110-
os.remove(os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', 'wallet.dat'))
111-
os.remove(os.path.join(self.nodes[1].datadir, 'regtest', 'wallets', 'wallet.dat'))
112-
os.remove(os.path.join(self.nodes[2].datadir, 'regtest', 'wallets', 'wallet.dat'))
110+
os.remove(os.path.join(self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat'))
111+
os.remove(os.path.join(self.nodes[1].datadir, self.chain, 'wallets', 'wallet.dat'))
112+
os.remove(os.path.join(self.nodes[2].datadir, self.chain, 'wallets', 'wallet.dat'))
113113

114114
def run_test(self):
115115
self.log.info("Generating initial blockchain")
@@ -167,13 +167,13 @@ def run_test(self):
167167
self.erase_three()
168168

169169
# Start node2 with no chain
170-
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'blocks'))
171-
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'chainstate'))
170+
shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'blocks'))
171+
shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'chainstate'))
172172

173173
# Restore wallets from backup
174-
shutil.copyfile(os.path.join(self.nodes[0].datadir, 'wallet.bak'), os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', 'wallet.dat'))
175-
shutil.copyfile(os.path.join(self.nodes[1].datadir, 'wallet.bak'), os.path.join(self.nodes[1].datadir, 'regtest', 'wallets', 'wallet.dat'))
176-
shutil.copyfile(os.path.join(self.nodes[2].datadir, 'wallet.bak'), os.path.join(self.nodes[2].datadir, 'regtest', 'wallets', 'wallet.dat'))
174+
shutil.copyfile(os.path.join(self.nodes[0].datadir, 'wallet.bak'), os.path.join(self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat'))
175+
shutil.copyfile(os.path.join(self.nodes[1].datadir, 'wallet.bak'), os.path.join(self.nodes[1].datadir, self.chain, 'wallets', 'wallet.dat'))
176+
shutil.copyfile(os.path.join(self.nodes[2].datadir, 'wallet.bak'), os.path.join(self.nodes[2].datadir, self.chain, 'wallets', 'wallet.dat'))
177177

178178
self.log.info("Re-starting nodes")
179179
self.start_three()
@@ -188,8 +188,8 @@ def run_test(self):
188188
self.erase_three()
189189

190190
#start node2 with no chain
191-
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'blocks'))
192-
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'chainstate'))
191+
shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'blocks'))
192+
shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'chainstate'))
193193

194194
self.start_three()
195195

@@ -209,10 +209,10 @@ def run_test(self):
209209

210210
# Backup to source wallet file must fail
211211
sourcePaths = [
212-
os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', 'wallet.dat'),
213-
os.path.join(self.nodes[0].datadir, 'regtest', '.', 'wallets', 'wallet.dat'),
214-
os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', ''),
215-
os.path.join(self.nodes[0].datadir, 'regtest', 'wallets')]
212+
os.path.join(self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat'),
213+
os.path.join(self.nodes[0].datadir, self.chain, '.', 'wallets', 'wallet.dat'),
214+
os.path.join(self.nodes[0].datadir, self.chain, 'wallets', ''),
215+
os.path.join(self.nodes[0].datadir, self.chain, 'wallets')]
216216

217217
for sourcePath in sourcePaths:
218218
assert_raises_rpc_error(-4, "backup failed", self.nodes[0].backupwallet, sourcePath)

test/functional/wallet_hd.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ def run_test(self):
6767

6868
self.log.info("Restore backup ...")
6969
self.stop_node(1)
70-
# we need to delete the complete regtest directory
70+
# we need to delete the complete chain directory
7171
# otherwise node1 would auto-recover all funds in flag the keypool keys as used
72-
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks"))
73-
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "chainstate"))
74-
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat"))
72+
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "blocks"))
73+
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "chainstate"))
74+
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat"))
7575
self.start_node(1)
7676

7777
# Assert that derivation is deterministic
@@ -92,9 +92,9 @@ def run_test(self):
9292

9393
# Try a RPC based rescan
9494
self.stop_node(1)
95-
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks"))
96-
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "chainstate"))
97-
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat"))
95+
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "blocks"))
96+
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "chainstate"))
97+
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat"))
9898
self.start_node(1, extra_args=self.extra_args[1])
9999
connect_nodes(self.nodes[0], 1)
100100
self.sync_all()

test/functional/wallet_keypool_topup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def skip_test_if_missing_module(self):
3030
self.skip_if_no_wallet()
3131

3232
def run_test(self):
33-
wallet_path = os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat")
33+
wallet_path = os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat")
3434
wallet_backup_path = os.path.join(self.nodes[1].datadir, "wallet.bak")
3535
self.nodes[0].generate(101)
3636

test/functional/wallet_multiwallet.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def add_options(self, parser):
3939
def run_test(self):
4040
node = self.nodes[0]
4141

42-
data_dir = lambda *p: os.path.join(node.datadir, 'regtest', *p)
42+
data_dir = lambda *p: os.path.join(node.datadir, self.chain, *p)
4343
wallet_dir = lambda *p: data_dir('wallets', *p)
4444
wallet = lambda name: node.get_wallet_rpc(name)
4545

@@ -187,7 +187,7 @@ def wallet_file(name):
187187
assert_equal(w4.getbalance(), 3)
188188

189189
batch = w1.batch([w1.getblockchaininfo.get_request(), w1.getwalletinfo.get_request()])
190-
assert_equal(batch[0]["result"]["chain"], "regtest")
190+
assert_equal(batch[0]["result"]["chain"], self.chain)
191191
assert_equal(batch[1]["result"]["walletname"], "w1")
192192

193193
self.log.info('Check for per-wallet settxfee call')

test/functional/wallet_reorgsrestore.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def run_test(self):
9090
# Node0 wallet file is loaded on longest sync'ed node1
9191
self.stop_node(1)
9292
self.nodes[0].backupwallet(os.path.join(self.nodes[0].datadir, 'wallet.bak'))
93-
shutil.copyfile(os.path.join(self.nodes[0].datadir, 'wallet.bak'), os.path.join(self.nodes[1].datadir, 'regtest', 'wallet.dat'))
93+
shutil.copyfile(os.path.join(self.nodes[0].datadir, 'wallet.bak'), os.path.join(self.nodes[1].datadir, self.chain, 'wallet.dat'))
9494
self.start_node(1)
9595
tx_after_reorg = self.nodes[1].gettransaction(txid)
9696
# Check that normal confirmed tx is confirmed again but with different blockhash

0 commit comments

Comments
 (0)