forked from lthn/blockchain
fixed all coretests
This commit is contained in:
parent
ce4b04014b
commit
ca760a237a
16 changed files with 40 additions and 31 deletions
|
|
@ -408,7 +408,7 @@ bool generate_genesis(const std::string& path_config, uint64_t premine_split_amo
|
|||
ss.str("");
|
||||
ss.clear();
|
||||
std::cout << ENDL << "PROOF PHRASE: " << gcp.proof_string << ENDL;
|
||||
construct_miner_tx(0, 0, 0, 0, 0, destinations, bl.miner_tx, gcp.proof_string, CURRENCY_MINER_TX_MAX_OUTS);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, destinations, bl.miner_tx, TRANSACTION_VERSION_PRE_HF4, gcp.proof_string, CURRENCY_MINER_TX_MAX_OUTS);
|
||||
currency::blobdata txb = tx_to_blob(bl.miner_tx);
|
||||
|
||||
//self validate block
|
||||
|
|
|
|||
|
|
@ -1487,7 +1487,9 @@ bool blockchain_storage::create_block_template(const create_block_template_param
|
|||
fee,
|
||||
miner_address,
|
||||
stakeholder_address,
|
||||
b.miner_tx, ex_nonce,
|
||||
b.miner_tx,
|
||||
get_tx_version(height, m_core_runtime_config.hard_forks),
|
||||
ex_nonce,
|
||||
CURRENCY_MINER_TX_MAX_OUTS,
|
||||
pos,
|
||||
pe);
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ namespace currency
|
|||
|
||||
struct hard_forks_descriptor
|
||||
{
|
||||
uint64_t hard_fork_01_starts_after_height;
|
||||
uint64_t hard_fork_02_starts_after_height;
|
||||
uint64_t hard_fork_03_starts_after_height;
|
||||
uint64_t hard_fork_04_starts_after_height;
|
||||
uint64_t hard_fork_01_starts_after_height = 0;
|
||||
uint64_t hard_fork_02_starts_after_height = 0;
|
||||
uint64_t hard_fork_03_starts_after_height = 0;
|
||||
uint64_t hard_fork_04_starts_after_height = UINT64_MAX;
|
||||
};
|
||||
|
||||
struct core_runtime_config
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ namespace currency
|
|||
const account_public_address &miner_address,
|
||||
const account_public_address &stakeholder_address,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
const blobdata& extra_nonce,
|
||||
size_t max_outs,
|
||||
bool pos,
|
||||
|
|
@ -130,7 +131,7 @@ namespace currency
|
|||
}
|
||||
|
||||
|
||||
return construct_miner_tx(height, median_size, already_generated_coins, current_block_size, fee, destinations, tx, extra_nonce, max_outs, pos, pe);
|
||||
return construct_miner_tx(height, median_size, already_generated_coins, current_block_size, fee, destinations, tx, tx_version, extra_nonce, max_outs, pos, pe);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool apply_unlock_time(const std::vector<tx_destination_entry>& destinations, transaction& tx)
|
||||
|
|
@ -159,6 +160,7 @@ namespace currency
|
|||
uint64_t fee,
|
||||
const std::vector<tx_destination_entry>& destinations,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
const blobdata& extra_nonce,
|
||||
size_t max_outs,
|
||||
bool pos,
|
||||
|
|
@ -208,7 +210,7 @@ namespace currency
|
|||
}
|
||||
|
||||
|
||||
tx.version = CURRENT_TRANSACTION_VERSION;
|
||||
tx.version = tx_version;
|
||||
if (!have_type_in_variant_container<etc_tx_details_unlock_time2>(tx.extra))
|
||||
{
|
||||
//if stake unlock time was not set, then we can use simple "whole transaction" lock scheme
|
||||
|
|
@ -1214,7 +1216,7 @@ namespace currency
|
|||
{
|
||||
//extra copy operation, but creating transaction is not sensitive to this
|
||||
finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = CURRENT_TRANSACTION_VERSION;
|
||||
ftp.tx_version = tx_version;
|
||||
ftp.sources = sources;
|
||||
ftp.prepared_destinations = destinations;
|
||||
ftp.extra = extra;
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ namespace currency
|
|||
const account_public_address &miner_address,
|
||||
const account_public_address &stakeholder_address,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
const blobdata& extra_nonce = blobdata(),
|
||||
size_t max_outs = CURRENCY_MINER_TX_MAX_OUTS,
|
||||
bool pos = false,
|
||||
|
|
@ -211,6 +212,7 @@ namespace currency
|
|||
uint64_t fee,
|
||||
const std::vector<tx_destination_entry>& destinations,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
const blobdata& extra_nonce = blobdata(),
|
||||
size_t max_outs = CURRENCY_MINER_TX_MAX_OUTS,
|
||||
bool pos = false,
|
||||
|
|
|
|||
|
|
@ -304,6 +304,7 @@ bool test_generator::construct_block(currency::block& blk,
|
|||
miner_acc.get_keys().account_address,
|
||||
miner_acc.get_keys().account_address,
|
||||
blk.miner_tx,
|
||||
get_tx_version(height, m_hardforks),
|
||||
blobdata(),
|
||||
test_generator::get_test_gentime_settings().miner_tx_max_outs,
|
||||
static_cast<bool>(coin_stake_sources.size()),
|
||||
|
|
@ -897,7 +898,7 @@ bool test_generator::construct_block(int64_t manual_timestamp_adjustment,
|
|||
{
|
||||
size_t current_block_size = txs_sizes + get_object_blobsize(blk.miner_tx);
|
||||
// TODO: This will work, until size of constructed block is less then CURRENCY_BLOCK_GRANTED_FULL_REWARD_ZONE
|
||||
if (!construct_miner_tx(height, misc_utils::median(block_sizes), already_generated_coins, current_block_size, 0, miner_acc.get_public_address(), miner_acc.get_public_address(), blk.miner_tx, blobdata(), 1))
|
||||
if (!construct_miner_tx(height, misc_utils::median(block_sizes), already_generated_coins, current_block_size, 0, miner_acc.get_public_address(), miner_acc.get_public_address(), blk.miner_tx, get_tx_version(height, m_hardforks), blobdata(), 1))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1462,7 +1463,7 @@ bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins
|
|||
out.target = txout_to_key(out_eph_public_key);
|
||||
tx.vout.push_back(out);
|
||||
|
||||
tx.version = CURRENT_TRANSACTION_VERSION;
|
||||
tx.version = TRANSACTION_VERSION_PRE_HF4;
|
||||
currency::set_tx_unlock_time(tx, height + CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -746,7 +746,7 @@ bool construct_broken_tx(const currency::account_keys& sender_account_keys, cons
|
|||
tx.signatures.clear();
|
||||
tx.extra = extra;
|
||||
|
||||
tx.version = CURRENT_TRANSACTION_VERSION;
|
||||
tx.version = TRANSACTION_VERSION_PRE_HF4;
|
||||
set_tx_unlock_time(tx, unlock_time);
|
||||
|
||||
currency::keypair txkey = currency::keypair::generate();
|
||||
|
|
@ -892,7 +892,7 @@ bool test_generator::construct_block_gentime_with_coinbase_cb(const currency::bl
|
|||
size_t height = get_block_height(prev_block) + 1;
|
||||
//size_t current_block_size = get_object_blobsize(miner_tx);
|
||||
|
||||
r = construct_miner_tx(height, misc_utils::median(block_sizes), already_generated_coins, 0 /* current_block_size !HACK! */, 0, acc.get_public_address(), acc.get_public_address(), miner_tx, currency::blobdata(), 1);
|
||||
r = construct_miner_tx(height, misc_utils::median(block_sizes), already_generated_coins, 0 /* current_block_size !HACK! */, 0, acc.get_public_address(), acc.get_public_address(), miner_tx, get_tx_version(height, m_hardforks), currency::blobdata(), 1);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_miner_tx failed");
|
||||
|
||||
if (!cb(miner_tx))
|
||||
|
|
|
|||
|
|
@ -628,6 +628,8 @@ gen_no_attchments_in_coinbase::gen_no_attchments_in_coinbase()
|
|||
|
||||
REGISTER_CALLBACK_METHOD(gen_no_attchments_in_coinbase, c1);
|
||||
REGISTER_CALLBACK_METHOD(gen_no_attchments_in_coinbase, init_config_set_cp);
|
||||
|
||||
m_hardforks.hard_fork_04_starts_after_height = UINT64_MAX;
|
||||
}
|
||||
|
||||
bool gen_no_attchments_in_coinbase::generate(std::vector<test_event_entry>& events) const
|
||||
|
|
|
|||
|
|
@ -1198,7 +1198,7 @@ bool multisig_and_unlock_time::generate(std::vector<test_event_entry>& events) c
|
|||
uint64_t unlock_time_2 = blk_0r.timestamp + DIFFICULTY_TOTAL_TARGET * 6 + CURRENCY_LOCKED_TX_ALLOWED_DELTA_SECONDS;
|
||||
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, unlock_time, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), unlock_time, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
CHECK_AND_ASSERT_MES(get_tx_max_unlock_time(tx_1) == unlock_time, false, "Unlock time was not correctly set");
|
||||
events.push_back(tx_1);
|
||||
|
|
@ -1448,7 +1448,7 @@ bool multisig_and_coinbase::generate(std::vector<test_event_entry>& events) cons
|
|||
r = fill_tx_sources_and_destinations(events, prev_block, miner_acc.get_keys(), ms_addr_list, blk_2_reward, TESTS_DEFAULT_FEE, 0, sources, destinations, false, false, 1);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction miner_tx = AUTO_VAL_INIT(miner_tx);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, miner_tx, height + CURRENCY_MINED_MONEY_UNLOCK_WINDOW, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, miner_tx, get_tx_version_from_events(events), height + CURRENCY_MINED_MONEY_UNLOCK_WINDOW, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
// replace vin with coinbase input
|
||||
|
|
@ -1628,7 +1628,7 @@ multisig_and_checkpoints::multisig_and_checkpoints()
|
|||
bool multisig_and_checkpoints::set_cp(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
|
||||
{
|
||||
currency::checkpoints checkpoints;
|
||||
checkpoints.add_checkpoint(15, "6f9194c144afd73077478e7f04e947c50160b5673558e6f696a4f662a3ca261e");
|
||||
checkpoints.add_checkpoint(15, "e2a1b0d51c4de81a79caafb28ba3c2f2ef3f53f7a728932b4d7e2a81a3fc2cc0");
|
||||
c.set_checkpoints(std::move(checkpoints));
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ bool construct_homemade_pos_miner_tx(size_t height, size_t median_size, const bo
|
|||
boost::value_initialized<transaction> new_tx;
|
||||
tx = new_tx;
|
||||
|
||||
tx.version = CURRENT_TRANSACTION_VERSION;
|
||||
tx.version = TRANSACTION_VERSION_PRE_HF4;
|
||||
set_tx_unlock_time(tx, height + CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
// calculate block reward
|
||||
|
|
|
|||
|
|
@ -40,17 +40,17 @@ bool test_transaction_generation_and_ring_signature()
|
|||
account_base rv_acc2;
|
||||
rv_acc2.generate();
|
||||
transaction tx_mine_1;
|
||||
construct_miner_tx(0, 0, 0, 10, 0, miner_acc1.get_keys().account_address, miner_acc1.get_keys().account_address, tx_mine_1);
|
||||
construct_miner_tx(0, 0, 0, 10, 0, miner_acc1.get_keys().account_address, miner_acc1.get_keys().account_address, tx_mine_1, TRANSACTION_VERSION_PRE_HF4);
|
||||
transaction tx_mine_2;
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc2.get_keys().account_address, miner_acc2.get_keys().account_address, tx_mine_2);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc2.get_keys().account_address, miner_acc2.get_keys().account_address, tx_mine_2, TRANSACTION_VERSION_PRE_HF4);
|
||||
transaction tx_mine_3;
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc3.get_keys().account_address, miner_acc3.get_keys().account_address, tx_mine_3);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc3.get_keys().account_address, miner_acc3.get_keys().account_address, tx_mine_3, TRANSACTION_VERSION_PRE_HF4);
|
||||
transaction tx_mine_4;
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc4.get_keys().account_address, miner_acc4.get_keys().account_address, tx_mine_4);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc4.get_keys().account_address, miner_acc4.get_keys().account_address, tx_mine_4, TRANSACTION_VERSION_PRE_HF4);
|
||||
transaction tx_mine_5;
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc5.get_keys().account_address, miner_acc5.get_keys().account_address, tx_mine_5);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc5.get_keys().account_address, miner_acc5.get_keys().account_address, tx_mine_5, TRANSACTION_VERSION_PRE_HF4);
|
||||
transaction tx_mine_6;
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc6.get_keys().account_address, miner_acc6.get_keys().account_address, tx_mine_6);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc6.get_keys().account_address, miner_acc6.get_keys().account_address, tx_mine_6, TRANSACTION_VERSION_PRE_HF4);
|
||||
|
||||
//fill inputs entry
|
||||
typedef tx_source_entry::output_entry tx_output_entry;
|
||||
|
|
@ -135,7 +135,7 @@ bool test_block_creation()
|
|||
bool r = get_account_address_from_str(adr, "ZxDLGBGXbjo5w51tJkvxEPHFRr7Xft4hf33N8EkJPndoGCqocQF1mzpZqYwXByx5gMbfQuPAAB9vj79EFR6Jwkgu1o3aMQPwJ");
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to import");
|
||||
block b;
|
||||
r = construct_miner_tx(90, epee::misc_utils::median(szs), 3553616528562147, 33094, 10000000, adr, adr, b.miner_tx);
|
||||
r = construct_miner_tx(90, epee::misc_utils::median(szs), 3553616528562147, 33094, 10000000, adr, adr, b.miner_tx, TRANSACTION_VERSION_PRE_HF4);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
struct tx_builder
|
||||
{
|
||||
void step1_init(size_t version = CURRENT_TRANSACTION_VERSION, uint64_t unlock_time = 0)
|
||||
void step1_init(size_t version = TRANSACTION_VERSION_PRE_HF4, uint64_t unlock_time = 0)
|
||||
{
|
||||
m_tx = AUTO_VAL_INIT(m_tx);
|
||||
m_in_contexts.clear();
|
||||
|
|
@ -126,7 +126,7 @@ struct tx_builder
|
|||
fill_tx_sources_and_destinations(events, blk_head, from, to, amount, TESTS_DEFAULT_FEE, 0, sources, destinations, true, check_for_unlock_time);
|
||||
|
||||
tx_builder builder;
|
||||
builder.step1_init(CURRENT_TRANSACTION_VERSION, unlock_time);
|
||||
builder.step1_init(TRANSACTION_VERSION_PRE_HF4, unlock_time);
|
||||
builder.step2_fill_inputs(from.get_keys(), sources);
|
||||
builder.step3_fill_outputs(destinations);
|
||||
builder.step4_calc_hash();
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ bool create_block_template_manually(const currency::block& prev_block, boost::mu
|
|||
// make things really simple by assuming block size is less than CURRENCY_BLOCK_GRANTED_FULL_REWARD_ZONE
|
||||
size_t median_size = 0;
|
||||
|
||||
bool r = construct_miner_tx(get_block_height(prev_block) + 1, median_size, already_generated_coins, txs_size, fee, miner_addr, miner_addr, result.miner_tx);
|
||||
bool r = construct_miner_tx(get_block_height(prev_block) + 1, median_size, already_generated_coins, txs_size, fee, miner_addr, miner_addr, result.miner_tx, TRANSACTION_VERSION_PRE_HF4);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_miner_tx failed");
|
||||
|
||||
size_t coinbase_size = get_object_blobsize(result.miner_tx);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
{
|
||||
m_miners[i].generate();
|
||||
|
||||
if (!construct_miner_tx(0, 0, 0, 2, 0, m_miners[i].get_keys().m_account_address, m_miner_txs[i]))
|
||||
if (!construct_miner_tx(0, 0, 0, 2, 0, m_miners[i].get_keys().m_account_address, m_miner_txs[i], TRANSACTION_VERSION_PRE_HF4))
|
||||
return false;
|
||||
|
||||
txout_to_key tx_out = boost::get<txout_to_key>(m_miner_txs[i].vout[0].target);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
|
||||
m_bob.generate();
|
||||
|
||||
if (!construct_miner_tx(0, 0, 0, 2, 0, m_bob.get_keys().account_address, m_bob.get_keys().account_address, m_tx, blobdata(), CURRENCY_MINER_TX_MAX_OUTS))
|
||||
if (!construct_miner_tx(0, 0, 0, 2, 0, m_bob.get_keys().account_address, m_bob.get_keys().account_address, m_tx, TRANSACTION_VERSION_PRE_HF4, blobdata(), CURRENCY_MINER_TX_MAX_OUTS))
|
||||
return false;
|
||||
|
||||
m_tx_pub_key = get_tx_pub_key_from_extra(m_tx);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ TEST(parse_and_validate_tx_extra, is_correct_parse_and_validate_tx_extra)
|
|||
currency::account_base acc;
|
||||
acc.generate();
|
||||
currency::blobdata b = "dsdsdfsdfsf";
|
||||
bool r = currency::construct_miner_tx(0, 0, 10000000000000, 1000, TESTS_DEFAULT_FEE, acc.get_keys().account_address, acc.get_keys().account_address, tx, b, 1);
|
||||
bool r = currency::construct_miner_tx(0, 0, 10000000000000, 1000, TESTS_DEFAULT_FEE, acc.get_keys().account_address, acc.get_keys().account_address, tx, TRANSACTION_VERSION_PRE_HF4, b, 1);
|
||||
ASSERT_TRUE(r);
|
||||
crypto::public_key tx_pub_key;
|
||||
r = currency::parse_and_validate_tx_extra(tx, tx_pub_key);
|
||||
|
|
@ -26,7 +26,7 @@ TEST(parse_and_validate_tx_extra, is_correct_extranonce_too_big)
|
|||
currency::account_base acc;
|
||||
acc.generate();
|
||||
currency::blobdata b(260, 0);
|
||||
bool r = currency::construct_miner_tx(0, 0, 10000000000000, 1000, TESTS_DEFAULT_FEE, acc.get_keys().account_address, acc.get_keys().account_address, tx, b, 1);
|
||||
bool r = currency::construct_miner_tx(0, 0, 10000000000000, 1000, TESTS_DEFAULT_FEE, acc.get_keys().account_address, acc.get_keys().account_address, tx, TRANSACTION_VERSION_PRE_HF4, b, 1);
|
||||
ASSERT_FALSE(r);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue