Skip to content
Bitcoin Roots

v31.1-roots.1 · Commit 6: [PATCH 06/17] feat(wallet): preserve Roots signing and spend controls on v31

test/functional/wallet_multiwallet.py

Before: test/functional/wallet_multiwallet.py · After: test/functional/wallet_multiwallet.py

File metadata
index 07bd7cb204cacd825a7bbb3b297df111af290070..4fbd9a1e1572b4eb4c59e670de29eec7b0cf5bae 100755

Download original patch · Release notes

Diff rows 1–37 of 37. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

test/functional/wallet_multiwallet.py CHANGED
@@ -201,6 +201,37 @@ class MultiWalletTest(BitcoinTestFramework):
201
201
  w5 = wallet("w5")
202
202
  assert_equal(w5.getbalances()["mine"]["immature"], 50)
203
203
 
204
+ if platform.system() != 'Windows' and os.geteuid() != 0:
205
+ self.log.info("Reject opening a wallet whose database directory cannot be written")
206
+ node.unloadwallet('w5')
207
+ os.chmod(data_dir('w5'), stat.S_IRUSR | stat.S_IXUSR)
208
+ try:
209
+ assert_raises_rpc_error(-4, 'directory is not writable', node.loadwallet, 'w5')
210
+ finally:
211
+ os.chmod(data_dir('w5'), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
212
+ node.loadwallet('w5')
213
+
214
+ self.log.info("Verify wallet discovery does not descend into node databases")
215
+ hidden_wallet_dir = data_dir('indexes', 'wallet_discovery_fixture')
216
+ os.makedirs(hidden_wallet_dir)
217
+ w5.backupwallet(os.path.join(hidden_wallet_dir, 'wallet.dat'))
218
+ discovered = {w['name'] for w in node.listwalletdir()['wallets']}
219
+ assert 'w5' in discovered
220
+ assert 'indexes/wallet_discovery_fixture' not in discovered
221
+ shutil.rmtree(hidden_wallet_dir)
222
+ if os.name != 'nt':
223
+ self.log.info("Verify wallet discovery does not descend through symlinks")
224
+ linked_wallet_dir = os.path.join(self.options.tmpdir, 'linked_wallet_fixture')
225
+ nested_wallet_dir = os.path.join(linked_wallet_dir, 'nested')
226
+ os.makedirs(nested_wallet_dir)
227
+ w5.backupwallet(os.path.join(nested_wallet_dir, 'wallet.dat'))
228
+ link = data_dir('wallet_discovery_link')
229
+ os.symlink(linked_wallet_dir, link, target_is_directory=True)
230
+ discovered = {w['name'] for w in node.listwalletdir()['wallets']}
231
+ assert 'wallet_discovery_link/nested' not in discovered
232
+ os.unlink(link)
233
+ shutil.rmtree(linked_wallet_dir)
234
+
204
235
  competing_wallet_dir = os.path.join(self.options.tmpdir, 'competing_walletdir')
205
236
  os.mkdir(competing_wallet_dir)
206
237
  self.restart_node(0, ['-nowallet', '-walletdir=' + competing_wallet_dir])