mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
wallet: Report full error message in wallettool
This commit is contained in:
parent
fae7776690
commit
fa59cc1c97
2 changed files with 11 additions and 5 deletions
|
@ -120,7 +120,7 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
|
|||
}
|
||||
bilingual_str error;
|
||||
if (!WalletBatch::VerifyEnvironment(path, error)) {
|
||||
tfm::format(std::cerr, "Error loading %s. Is wallet being used by other process?\n", name);
|
||||
tfm::format(std::cerr, "%s\nError loading %s. Is wallet being used by other process?\n", error.original, name);
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<CWallet> wallet_instance = LoadWallet(name, path);
|
||||
|
|
|
@ -15,6 +15,7 @@ from test_framework.util import assert_equal
|
|||
|
||||
BUFFER_SIZE = 16 * 1024
|
||||
|
||||
|
||||
class ToolWalletTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
|
@ -48,7 +49,7 @@ class ToolWalletTest(BitcoinTestFramework):
|
|||
h = hashlib.sha1()
|
||||
mv = memoryview(bytearray(BUFFER_SIZE))
|
||||
with open(self.wallet_path, 'rb', buffering=0) as f:
|
||||
for n in iter(lambda : f.readinto(mv), 0):
|
||||
for n in iter(lambda: f.readinto(mv), 0):
|
||||
h.update(mv[:n])
|
||||
return h.hexdigest()
|
||||
|
||||
|
@ -69,7 +70,12 @@ class ToolWalletTest(BitcoinTestFramework):
|
|||
self.assert_raises_tool_error('Invalid command: help', 'help')
|
||||
self.assert_raises_tool_error('Error: two methods provided (info and create). Only one method should be provided.', 'info', 'create')
|
||||
self.assert_raises_tool_error('Error parsing command line arguments: Invalid parameter -foo', '-foo')
|
||||
self.assert_raises_tool_error('Error loading wallet.dat. Is wallet being used by other process?', '-wallet=wallet.dat', 'info')
|
||||
self.assert_raises_tool_error(
|
||||
'Error initializing wallet database environment "{}"!\nError loading wallet.dat. Is wallet being used by other process?'
|
||||
.format(os.path.join(self.nodes[0].datadir, self.chain, 'wallets')),
|
||||
'-wallet=wallet.dat',
|
||||
'info',
|
||||
)
|
||||
self.assert_raises_tool_error('Error: no wallet file at nonexistent.dat', '-wallet=nonexistent.dat', 'info')
|
||||
|
||||
def test_tool_wallet_info(self):
|
||||
|
@ -84,7 +90,7 @@ class ToolWalletTest(BitcoinTestFramework):
|
|||
#
|
||||
# self.log.debug('Setting wallet file permissions to 400 (read-only)')
|
||||
# os.chmod(self.wallet_path, stat.S_IRUSR)
|
||||
# assert(self.wallet_permissions() in ['400', '666']) # Sanity check. 666 because Appveyor.
|
||||
# assert self.wallet_permissions() in ['400', '666'] # Sanity check. 666 because Appveyor.
|
||||
# shasum_before = self.wallet_shasum()
|
||||
timestamp_before = self.wallet_timestamp()
|
||||
self.log.debug('Wallet file timestamp before calling info: {}'.format(timestamp_before))
|
||||
|
@ -103,7 +109,7 @@ class ToolWalletTest(BitcoinTestFramework):
|
|||
self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after)
|
||||
self.log.debug('Setting wallet file permissions back to 600 (read/write)')
|
||||
os.chmod(self.wallet_path, stat.S_IRUSR | stat.S_IWUSR)
|
||||
assert(self.wallet_permissions() in ['600', '666']) # Sanity check. 666 because Appveyor.
|
||||
assert self.wallet_permissions() in ['600', '666'] # Sanity check. 666 because Appveyor.
|
||||
#
|
||||
# TODO: Wallet tool info should not write to the wallet file.
|
||||
# The following lines should be uncommented and the tests still succeed:
|
||||
|
|
Loading…
Reference in a new issue