diff --git a/test/functional/feature_assumevalid.py b/test/functional/feature_assumevalid.py index a8fd2fa28c9cd3..050ad260544a6b 100755 --- a/test/functional/feature_assumevalid.py +++ b/test/functional/feature_assumevalid.py @@ -73,12 +73,8 @@ def send_blocks_until_disconnected(self, p2p_conn): break try: p2p_conn.send_message(msg_block(self.blocks[i])) - # TODO There is a race condition between send_message and on_close which causes an AttributError on Travis - # We can reenable the correct exception handling and the assert when Bitcoin 0.16 mininode.py changes have been - # backported - #except IOError as e: - except: - #assert not p2p_conn.is_connected + except IOError: + assert not p2p_conn.is_connected break def assert_blockchain_height(self, node, height): diff --git a/test/functional/feature_logging.py b/test/functional/feature_logging.py index a4ebc7cca3fa34..28cd9b961b8c2f 100755 --- a/test/functional/feature_logging.py +++ b/test/functional/feature_logging.py @@ -15,11 +15,11 @@ def set_test_params(self): def run_test(self): # test default log file name - assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "debug.log")) + assert os.path.isfile(os.path.join(self.nodes[0].datadir, self.chain, "debug.log")) # test alternative log file name in datadir self.restart_node(0, ["-debuglogfile=foo.log"]) - assert os.path.isfile(os.path.join(self.nodes[0].datadir, "regtest", "foo.log")) + assert os.path.isfile(os.path.join(self.nodes[0].datadir, self.chain, "foo.log")) # test alternative log file name outside datadir tempname = os.path.join(self.options.tmpdir, "foo.log") @@ -27,7 +27,7 @@ def run_test(self): assert os.path.isfile(tempname) # check that invalid log (relative) will cause error - invdir = os.path.join(self.nodes[0].datadir, "regtest", "foo") + invdir = os.path.join(self.nodes[0].datadir, self.chain, "foo") invalidname = os.path.join("foo", "foo.log") self.stop_node(0) exp_stderr = "Error: Could not open debug log file \S+$" diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py index ede82787b21504..8ab2ef1cdb78e4 100755 --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -45,7 +45,7 @@ def set_test_params(self): def setup_network(self): self.setup_nodes() - self.prunedir = os.path.join(self.nodes[2].datadir, 'regtest', 'blocks', '') + self.prunedir = os.path.join(self.nodes[2].datadir, self.chain, 'blocks', '') connect_nodes(self.nodes[0], 1) connect_nodes(self.nodes[1], 2) @@ -256,7 +256,7 @@ def prune(index, expected_ret=None): assert_equal(ret, expected_ret) def has_block(index): - return os.path.isfile(os.path.join(self.nodes[node_number].datadir, "regtest", "blocks", "blk{:05}.dat".format(index))) + return os.path.isfile(os.path.join(self.nodes[node_number].datadir, self.chain, "blocks", "blk{:05}.dat".format(index))) # should not prune because chain tip of node 3 (995) < PruneAfterHeight (1000) assert_raises_rpc_error(-1, "Blockchain is too short for pruning", node.pruneblockchain, height(500)) diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py index c0973985c3d66d..ad6ad757cbdbc5 100755 --- a/test/functional/mempool_persist.py +++ b/test/functional/mempool_persist.py @@ -93,8 +93,8 @@ def run_test(self): self.start_node(0) wait_until(lambda: len(self.nodes[0].getrawmempool()) == 5) - mempooldat0 = os.path.join(self.nodes[0].datadir, 'regtest', 'mempool.dat') - mempooldat1 = os.path.join(self.nodes[1].datadir, 'regtest', 'mempool.dat') + mempooldat0 = os.path.join(self.nodes[0].datadir, self.chain, 'mempool.dat') + mempooldat1 = os.path.join(self.nodes[1].datadir, self.chain, 'mempool.dat') self.log.debug("Remove the mempool.dat file. Verify that savemempool to disk via RPC re-creates it") os.remove(mempooldat0) self.nodes[0].savemempool() diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py index fbf478ce831d41..efa47174d9109d 100755 --- a/test/functional/mining_basic.py +++ b/test/functional/mining_basic.py @@ -37,7 +37,7 @@ def run_test(self): self.log.info('getmininginfo') mining_info = node.getmininginfo() assert_equal(mining_info['blocks'], 200) - assert_equal(mining_info['chain'], 'regtest') + assert_equal(mining_info['chain'], self.chain) assert_equal(mining_info['currentblocksize'], 0) assert_equal(mining_info['currentblocktx'], 0) assert_equal(mining_info['difficulty'], Decimal('4.656542373906925E-10')) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index f3e6cbb583d80e..c0a53227bc84bc 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -645,7 +645,7 @@ def prepare_datadirs(self): start_idx = len(self.nodes) for idx in range(0, self.mn_count): - copy_datadir(0, idx + start_idx, self.options.tmpdir) + copy_datadir(0, idx + start_idx, self.options.tmpdir, self.chain) # restart faucet node self.start_node(0) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 0b24e397fdb291..662e081a1c4d1b 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -366,9 +366,9 @@ def get_auth_cookie(datadir, chain): raise ValueError("No RPC credentials") return user, password -def copy_datadir(from_node, to_node, dirname): - from_datadir = os.path.join(dirname, "node"+str(from_node), "regtest") - to_datadir = os.path.join(dirname, "node"+str(to_node), "regtest") +def copy_datadir(from_node, to_node, dirname, chain): + from_datadir = os.path.join(dirname, "node"+str(from_node), chain) + to_datadir = os.path.join(dirname, "node"+str(to_node), chain) dirs = ["blocks", "chainstate", "evodb", "llmq"] for d in dirs: diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py index 7423f84a0e6c20..f1bf87ce6b670d 100755 --- a/test/functional/wallet_backup.py +++ b/test/functional/wallet_backup.py @@ -90,9 +90,9 @@ def stop_three(self): self.stop_node(2) def erase_three(self): - os.remove(os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', 'wallet.dat')) - os.remove(os.path.join(self.nodes[1].datadir, 'regtest', 'wallets', 'wallet.dat')) - os.remove(os.path.join(self.nodes[2].datadir, 'regtest', 'wallets', 'wallet.dat')) + os.remove(os.path.join(self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat')) + os.remove(os.path.join(self.nodes[1].datadir, self.chain, 'wallets', 'wallet.dat')) + os.remove(os.path.join(self.nodes[2].datadir, self.chain, 'wallets', 'wallet.dat')) def run_test(self): self.log.info("Generating initial blockchain") @@ -150,15 +150,15 @@ def run_test(self): self.erase_three() # Start node2 with no chain - shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'blocks')) - shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'chainstate')) - shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'evodb')) - shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'llmq')) + shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'blocks')) + shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'chainstate')) + shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'evodb')) + shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'llmq')) # Restore wallets from backup - shutil.copyfile(os.path.join(self.nodes[0].datadir, 'wallet.bak'), os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', 'wallet.dat')) - shutil.copyfile(os.path.join(self.nodes[1].datadir, 'wallet.bak'), os.path.join(self.nodes[1].datadir, 'regtest', 'wallets', 'wallet.dat')) - shutil.copyfile(os.path.join(self.nodes[2].datadir, 'wallet.bak'), os.path.join(self.nodes[2].datadir, 'regtest', 'wallets', 'wallet.dat')) + shutil.copyfile(os.path.join(self.nodes[0].datadir, 'wallet.bak'), os.path.join(self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat')) + shutil.copyfile(os.path.join(self.nodes[1].datadir, 'wallet.bak'), os.path.join(self.nodes[1].datadir, self.chain, 'wallets', 'wallet.dat')) + shutil.copyfile(os.path.join(self.nodes[2].datadir, 'wallet.bak'), os.path.join(self.nodes[2].datadir, self.chain, 'wallets', 'wallet.dat')) self.log.info("Re-starting nodes") self.start_three() @@ -173,10 +173,10 @@ def run_test(self): self.erase_three() #start node2 with no chain - shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'blocks')) - shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'chainstate')) - shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'evodb')) - shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'llmq')) + shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'blocks')) + shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'chainstate')) + shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'evodb')) + shutil.rmtree(os.path.join(self.nodes[2].datadir, self.chain, 'llmq')) self.start_three() @@ -196,10 +196,10 @@ def run_test(self): # Backup to source wallet file must fail sourcePaths = [ - os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', 'wallet.dat'), - os.path.join(self.nodes[0].datadir, 'regtest', '.', 'wallets', 'wallet.dat'), - os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', ''), - os.path.join(self.nodes[0].datadir, 'regtest', 'wallets')] + os.path.join(self.nodes[0].datadir, self.chain, 'wallets', 'wallet.dat'), + os.path.join(self.nodes[0].datadir, self.chain, '.', 'wallets', 'wallet.dat'), + os.path.join(self.nodes[0].datadir, self.chain, 'wallets', ''), + os.path.join(self.nodes[0].datadir, self.chain, 'wallets')] for sourcePath in sourcePaths: assert_raises_rpc_error(-4, "backup failed", self.nodes[0].backupwallet, sourcePath) diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py index 2132686a23d5f9..38c107d7e43eca 100755 --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -73,13 +73,13 @@ def run_test(self): self.log.info("Restore backup ...") self.stop_node(1) - # we need to delete the complete regtest directory + # we need to delete the complete chain directory # otherwise node1 would auto-recover all funds in flag the keypool keys as used - shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks")) - shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "chainstate")) - shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "evodb")) - shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "llmq")) - shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat")) + shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "blocks")) + shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "chainstate")) + shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "evodb")) + shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "llmq")) + shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat")) self.start_node(1) # Assert that derivation is deterministic @@ -100,11 +100,11 @@ def run_test(self): # Try a RPC based rescan self.stop_node(1) - shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks")) - shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "chainstate")) - shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "evodb")) - shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "llmq")) - shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat")) + shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "blocks")) + shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "chainstate")) + shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "evodb")) + shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "llmq")) + shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat")) self.start_node(1, extra_args=self.extra_args[1]) connect_nodes_bi(self.nodes, 0, 1) self.sync_all() diff --git a/test/functional/wallet_keypool_topup.py b/test/functional/wallet_keypool_topup.py index 2f6de7745fb632..88e6e38173cfe6 100755 --- a/test/functional/wallet_keypool_topup.py +++ b/test/functional/wallet_keypool_topup.py @@ -29,7 +29,7 @@ def set_test_params(self): self.stderr = sys.stdout def run_test(self): - wallet_path = os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat") + wallet_path = os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat") wallet_backup_path = os.path.join(self.nodes[1].datadir, "wallet.bak") self.nodes[0].generate(101) diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py index d9c187faec2c48..0f57b4bf0b9da5 100755 --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -26,7 +26,7 @@ def set_test_params(self): def run_test(self): node = self.nodes[0] - data_dir = lambda *p: os.path.join(node.datadir, 'regtest', *p) + data_dir = lambda *p: os.path.join(node.datadir, self.chain, *p) wallet_dir = lambda *p: data_dir('wallets', *p) wallet = lambda name: node.get_wallet_rpc(name) @@ -160,7 +160,7 @@ def run_test(self): assert_equal(w4.getbalance(), 3) batch = w1.batch([w1.getblockchaininfo.get_request(), w1.getwalletinfo.get_request()]) - assert_equal(batch[0]["result"]["chain"], "regtest") + assert_equal(batch[0]["result"]["chain"], self.chain) assert_equal(batch[1]["result"]["walletname"], "w1")