forked from lthn/blockchain
changes and fixes over few tests in connection to hardfork 4
This commit is contained in:
parent
ef3385192f
commit
100d46fa9b
3 changed files with 20 additions and 4 deletions
|
|
@ -1068,7 +1068,7 @@ bool gen_alias_too_small_reward::generate(std::vector<test_event_entry>& events)
|
||||||
set_hard_fork_heights_to_generator(generator);
|
set_hard_fork_heights_to_generator(generator);
|
||||||
DO_CALLBACK(events, "configure_core");
|
DO_CALLBACK(events, "configure_core");
|
||||||
DO_CALLBACK(events, "init_runtime_config");
|
DO_CALLBACK(events, "init_runtime_config");
|
||||||
REWIND_BLOCKS_N_WITH_TIME(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
REWIND_BLOCKS_N_WITH_TIME(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW+20);
|
||||||
|
|
||||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||||
r = construct_tx_with_many_outputs(m_hardforks, events, blk_0r, miner_acc.get_keys(), miner_acc.get_public_address(), 3 * aliases_count * TESTS_DEFAULT_FEE * 100, 3 * aliases_count, TESTS_DEFAULT_FEE, tx_1);
|
r = construct_tx_with_many_outputs(m_hardforks, events, blk_0r, miner_acc.get_keys(), miner_acc.get_public_address(), 3 * aliases_count * TESTS_DEFAULT_FEE * 100, 3 * aliases_count, TESTS_DEFAULT_FEE, tx_1);
|
||||||
|
|
@ -1271,7 +1271,8 @@ bool gen_alias_switch_and_check_block_template::generate(std::vector<test_event_
|
||||||
uint64_t miner_amount = get_outs_money_amount(blk_0r.miner_tx, miner_acc.get_keys()) * 4;
|
uint64_t miner_amount = get_outs_money_amount(blk_0r.miner_tx, miner_acc.get_keys()) * 4;
|
||||||
// alice get some money
|
// alice get some money
|
||||||
MAKE_TX_LIST(events, tx_list, miner_acc, alice, miner_amount / 2, blk_0r); // 2N+3
|
MAKE_TX_LIST(events, tx_list, miner_acc, alice, miner_amount / 2, blk_0r); // 2N+3
|
||||||
MAKE_NEXT_BLOCK_TX_LIST(events, blk_1, blk_0r, miner_acc, tx_list); // 2N+4
|
MAKE_NEXT_BLOCK_TX_LIST(events, blk_1_, blk_0r, miner_acc, tx_list); // 2N+4
|
||||||
|
REWIND_BLOCKS_N_WITH_TIME(events, blk_1, blk_1_, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 1); // 2N = CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 2
|
||||||
tx_list.clear();
|
tx_list.clear();
|
||||||
|
|
||||||
// Alice registers an alias
|
// Alice registers an alias
|
||||||
|
|
|
||||||
|
|
@ -448,6 +448,16 @@ bool test_generator::build_wallets(const blockchain_vector& blockchain,
|
||||||
{
|
{
|
||||||
for (uint64_t amount : rqt.amounts)
|
for (uint64_t amount : rqt.amounts)
|
||||||
{
|
{
|
||||||
|
uint64_t height_upper_limit_local = rqt.height_upper_limit;
|
||||||
|
if (amount == 0)
|
||||||
|
{
|
||||||
|
//for hardfork 4 we need to have at least 10 confirmations on hard rule level
|
||||||
|
//rqt.height_upper_limit > - 10
|
||||||
|
if (m_blockchain.size() < CURRENCY_HF4_MANDATORY_MIN_COINAGE)
|
||||||
|
return false;
|
||||||
|
if (height_upper_limit_local > m_blockchain.size() - CURRENCY_HF4_MANDATORY_MIN_COINAGE)
|
||||||
|
height_upper_limit_local = m_blockchain.size() - CURRENCY_HF4_MANDATORY_MIN_COINAGE;
|
||||||
|
}
|
||||||
rsp.outs.resize(rsp.outs.size() + 1);
|
rsp.outs.resize(rsp.outs.size() + 1);
|
||||||
auto& rsp_entry = rsp.outs.back();
|
auto& rsp_entry = rsp.outs.back();
|
||||||
rsp_entry.amount = amount;
|
rsp_entry.amount = amount;
|
||||||
|
|
@ -463,7 +473,7 @@ bool test_generator::build_wallets(const blockchain_vector& blockchain,
|
||||||
for (size_t gindex : random_mapping)
|
for (size_t gindex : random_mapping)
|
||||||
{
|
{
|
||||||
const out_index_info& oii = it->second[gindex];
|
const out_index_info& oii = it->second[gindex];
|
||||||
if (rqt.height_upper_limit != 0 && oii.block_height > rqt.height_upper_limit)
|
if (height_upper_limit_local != 0 && oii.block_height > height_upper_limit_local)
|
||||||
continue;
|
continue;
|
||||||
const transaction& tx = oii.in_block_tx_index == 0 ? m_blockchain[oii.block_height]->b.miner_tx : m_blockchain[oii.block_height]->m_transactions[oii.in_block_tx_index - 1];
|
const transaction& tx = oii.in_block_tx_index == 0 ? m_blockchain[oii.block_height]->b.miner_tx : m_blockchain[oii.block_height]->m_transactions[oii.in_block_tx_index - 1];
|
||||||
auto& out_v = tx.vout[oii.in_tx_out_index];
|
auto& out_v = tx.vout[oii.in_tx_out_index];
|
||||||
|
|
@ -1485,6 +1495,11 @@ bool fill_tx_sources(std::vector<currency::tx_source_entry>& sources, const std:
|
||||||
if (unlock_time > head_block_ts + DIFFICULTY_TOTAL_TARGET)
|
if (unlock_time > head_block_ts + DIFFICULTY_TOTAL_TARGET)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (blk_head.miner_tx.version < TRANSACTION_VERSION_POST_HF4 && next_block_height - get_block_height(*oi.p_blk) < CURRENCY_HF4_MANDATORY_MIN_COINAGE)
|
||||||
|
{
|
||||||
|
//ignore outs that doesn't fit the HF4 rule
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -794,7 +794,7 @@ bool zarcanum_block_with_txs::generate(std::vector<test_event_entry>& events) co
|
||||||
MAKE_NEXT_BLOCK_TX1(events, blk_4, blk_3, miner_acc, tx_2);
|
MAKE_NEXT_BLOCK_TX1(events, blk_4, blk_3, miner_acc, tx_2);
|
||||||
m_alice_balance += MK_TEST_COINS(200);
|
m_alice_balance += MK_TEST_COINS(200);
|
||||||
|
|
||||||
REWIND_BLOCKS_N_WITH_TIME(events, blk_4r, blk_4, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
REWIND_BLOCKS_N_WITH_TIME(events, blk_4r, blk_4, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW+5);
|
||||||
DO_CALLBACK_PARAMS(events, "check_balance", params_check_balance(ALICE_ACC_IDX, m_alice_balance, m_alice_balance, mined_amount, 0, 0));
|
DO_CALLBACK_PARAMS(events, "check_balance", params_check_balance(ALICE_ACC_IDX, m_alice_balance, m_alice_balance, mined_amount, 0, 0));
|
||||||
|
|
||||||
// then miner sends few coins to Bob via a tx with a big fee amount
|
// then miner sends few coins to Bob via a tx with a big fee amount
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue