tests: Make only desc wallets for wallet_multwallet.py --descriptors
This commit is contained in:
1 parent
d4b67ad214
commit
c7b7e0a692
1 file changed
+44
-24
@@ -82,8 +82,8 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||||||
# directory paths) can be loaded
|
# directory paths) can be loaded
|
||||||
# create another dummy wallet for use in testing backups later
|
# create another dummy wallet for use in testing backups later
|
||||||
self.start_node(0)
|
self.start_node(0)
|
||||||
node.createwallet("empty", descriptors=False)
|
node.createwallet("empty")
|
||||||
node.createwallet("plain", descriptors=False)
|
node.createwallet("plain")
|
||||||
node.createwallet("created")
|
node.createwallet("created")
|
||||||
self.stop_nodes()
|
self.stop_nodes()
|
||||||
empty_wallet = os.path.join(self.options.tmpdir, 'empty.dat')
|
empty_wallet = os.path.join(self.options.tmpdir, 'empty.dat')
|
||||||
@@ -101,20 +101,29 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||||||
# sub/w5 - to verify relative wallet path is created correctly
|
# sub/w5 - to verify relative wallet path is created correctly
|
||||||
# extern/w6 - to verify absolute wallet path is created correctly
|
# extern/w6 - to verify absolute wallet path is created correctly
|
||||||
# w7_symlink - to verify symlinked wallet path is initialized correctly
|
# w7_symlink - to verify symlinked wallet path is initialized correctly
|
||||||
# w8 - to verify existing wallet file is loaded correctly
|
# w8 - to verify existing wallet file is loaded correctly. Not tested for SQLite wallets as this is a deprecated BDB behavior.
|
||||||
# '' - to verify default wallet file is created correctly
|
# '' - to verify default wallet file is created correctly
|
||||||
wallet_names = ['w1', 'w2', 'w3', 'w', 'sub/w5', os.path.join(self.options.tmpdir, 'extern/w6'), 'w7_symlink', 'w8', self.default_wallet_name]
|
to_create = ['w1', 'w2', 'w3', 'w', 'sub/w5', 'w7_symlink']
|
||||||
|
in_wallet_dir = to_create.copy() # Wallets in the wallet dir
|
||||||
|
in_wallet_dir.append('w7') # w7 is not loaded or created, but will be listed by listwalletdir because w7_symlink
|
||||||
|
to_create.append(os.path.join(self.options.tmpdir, 'extern/w6')) # External, not in the wallet dir, so we need to avoid adding it to in_wallet_dir
|
||||||
|
to_load = [self.default_wallet_name]
|
||||||
|
if not self.options.descriptors:
|
||||||
|
to_load.append('w8')
|
||||||
|
wallet_names = to_create + to_load # Wallet names loaded in the wallet
|
||||||
|
in_wallet_dir += to_load # The loaded wallets are also in the wallet dir
|
||||||
self.start_node(0)
|
self.start_node(0)
|
||||||
for wallet_name in wallet_names[:-2]:
|
for wallet_name in to_create:
|
||||||
self.nodes[0].createwallet(wallet_name, descriptors=False)
|
self.nodes[0].createwallet(wallet_name)
|
||||||
for wallet_name in wallet_names[-2:]:
|
for wallet_name in to_load:
|
||||||
self.nodes[0].loadwallet(wallet_name)
|
self.nodes[0].loadwallet(wallet_name)
|
||||||
assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [self.default_wallet_name, os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8'])
|
assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), sorted(in_wallet_dir))
|
||||||
|
|
||||||
assert_equal(set(node.listwallets()), set(wallet_names))
|
assert_equal(set(node.listwallets()), set(wallet_names))
|
||||||
|
|
||||||
# should raise rpc error if wallet path can't be created
|
# should raise rpc error if wallet path can't be created
|
||||||
assert_raises_rpc_error(-1, "boost::filesystem::create_directory:", self.nodes[0].createwallet, "w8/bad", descriptors=False)
|
err_code = -4 if self.options.descriptors else -1
|
||||||
|
assert_raises_rpc_error(err_code, "boost::filesystem::create_directory:", self.nodes[0].createwallet, "w8/bad")
|
||||||
|
|
||||||
# check that all requested wallets were created
|
# check that all requested wallets were created
|
||||||
self.stop_node(0)
|
self.stop_node(0)
|
||||||
@@ -128,10 +137,13 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||||||
# should not initialize if there are duplicate wallets
|
# should not initialize if there are duplicate wallets
|
||||||
self.nodes[0].assert_start_raises_init_error(['-wallet=w1', '-wallet=w1'], 'Error: Error loading wallet w1. Duplicate -wallet filename specified.')
|
self.nodes[0].assert_start_raises_init_error(['-wallet=w1', '-wallet=w1'], 'Error: Error loading wallet w1. Duplicate -wallet filename specified.')
|
||||||
|
|
||||||
# should not initialize if one wallet is a copy of another
|
if not self.options.descriptors:
|
||||||
shutil.copyfile(wallet_dir('w8'), wallet_dir('w8_copy'))
|
# Only BDB doesn't open duplicate wallet files. SQLite does not have this limitation. While this may be desired in the future, it is not necessary
|
||||||
exp_stderr = r"BerkeleyDatabase: Can't open database w8_copy \(duplicates fileid \w+ from w8\)"
|
# should not initialize if one wallet is a copy of another
|
||||||
self.nodes[0].assert_start_raises_init_error(['-wallet=w8', '-wallet=w8_copy'], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
|
shutil.copyfile(wallet_dir('w8'), wallet_dir('w8_copy'))
|
||||||
|
in_wallet_dir.append('w8_copy')
|
||||||
|
exp_stderr = r"BerkeleyDatabase: Can't open database w8_copy \(duplicates fileid \w+ from w8\)"
|
||||||
|
self.nodes[0].assert_start_raises_init_error(['-wallet=w8', '-wallet=w8_copy'], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
|
||||||
|
|
||||||
# should not initialize if wallet file is a symlink
|
# should not initialize if wallet file is a symlink
|
||||||
os.symlink('w8', wallet_dir('w8_symlink'))
|
os.symlink('w8', wallet_dir('w8_symlink'))
|
||||||
@@ -167,15 +179,18 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||||||
competing_wallet_dir = os.path.join(self.options.tmpdir, 'competing_walletdir')
|
competing_wallet_dir = os.path.join(self.options.tmpdir, 'competing_walletdir')
|
||||||
os.mkdir(competing_wallet_dir)
|
os.mkdir(competing_wallet_dir)
|
||||||
self.restart_node(0, ['-nowallet', '-walletdir=' + competing_wallet_dir])
|
self.restart_node(0, ['-nowallet', '-walletdir=' + competing_wallet_dir])
|
||||||
self.nodes[0].createwallet(self.default_wallet_name, descriptors=False)
|
self.nodes[0].createwallet(self.default_wallet_name)
|
||||||
exp_stderr = r"Error: Error initializing wallet database environment \"\S+competing_walletdir\S*\"!"
|
if self.options.descriptors:
|
||||||
|
exp_stderr = r"Error: SQLiteDatabase: Unable to obtain an exclusive lock on the database, is it being used by another bitcoind?"
|
||||||
|
else:
|
||||||
|
exp_stderr = r"Error: Error initializing wallet database environment \"\S+competing_walletdir\S*\"!"
|
||||||
self.nodes[1].assert_start_raises_init_error(['-walletdir=' + competing_wallet_dir], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
|
self.nodes[1].assert_start_raises_init_error(['-walletdir=' + competing_wallet_dir], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
|
||||||
|
|
||||||
self.restart_node(0)
|
self.restart_node(0)
|
||||||
for wallet_name in wallet_names:
|
for wallet_name in wallet_names:
|
||||||
self.nodes[0].loadwallet(wallet_name)
|
self.nodes[0].loadwallet(wallet_name)
|
||||||
|
|
||||||
assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [self.default_wallet_name, os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8', 'w8_copy'])
|
assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), sorted(in_wallet_dir))
|
||||||
|
|
||||||
wallets = [wallet(w) for w in wallet_names]
|
wallets = [wallet(w) for w in wallet_names]
|
||||||
wallet_bad = wallet("bad")
|
wallet_bad = wallet("bad")
|
||||||
@@ -266,18 +281,22 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Fail to load duplicate wallets
|
# Fail to load duplicate wallets
|
||||||
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "w1", "wallet.dat")
|
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "w1", "wallet.dat")
|
||||||
assert_raises_rpc_error(-4, "Wallet file verification failed. Refusing to load database. Data file '{}' is already loaded.".format(path), self.nodes[0].loadwallet, wallet_names[0])
|
if self.options.descriptors:
|
||||||
|
assert_raises_rpc_error(-4, "Wallet file verification failed. SQLiteDatabase: Unable to obtain an exclusive lock on the database, is it being used by another bitcoind?", self.nodes[0].loadwallet, wallet_names[0])
|
||||||
|
else:
|
||||||
|
assert_raises_rpc_error(-4, "Wallet file verification failed. Refusing to load database. Data file '{}' is already loaded.".format(path), self.nodes[0].loadwallet, wallet_names[0])
|
||||||
|
|
||||||
# Fail to load duplicate wallets by different ways (directory and filepath)
|
# This tests the default wallet that BDB makes, so SQLite wallet doesn't need to test this
|
||||||
if not self.options.descriptors:
|
# Fail to load duplicate wallets by different ways (directory and filepath)
|
||||||
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "wallet.dat")
|
path = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets", "wallet.dat")
|
||||||
assert_raises_rpc_error(-4, "Wallet file verification failed. Refusing to load database. Data file '{}' is already loaded.".format(path), self.nodes[0].loadwallet, 'wallet.dat')
|
assert_raises_rpc_error(-4, "Wallet file verification failed. Refusing to load database. Data file '{}' is already loaded.".format(path), self.nodes[0].loadwallet, 'wallet.dat')
|
||||||
|
|
||||||
# Fail to load if one wallet is a copy of another
|
# Only BDB doesn't open duplicate wallet files. SQLite does not have this limitation. While this may be desired in the future, it is not necessary
|
||||||
assert_raises_rpc_error(-4, "BerkeleyDatabase: Can't open database w8_copy (duplicates fileid", self.nodes[0].loadwallet, 'w8_copy')
|
# Fail to load if one wallet is a copy of another
|
||||||
|
assert_raises_rpc_error(-4, "BerkeleyDatabase: Can't open database w8_copy (duplicates fileid", self.nodes[0].loadwallet, 'w8_copy')
|
||||||
|
|
||||||
# Fail to load if one wallet is a copy of another, test this twice to make sure that we don't re-introduce #14304
|
# Fail to load if one wallet is a copy of another, test this twice to make sure that we don't re-introduce #14304
|
||||||
assert_raises_rpc_error(-4, "BerkeleyDatabase: Can't open database w8_copy (duplicates fileid", self.nodes[0].loadwallet, 'w8_copy')
|
assert_raises_rpc_error(-4, "BerkeleyDatabase: Can't open database w8_copy (duplicates fileid", self.nodes[0].loadwallet, 'w8_copy')
|
||||||
|
|
||||||
|
|
||||||
# Fail to load if wallet file is a symlink
|
# Fail to load if wallet file is a symlink
|
||||||
@@ -296,6 +315,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Successfully create a wallet with a new name
|
# Successfully create a wallet with a new name
|
||||||
loadwallet_name = self.nodes[0].createwallet('w9')
|
loadwallet_name = self.nodes[0].createwallet('w9')
|
||||||
|
in_wallet_dir.append('w9')
|
||||||
assert_equal(loadwallet_name['name'], 'w9')
|
assert_equal(loadwallet_name['name'], 'w9')
|
||||||
w9 = node.get_wallet_rpc('w9')
|
w9 = node.get_wallet_rpc('w9')
|
||||||
assert_equal(w9.getwalletinfo()['walletname'], 'w9')
|
assert_equal(w9.getwalletinfo()['walletname'], 'w9')
|
||||||
@@ -343,7 +363,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||||||
assert_equal(self.nodes[0].listwallets(), ['w1'])
|
assert_equal(self.nodes[0].listwallets(), ['w1'])
|
||||||
assert_equal(w1.getwalletinfo()['walletname'], 'w1')
|
assert_equal(w1.getwalletinfo()['walletname'], 'w1')
|
||||||
|
|
||||||
assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), [self.default_wallet_name, os.path.join('sub', 'w5'), 'w', 'w1', 'w2', 'w3', 'w7', 'w7_symlink', 'w8', 'w8_copy', 'w9'])
|
assert_equal(sorted(map(lambda w: w['name'], self.nodes[0].listwalletdir()['wallets'])), sorted(in_wallet_dir))
|
||||||
|
|
||||||
# Test backing up and restoring wallets
|
# Test backing up and restoring wallets
|
||||||
self.log.info("Test wallet backup")
|
self.log.info("Test wallet backup")
|
||||||
|
|||||||
Reference in new issue
Block a user