forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util/system datadir code should not care about wallets or create any wallet paths If -walletdir is specified, wallet init code should use that directory If -walletdir is specified and path is not a directory, return a fatal error If -walletdir is not specified, use <datadir>/wallets if it is directory. If -walletdir is not specified and <datadir>/wallets does not exist: <datadir>/wallets wallet should call ListWalletDir ListDatabases on <datadir> If list is empty wallet should create <datadir>/wallets as a directory, otherwise it should create it as a symlink pointing to . discussion at bitcoin#16220
- Loading branch information
1 parent
76d8957
commit dfe62e9
Showing
9 changed files
with
83 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2017-2022 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
"""Test wallet load on startup. | ||
Verify that a bitcoind node can initialise wallet directory correctly on startup | ||
""" | ||
|
||
import os | ||
import shutil | ||
|
||
from test_framework.test_framework import BitcoinTestFramework | ||
from test_framework.util import ( | ||
assert_equal, | ||
) | ||
|
||
|
||
class WalletInitTest(BitcoinTestFramework): | ||
def add_options(self, parser): | ||
self.add_wallet_options(parser) | ||
|
||
def set_test_params(self): | ||
self.num_nodes = 4 | ||
|
||
def skip_test_if_missing_module(self): | ||
self.skip_if_no_wallet() | ||
|
||
def setup_nodes(self): | ||
self.add_nodes(self.num_nodes) | ||
self.start_nodes() | ||
|
||
def run_test(self): | ||
self.log.info('Test node0 is initialized with a wallets/ dir') | ||
node0_data_dir = self.nodes[0].chain_path | ||
assert_equal(os.path.isdir(os.path.join(node0_data_dir, "wallets")), True) | ||
self.nodes[0].createwallet("w0") | ||
assert_equal(self.nodes[0].listwallets(), ['w0']) | ||
assert_equal(os.path.isdir(os.path.join(node0_data_dir, "wallets", "w0")), True) | ||
|
||
self.log.info('Test node2 initialized with invalid -walletsdir') | ||
node2_data_dir = self.nodes[2].chain_path | ||
self.stop_node(2) | ||
self.nodes[2].assert_start_raises_init_error(['-walletdir=wallets'], 'Error: Specified -walletdir "wallets" does not exist') | ||
self.nodes[2].assert_start_raises_init_error(['-walletdir=wallets'], 'Error: Specified -walletdir "wallets" is a relative path', cwd=node2_data_dir) | ||
self.nodes[2].assert_start_raises_init_error(['-walletdir=debug.log'], 'Error: Specified -walletdir "debug.log" is not a directory', cwd=node2_data_dir) | ||
|
||
self.log.info('Test node3 is initialized with a valid -walletsdir') | ||
node3_data_dir = self.nodes[3].chain_path | ||
new_walletdir = os.path.join(node3_data_dir, "my_wallets") | ||
self.stop_node(3) | ||
shutil.rmtree(os.path.join(node3_data_dir, "wallets")) | ||
os.makedirs(new_walletdir) | ||
self.restart_node(3, ['-walletdir=' + str(new_walletdir)]) | ||
self.nodes[3].createwallet("w3") | ||
assert_equal(self.nodes[3].listwallets(), ["w3"]) | ||
assert_equal(os.path.isdir(os.path.join(new_walletdir, "w3")), True) | ||
|
||
if __name__ == '__main__': | ||
WalletInitTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters