Skip to content

Commit fa59cc1

Browse files
author
MarcoFalke
committed
wallet: Report full error message in wallettool
1 parent fae7776 commit fa59cc1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/wallet/wallettool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
120120
}
121121
bilingual_str error;
122122
if (!WalletBatch::VerifyEnvironment(path, error)) {
123-
tfm::format(std::cerr, "Error loading %s. Is wallet being used by other process?\n", name);
123+
tfm::format(std::cerr, "%s\nError loading %s. Is wallet being used by other process?\n", error.original, name);
124124
return false;
125125
}
126126
std::shared_ptr<CWallet> wallet_instance = LoadWallet(name, path);

test/functional/tool_wallet.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
BUFFER_SIZE = 16 * 1024
1717

18+
1819
class ToolWalletTest(BitcoinTestFramework):
1920
def set_test_params(self):
2021
self.num_nodes = 1
@@ -48,7 +49,7 @@ def wallet_shasum(self):
4849
h = hashlib.sha1()
4950
mv = memoryview(bytearray(BUFFER_SIZE))
5051
with open(self.wallet_path, 'rb', buffering=0) as f:
51-
for n in iter(lambda : f.readinto(mv), 0):
52+
for n in iter(lambda: f.readinto(mv), 0):
5253
h.update(mv[:n])
5354
return h.hexdigest()
5455

@@ -69,7 +70,12 @@ def test_invalid_tool_commands_and_args(self):
6970
self.assert_raises_tool_error('Invalid command: help', 'help')
7071
self.assert_raises_tool_error('Error: two methods provided (info and create). Only one method should be provided.', 'info', 'create')
7172
self.assert_raises_tool_error('Error parsing command line arguments: Invalid parameter -foo', '-foo')
72-
self.assert_raises_tool_error('Error loading wallet.dat. Is wallet being used by other process?', '-wallet=wallet.dat', 'info')
73+
self.assert_raises_tool_error(
74+
'Error initializing wallet database environment "{}"!\nError loading wallet.dat. Is wallet being used by other process?'
75+
.format(os.path.join(self.nodes[0].datadir, self.chain, 'wallets')),
76+
'-wallet=wallet.dat',
77+
'info',
78+
)
7379
self.assert_raises_tool_error('Error: no wallet file at nonexistent.dat', '-wallet=nonexistent.dat', 'info')
7480

7581
def test_tool_wallet_info(self):
@@ -84,7 +90,7 @@ def test_tool_wallet_info(self):
8490
#
8591
# self.log.debug('Setting wallet file permissions to 400 (read-only)')
8692
# os.chmod(self.wallet_path, stat.S_IRUSR)
87-
# assert(self.wallet_permissions() in ['400', '666']) # Sanity check. 666 because Appveyor.
93+
# assert self.wallet_permissions() in ['400', '666'] # Sanity check. 666 because Appveyor.
8894
# shasum_before = self.wallet_shasum()
8995
timestamp_before = self.wallet_timestamp()
9096
self.log.debug('Wallet file timestamp before calling info: {}'.format(timestamp_before))
@@ -103,7 +109,7 @@ def test_tool_wallet_info(self):
103109
self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after)
104110
self.log.debug('Setting wallet file permissions back to 600 (read/write)')
105111
os.chmod(self.wallet_path, stat.S_IRUSR | stat.S_IWUSR)
106-
assert(self.wallet_permissions() in ['600', '666']) # Sanity check. 666 because Appveyor.
112+
assert self.wallet_permissions() in ['600', '666'] # Sanity check. 666 because Appveyor.
107113
#
108114
# TODO: Wallet tool info should not write to the wallet file.
109115
# The following lines should be uncommented and the tests still succeed:

0 commit comments

Comments
 (0)