forked from lthn/blockchain
coretests: minor improvements
This commit is contained in:
parent
096de774b1
commit
138c7e2ae0
4 changed files with 18 additions and 11 deletions
|
|
@ -1698,7 +1698,7 @@ bool check_balance_via_wallet(const tools::wallet2& w, const char* account_name,
|
|||
uint64_t total, unlocked, awaiting_in, awaiting_out, mined;
|
||||
balance_via_wallet(w, &total, &unlocked, &awaiting_in, &awaiting_out, &mined);
|
||||
|
||||
LOG_PRINT_CYAN("Balance for wallet " << account_name << ":" << ENDL <<
|
||||
LOG_PRINT_CYAN("Balance for wallet " << account_name << " @ height " << w.get_top_block_height() << ":" << ENDL <<
|
||||
"unlocked: " << print_money(unlocked) << ENDL <<
|
||||
"awaiting in: " << print_money(awaiting_in) << ENDL <<
|
||||
"awaiting out: " << print_money(awaiting_out) << ENDL <<
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ bool hard_fork_2_tx_payer_in_wallet::generate(std::vector<test_event_entry>& eve
|
|||
account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(true); // Bob has auditable address
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
|
||||
set_hard_fork_heights_to_generator(generator);
|
||||
DO_CALLBACK(events, "configure_core");
|
||||
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
|
|
@ -307,7 +306,6 @@ bool hard_fork_2_tx_receiver_in_wallet::generate(std::vector<test_event_entry>&
|
|||
account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(true); // Bob has auditable address
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
|
||||
set_hard_fork_heights_to_generator(generator);
|
||||
DO_CALLBACK(events, "configure_core");
|
||||
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 1);
|
||||
|
||||
|
|
@ -448,7 +446,6 @@ bool hard_fork_2_tx_extra_alias_entry_in_wallet::generate(std::vector<test_event
|
|||
account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(true); // auditable address
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
|
||||
set_hard_fork_heights_to_generator(generator);
|
||||
DO_CALLBACK(events, "configure_core");
|
||||
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
|
|
@ -640,7 +637,6 @@ bool hard_fork_2_auditable_addresses_basics::generate(std::vector<test_event_ent
|
|||
account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(true); // Bob has auditable address
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
|
||||
set_hard_fork_heights_to_generator(generator);
|
||||
DO_CALLBACK(events, "configure_core");
|
||||
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
|
|
@ -750,7 +746,6 @@ bool hard_fork_2_no_new_structures_before_hf::generate(std::vector<test_event_en
|
|||
account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate();
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
|
||||
set_hard_fork_heights_to_generator(generator);
|
||||
DO_CALLBACK(events, "configure_core");
|
||||
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
|
|
@ -888,7 +883,6 @@ bool hard_fork_2_awo_wallets_basic_test<before_hf_2>::generate(std::vector<test_
|
|||
account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(true); // Bob has auditable address
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
|
||||
set_hard_fork_heights_to_generator(generator);
|
||||
DO_CALLBACK(events, "configure_core");
|
||||
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
|
|
@ -1162,7 +1156,6 @@ bool hard_fork_2_alias_update_using_old_tx<before_hf_2>::generate(std::vector<te
|
|||
alice_acc.set_createtime(ts);
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, ts);
|
||||
set_hard_fork_heights_to_generator(generator);
|
||||
DO_CALLBACK(events, "configure_core");
|
||||
events.push_back(event_core_time(ts));
|
||||
|
||||
|
|
@ -1280,7 +1273,6 @@ bool hard_fork_2_incorrect_alias_update<before_hf_2>::generate(std::vector<test_
|
|||
account_base& bob_acc = m_accounts[BOB_ACC_IDX]; bob_acc.generate(true); // Bob has auditable address
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
|
||||
set_hard_fork_heights_to_generator(generator);
|
||||
DO_CALLBACK(events, "configure_core");
|
||||
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ bool wallet_test::check_balance_via_build_wallets(currency::core& c, size_t ev_i
|
|||
r = generator.build_wallets(get_block_hash(*top_block), accounts, w, c.get_blockchain_storage().get_core_runtime_config());
|
||||
CHECK_AND_ASSERT_MES(r && w.size() == 1 && w[0].wallet != 0, false, "check_balance: failed to build wallets");
|
||||
|
||||
if (!check_balance_via_wallet(*w[0].wallet, epee::string_tools::num_to_string_fast(pcb.account_index).c_str(), pcb.total_balance, pcb.mined_balance, pcb.unlocked_balance, pcb.awaiting_in, pcb.awaiting_out))
|
||||
if (!check_balance_via_wallet(*w[0].wallet, get_test_account_name_by_id(pcb.account_index).c_str(), pcb.total_balance, pcb.mined_balance, pcb.unlocked_balance, pcb.awaiting_in, pcb.awaiting_out))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -67,12 +67,25 @@ bool wallet_test::check_balance(currency::core& c, size_t ev_index, const std::v
|
|||
bool has_aliases = false;
|
||||
w->scan_tx_pool(has_aliases);
|
||||
|
||||
if (!check_balance_via_wallet(*w.get(), epee::string_tools::num_to_string_fast(pcb.account_index).c_str(), pcb.total_balance, pcb.mined_balance, pcb.unlocked_balance, pcb.awaiting_in, pcb.awaiting_out))
|
||||
if (!check_balance_via_wallet(*w.get(), get_test_account_name_by_id(pcb.account_index).c_str(), pcb.total_balance, pcb.mined_balance, pcb.unlocked_balance, pcb.awaiting_in, pcb.awaiting_out))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string wallet_test::get_test_account_name_by_id(size_t acc_id)
|
||||
{
|
||||
switch(acc_id)
|
||||
{
|
||||
case MINER_ACC_IDX: return "miner";
|
||||
case ALICE_ACC_IDX: return "Alice";
|
||||
case BOB_ACC_IDX: return "Bob";
|
||||
case CAROL_ACC_IDX: return "Carol";
|
||||
case DAN_ACC_IDX: return "Dan";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<tools::wallet2> wallet_test::init_playtime_test_wallet(const std::vector<test_event_entry>& events, currency::core& c, const account_base& acc) const
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(events.size() > 0 && events[0].type() == typeid(currency::block), "Invalid events queue, can't find genesis block at the beginning");
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ struct wallet_test : virtual public test_chain_unit_enchanced
|
|||
bool check_balance_via_build_wallets(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
|
||||
bool check_balance(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
|
||||
|
||||
static std::string get_test_account_name_by_id(size_t acc_id);
|
||||
|
||||
protected:
|
||||
|
||||
struct params_check_balance
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue