[SON-242] fix list_active_sons call after deleting an active son (#292)
* test to reproduce error in list_active_sons after delete_son * prevent exception in list_active_list
This commit is contained in:
parent
a968ec922c
commit
a9cfadc500
2 changed files with 15 additions and 9 deletions
|
|
@ -1988,19 +1988,22 @@ public:
|
|||
});
|
||||
std::vector<fc::optional<son_object>> son_objects = _remote_db->get_sons(son_ids);
|
||||
vector<account_id_type> owners;
|
||||
owners.resize(son_objects.size());
|
||||
std::transform(son_objects.begin(), son_objects.end(), owners.begin(),
|
||||
[](const fc::optional<son_object>& obj) {
|
||||
FC_ASSERT(obj, "Invalid active SONs list in global properties.");
|
||||
return obj->son_account;
|
||||
});
|
||||
for(auto obj: son_objects)
|
||||
{
|
||||
if (obj)
|
||||
owners.push_back(obj->son_account);
|
||||
}
|
||||
vector<fc::optional<account_object>> accs = _remote_db->get_accounts(owners);
|
||||
std::remove_if(son_objects.begin(), son_objects.end(),
|
||||
[](const fc::optional<son_object>& obj) -> bool { return obj.valid(); });
|
||||
map<string, son_id_type> result;
|
||||
std::transform(accs.begin(), accs.end(), son_ids.begin(),
|
||||
std::transform(accs.begin(), accs.end(), son_objects.begin(),
|
||||
std::inserter(result, result.end()),
|
||||
[](fc::optional<account_object>& acct, son_id_type& sid) {
|
||||
[](fc::optional<account_object>& acct, fc::optional<son_object> son) {
|
||||
FC_ASSERT(acct, "Invalid active SONs list in global properties.");
|
||||
return std::make_pair<string, son_id_type>(string(acct->name), std::move(sid));
|
||||
if (son.valid())
|
||||
return std::make_pair<string, son_id_type>(string(acct->name), std::move(son->id));
|
||||
return std::make_pair<string, son_id_type>(string(acct->name), std::move(son_id_type()));
|
||||
});
|
||||
return result;
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
|
|
|||
|
|
@ -650,6 +650,9 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
|
|||
BOOST_CHECK(active_sons.find(name) != active_sons.end());
|
||||
}
|
||||
|
||||
// check list_active_son after SON deletion
|
||||
con.wallet_api_ptr->delete_son("sonaccount1", true);
|
||||
BOOST_CHECK_NO_THROW(con.wallet_api_ptr->list_active_sons());
|
||||
} catch( fc::exception& e ) {
|
||||
BOOST_TEST_MESSAGE("SON cli wallet tests exception");
|
||||
edump((e.to_detail_string()));
|
||||
|
|
|
|||
Loading…
Reference in a new issue