Skip to content

Commit fa41614

Browse files
author
MarcoFalke
committed
scripted-diff: Use wallets_path and chain_path where possible
Instead of passing the datadir and chain name to os.path.join, just use the existing properties, which are the same. -BEGIN VERIFY SCRIPT- sed -i --regexp-extended 's|\.datadir, self\.chain, .wallets.|.wallets_path|g' $(git grep -l '\.datadir, self\.chain,') sed -i --regexp-extended 's|\.datadir, self\.chain,|.chain_path,|g' $(git grep -l '\.datadir, self\.chain,') -END VERIFY SCRIPT-
1 parent fa493fa commit fa41614

18 files changed

+42
-42
lines changed

test/functional/feature_addrman.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def set_test_params(self):
5353
self.num_nodes = 1
5454

5555
def run_test(self):
56-
peers_dat = os.path.join(self.nodes[0].datadir, self.chain, "peers.dat")
56+
peers_dat = os.path.join(self.nodes[0].chain_path, "peers.dat")
5757
init_error = lambda reason: (
5858
f"Error: Invalid or corrupt peers.dat \\({reason}\\). If you believe this "
5959
f"is a bug, please report it to {self.config['environment']['PACKAGE_BUGREPORT']}. "

test/functional/feature_blocksdir.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def set_test_params(self):
1818

1919
def run_test(self):
2020
self.stop_node(0)
21-
assert os.path.isdir(os.path.join(self.nodes[0].datadir, self.chain, "blocks"))
21+
assert os.path.isdir(os.path.join(self.nodes[0].chain_path, "blocks"))
2222
assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "blocks"))
2323
shutil.rmtree(self.nodes[0].datadir)
2424
initialize_datadir(self.options.tmpdir, 0, self.chain)
@@ -31,7 +31,7 @@ def run_test(self):
3131
self.log.info("mining blocks..")
3232
self.generatetoaddress(self.nodes[0], 10, self.nodes[0].get_deterministic_priv_key().address)
3333
assert os.path.isfile(os.path.join(blocksdir_path, self.chain, "blocks", "blk00000.dat"))
34-
assert os.path.isdir(os.path.join(self.nodes[0].datadir, self.chain, "blocks", "index"))
34+
assert os.path.isdir(os.path.join(self.nodes[0].chain_path, "blocks", "index"))
3535

3636

3737
if __name__ == '__main__':

test/functional/feature_fee_estimation.py

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

422422
self.log.info("Restarting node with fresh estimation")
423423
self.stop_node(0)
424-
fee_dat = os.path.join(self.nodes[0].datadir, self.chain, "fee_estimates.dat")
424+
fee_dat = os.path.join(self.nodes[0].chain_path, "fee_estimates.dat")
425425
os.remove(fee_dat)
426426
self.start_node(0)
427427
self.connect_nodes(0, 1)

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, self.chain, name)
19+
return os.path.join(self.nodes[0].chain_path, 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
@@ -91,7 +91,7 @@ def set_test_params(self):
9191
def setup_network(self):
9292
self.setup_nodes()
9393

94-
self.prunedir = os.path.join(self.nodes[2].datadir, self.chain, 'blocks', '')
94+
self.prunedir = os.path.join(self.nodes[2].chain_path, 'blocks', '')
9595

9696
self.connect_nodes(0, 1)
9797
self.connect_nodes(1, 2)
@@ -290,7 +290,7 @@ def prune(index):
290290
assert_equal(ret + 1, node.getblockchaininfo()['pruneheight'])
291291

292292
def has_block(index):
293-
return os.path.isfile(os.path.join(self.nodes[node_number].datadir, self.chain, "blocks", f"blk{index:05}.dat"))
293+
return os.path.isfile(os.path.join(self.nodes[node_number].chain_path, "blocks", f"blk{index:05}.dat"))
294294

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

test/functional/feature_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def set_test_params(self):
2121

2222
def run_test(self):
2323
node, = self.nodes
24-
settings = Path(node.datadir, self.chain, "settings.json")
24+
settings = Path(node.chain_path, "settings.json")
2525
conf = Path(node.datadir, "bitcoin.conf")
2626

2727
# Assert empty settings file was created

test/functional/interface_rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_getrpcinfo(self):
4646
command = info['active_commands'][0]
4747
assert_equal(command['method'], 'getrpcinfo')
4848
assert_greater_than_or_equal(command['duration'], 0)
49-
assert_equal(info['logpath'], os.path.join(self.nodes[0].datadir, self.chain, 'debug.log'))
49+
assert_equal(info['logpath'], os.path.join(self.nodes[0].chain_path, 'debug.log'))
5050

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

test/functional/mempool_compatibility.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def run_test(self):
5555
self.stop_node(1)
5656

5757
self.log.info("Move mempool.dat from old to new node")
58-
old_node_mempool = os.path.join(old_node.datadir, self.chain, 'mempool.dat')
59-
new_node_mempool = os.path.join(new_node.datadir, self.chain, 'mempool.dat')
58+
old_node_mempool = os.path.join(old_node.chain_path, 'mempool.dat')
59+
new_node_mempool = os.path.join(new_node.chain_path, 'mempool.dat')
6060
os.rename(old_node_mempool, new_node_mempool)
6161

6262
self.log.info("Start new node and verify mempool contains the tx")

test/functional/mempool_persist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def run_test(self):
143143
self.nodes[2].syncwithvalidationinterfacequeue() # Flush mempool to wallet
144144
assert_equal(node2_balance, wallet_watch.getbalance())
145145

146-
mempooldat0 = os.path.join(self.nodes[0].datadir, self.chain, 'mempool.dat')
147-
mempooldat1 = os.path.join(self.nodes[1].datadir, self.chain, 'mempool.dat')
146+
mempooldat0 = os.path.join(self.nodes[0].chain_path, 'mempool.dat')
147+
mempooldat1 = os.path.join(self.nodes[1].chain_path, 'mempool.dat')
148148

149149
self.log.debug("Force -persistmempool=0 node1 to savemempool to disk via RPC")
150150
assert not os.path.exists(mempooldat1)

test/functional/tool_wallet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def test_dump_createfromdump(self):
401401

402402

403403
def run_test(self):
404-
self.wallet_path = os.path.join(self.nodes[0].datadir, self.chain, 'wallets', self.default_wallet_name, self.wallet_data_filename)
404+
self.wallet_path = os.path.join(self.nodes[0].wallets_path, self.default_wallet_name, self.wallet_data_filename)
405405
self.test_invalid_tool_commands_and_args()
406406
# Warning: The following tests are order-dependent.
407407
self.test_tool_wallet_info()

0 commit comments

Comments
 (0)