Fixing crash when importing corrupt legacy wallet files.
This commit is contained in:
parent
99fb756386
commit
49d773b9a2
2 changed files with 17 additions and 1 deletions
|
@ -588,6 +588,15 @@ TEST (wallet_store, fail_import_bad_password)
|
|||
ASSERT_TRUE (error);
|
||||
}
|
||||
|
||||
TEST (wallet_store, fail_import_corrupt)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
auto wallet1 (system.wallet (1));
|
||||
std::string json;
|
||||
auto error (wallet1->import (json, "1"));
|
||||
ASSERT_TRUE (error);
|
||||
}
|
||||
|
||||
// Test arbitrary work can be generated
|
||||
TEST (wallet, empty_work)
|
||||
{
|
||||
|
|
|
@ -405,7 +405,14 @@ environment (transaction_a.environment)
|
|||
assert (mdb_get (transaction_a, handle, version_special.val (), &junk) == MDB_NOTFOUND);
|
||||
boost::property_tree::ptree wallet_l;
|
||||
std::stringstream istream (json_a);
|
||||
boost::property_tree::read_json (istream, wallet_l);
|
||||
try
|
||||
{
|
||||
boost::property_tree::read_json (istream, wallet_l);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
init_a = true;
|
||||
}
|
||||
for (auto i (wallet_l.begin ()), n (wallet_l.end ()); i != n; ++i)
|
||||
{
|
||||
rai::uint256_union key;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue