Merge #12076: qa: Use node.datadir instead of tmpdir in test framework
c8330d4qa: Use node.datadir instead of tmpdir in test framework (MarcoFalke) Pull request description: Commitc53c9831eeintroduced the utility function `get_datadir_path`, however not all places in the code use this util function. Using the util function everywhere makes it easier to review pull requests related to the datadir. This commit replaces datadir path creation with the `datadir` member of `TestNode`, which itself uses `get_datadir_path`. Tree-SHA512: c75707ab7149d732a6d56152a5813138a33459d3d07577b60b89f2a207c83b7663fac5f203593677c9892d1c23a5eba4bd45c5c4ababf040d720b437240fcddf
This commit is contained in:
13 files changed
+74
-71
No files matched your search
@@ -4,13 +4,15 @@
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test Hierarchical Deterministic wallet function."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
connect_nodes_bi,
|
||||
)
|
||||
import shutil
|
||||
import os
|
||||
|
||||
|
||||
class WalletHDTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
@@ -18,9 +20,7 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
self.num_nodes = 2
|
||||
self.extra_args = [[], ['-keypool=0']]
|
||||
|
||||
def run_test (self):
|
||||
tmpdir = self.options.tmpdir
|
||||
|
||||
def run_test(self):
|
||||
# Make sure can't switch off usehd after wallet creation
|
||||
self.stop_node(1)
|
||||
self.nodes[1].assert_start_raises_init_error(['-usehd=0'], "Error: Error loading : You can't disable HD on an already existing HD wallet")
|
||||
@@ -41,8 +41,8 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
self.nodes[1].importprivkey(self.nodes[0].dumpprivkey(non_hd_add))
|
||||
|
||||
# This should be enough to keep the master key and the non-HD key
|
||||
self.nodes[1].backupwallet(tmpdir + "/hd.bak")
|
||||
#self.nodes[1].dumpwallet(tmpdir + "/hd.dump")
|
||||
self.nodes[1].backupwallet(os.path.join(self.nodes[1].datadir, "hd.bak"))
|
||||
#self.nodes[1].dumpwallet(os.path.join(self.nodes[1].datadir, "hd.dump"))
|
||||
|
||||
# Derive some HD addresses and remember the last
|
||||
# Also send funds to each add
|
||||
@@ -71,9 +71,9 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
self.stop_node(1)
|
||||
# we need to delete the complete regtest directory
|
||||
# otherwise node1 would auto-recover all funds in flag the keypool keys as used
|
||||
shutil.rmtree(os.path.join(tmpdir, "node1/regtest/blocks"))
|
||||
shutil.rmtree(os.path.join(tmpdir, "node1/regtest/chainstate"))
|
||||
shutil.copyfile(os.path.join(tmpdir, "hd.bak"), os.path.join(tmpdir, "node1/regtest/wallets/wallet.dat"))
|
||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks"))
|
||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "chainstate"))
|
||||
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat"))
|
||||
self.start_node(1)
|
||||
|
||||
# Assert that derivation is deterministic
|
||||
@@ -94,9 +94,9 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
|
||||
# Try a RPC based rescan
|
||||
self.stop_node(1)
|
||||
shutil.rmtree(os.path.join(tmpdir, "node1/regtest/blocks"))
|
||||
shutil.rmtree(os.path.join(tmpdir, "node1/regtest/chainstate"))
|
||||
shutil.copyfile(os.path.join(tmpdir, "hd.bak"), os.path.join(tmpdir, "node1/regtest/wallet.dat"))
|
||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks"))
|
||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "chainstate"))
|
||||
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat"))
|
||||
self.start_node(1, extra_args=self.extra_args[1])
|
||||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
self.sync_all()
|
||||
|
||||
Reference in new issue
Block a user