forked from lthn/blockchain
Merge branch 'txhfid' into develop
This commit is contained in:
commit
a0ddaea1a3
42 changed files with 564 additions and 225 deletions
|
|
@ -414,7 +414,7 @@ bool generate_genesis(const std::string& path_config, uint64_t premine_split_amo
|
|||
std::cout << ENDL << "PROOF PHRASE: " << gcp.proof_string << ENDL;
|
||||
uint64_t block_reward_without_fee = 0;
|
||||
uint64_t block_reward = 0;
|
||||
construct_miner_tx(0, 0, 0, 0, 0, dummy_address, dummy_address, bl.miner_tx, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, gcp.proof_string, CURRENCY_MINER_TX_MAX_OUTS, false, pos_entry(), nullptr, nullptr, destinations);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, dummy_address, dummy_address, bl.miner_tx, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0, gcp.proof_string, CURRENCY_MINER_TX_MAX_OUTS, false, pos_entry(), nullptr, nullptr, destinations);
|
||||
currency::blobdata txb = tx_to_blob(bl.miner_tx);
|
||||
|
||||
//self validate block
|
||||
|
|
|
|||
|
|
@ -1639,6 +1639,9 @@ bool blockchain_storage::create_block_template(const create_block_template_param
|
|||
|
||||
resp.txs_fee = fee;
|
||||
|
||||
size_t tx_hardfork_id = 0;
|
||||
size_t tx_version = get_tx_version_and_hardfork_id(height, m_core_runtime_config.hard_forks, tx_hardfork_id);
|
||||
|
||||
/*
|
||||
instead of complicated two-phase template construction and adjustment of cumulative size with block reward we
|
||||
use CURRENCY_COINBASE_BLOB_RESERVED_SIZE as penalty-free coinbase transaction reservation.
|
||||
|
|
@ -1651,7 +1654,8 @@ bool blockchain_storage::create_block_template(const create_block_template_param
|
|||
b.miner_tx,
|
||||
resp.block_reward_without_fee,
|
||||
resp.block_reward,
|
||||
get_tx_version(height, m_core_runtime_config.hard_forks),
|
||||
tx_version,
|
||||
tx_hardfork_id,
|
||||
ex_nonce,
|
||||
CURRENCY_MINER_TX_MAX_OUTS,
|
||||
pos,
|
||||
|
|
@ -6130,6 +6134,7 @@ struct visitor_proxy : public boost::static_visitor<const x_type*>
|
|||
|
||||
bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transaction& tx, const crypto::hash& tx_id, uint64_t block_height) const
|
||||
{
|
||||
size_t most_recent_hardfork_id_for_height = m_core_runtime_config.hard_forks.get_the_most_recent_hardfork_id_for_height(block_height);
|
||||
bool var_is_after_hardfork_1_zone = m_core_runtime_config.is_hardfork_active_for_height(1, block_height);
|
||||
bool var_is_after_hardfork_2_zone = m_core_runtime_config.is_hardfork_active_for_height(2, block_height);
|
||||
bool var_is_after_hardfork_3_zone = m_core_runtime_config.is_hardfork_active_for_height(3, block_height);
|
||||
|
|
@ -6268,7 +6273,9 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti
|
|||
|
||||
if (var_is_after_hardfork_5_zone)
|
||||
{
|
||||
// additional checks here
|
||||
CHECK_AND_ASSERT_MES(tx.version >= TRANSACTION_VERSION_POST_HF5, false, "HF5: tx with version " << tx.version << " is not allowed");
|
||||
// starting from HF5 each tx must have hardfork_id corresponding to the current active hardfork
|
||||
CHECK_AND_ASSERT_MES(tx.hardfork_id == most_recent_hardfork_id_for_height, false, "tx's hardfork_id is " << (int)tx.hardfork_id << ", but the current hardfork is " << most_recent_hardfork_id_for_height << ", rejected");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1032,6 +1032,7 @@ namespace currency
|
|||
{
|
||||
public:
|
||||
uint64_t version = 0;
|
||||
uint8_t hardfork_id = 0;
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<tx_out_v> vout;
|
||||
|
|
@ -1044,6 +1045,8 @@ namespace currency
|
|||
FIELD(vin)
|
||||
FIELD(extra)
|
||||
FIELD(vout)
|
||||
if(version < TRANSACTION_VERSION_POST_HF5) return true;
|
||||
FIELD(hardfork_id)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,11 @@
|
|||
#define CURRENCY_PUBLIC_AUDITABLE_ADDRESS_BASE58_PREFIX 0x98c8 // auditable addresses start with 'aZx'
|
||||
#define CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX 0x8a49 // auditable integrated addresses start with 'aiZX'
|
||||
#define CURRENCY_MINED_MONEY_UNLOCK_WINDOW 10
|
||||
#define CURRENT_TRANSACTION_VERSION 2
|
||||
#define CURRENT_TRANSACTION_VERSION 3
|
||||
#define TRANSACTION_VERSION_INITAL 0
|
||||
#define TRANSACTION_VERSION_PRE_HF4 1
|
||||
#define TRANSACTION_VERSION_POST_HF4 2
|
||||
#define TRANSACTION_VERSION_POST_HF4 2
|
||||
#define TRANSACTION_VERSION_POST_HF5 3
|
||||
#define HF1_BLOCK_MAJOR_VERSION 1
|
||||
#define HF3_BLOCK_MAJOR_VERSION 2
|
||||
#define HF3_BLOCK_MINOR_VERSION 0
|
||||
|
|
|
|||
|
|
@ -393,6 +393,7 @@ namespace currency
|
|||
uint64_t& block_reward_without_fee,
|
||||
uint64_t& block_reward,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hadrfork_id,
|
||||
const blobdata& extra_nonce /* = blobdata() */,
|
||||
size_t max_outs /* = CURRENCY_MINER_TX_MAX_OUTS */,
|
||||
bool pos /* = false */,
|
||||
|
|
@ -476,6 +477,8 @@ namespace currency
|
|||
CHECK_AND_ASSERT_MES(destinations.size() <= CURRENCY_TX_MAX_ALLOWED_OUTS || height == 0, false, "Too many outs (" << destinations.size() << ")! Miner tx can't be constructed.");
|
||||
// tx is not cleared intentionally to allow passing additional args in the extra/attachments
|
||||
tx.version = tx_version;
|
||||
if (tx.version >= TRANSACTION_VERSION_POST_HF5)
|
||||
tx.hardfork_id = tx_hadrfork_id;
|
||||
|
||||
tx_generation_context tx_gen_context{};
|
||||
tx_gen_context.set_tx_key(tx_one_time_key_to_use ? *tx_one_time_key_to_use : keypair::generate());
|
||||
|
|
@ -1439,12 +1442,13 @@ namespace currency
|
|||
const std::vector<attachment_v>& attachments,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
uint64_t unlock_time,
|
||||
uint8_t tx_outs_attr,
|
||||
bool shuffle)
|
||||
{
|
||||
crypto::secret_key one_time_secret_key = AUTO_VAL_INIT(one_time_secret_key);
|
||||
return construct_tx(sender_account_keys, sources, destinations, std::vector<extra_v>(), attachments, tx, tx_version, one_time_secret_key, unlock_time, tx_outs_attr, shuffle);
|
||||
crypto::secret_key one_time_secret_key{};
|
||||
return construct_tx(sender_account_keys, sources, destinations, std::vector<extra_v>(), attachments, tx, tx_version, tx_hardfork_id, one_time_secret_key, unlock_time, tx_outs_attr, shuffle);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
|
@ -1964,6 +1968,7 @@ namespace currency
|
|||
const std::vector<attachment_v>& attachments,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
crypto::secret_key& one_time_secret_key,
|
||||
uint64_t unlock_time,
|
||||
uint8_t tx_outs_attr,
|
||||
|
|
@ -1976,7 +1981,7 @@ namespace currency
|
|||
//in case if there is no real targets we use sender credentials to encrypt attachments
|
||||
account_public_address crypt_destination_addr = get_crypt_address_from_destinations(sender_account_keys, destinations);
|
||||
|
||||
return construct_tx(sender_account_keys, sources, destinations, extra, attachments, tx, tx_version, one_time_secret_key, unlock_time,
|
||||
return construct_tx(sender_account_keys, sources, destinations, extra, attachments, tx, tx_version, tx_hardfork_id, one_time_secret_key, unlock_time,
|
||||
crypt_destination_addr,
|
||||
0,
|
||||
tx_outs_attr,
|
||||
|
|
@ -1990,6 +1995,7 @@ namespace currency
|
|||
const std::vector<attachment_v>& attachments,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
crypto::secret_key& one_time_secret_key,
|
||||
uint64_t unlock_time,
|
||||
const account_public_address& crypt_destination_addr,
|
||||
|
|
@ -1999,8 +2005,9 @@ namespace currency
|
|||
uint64_t flags)
|
||||
{
|
||||
//extra copy operation, but creating transaction is not sensitive to this
|
||||
finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
finalize_tx_param ftp{};
|
||||
ftp.tx_version = tx_version;
|
||||
ftp.tx_hardfork_id = tx_hardfork_id;
|
||||
ftp.sources = sources;
|
||||
ftp.prepared_destinations = destinations;
|
||||
ftp.extra = extra;
|
||||
|
|
@ -2012,7 +2019,7 @@ namespace currency
|
|||
ftp.shuffle = shuffle;
|
||||
ftp.flags = flags;
|
||||
|
||||
finalized_tx ft = AUTO_VAL_INIT(ft);
|
||||
finalized_tx ft{};
|
||||
ft.tx = tx;
|
||||
ft.one_time_key = one_time_secret_key;
|
||||
bool r = construct_tx(sender_account_keys, ftp, ft);
|
||||
|
|
@ -2402,6 +2409,9 @@ namespace currency
|
|||
tx.signatures.clear();
|
||||
|
||||
tx.version = ftp.tx_version;
|
||||
if (tx.version >= TRANSACTION_VERSION_POST_HF5)
|
||||
tx.hardfork_id = ftp.tx_hardfork_id;
|
||||
|
||||
if (unlock_time != 0)
|
||||
set_tx_unlock_time(tx, unlock_time);
|
||||
|
||||
|
|
@ -2819,15 +2829,26 @@ namespace currency
|
|||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
uint64_t get_tx_version(uint64_t tx_expected_block_height, const hard_forks_descriptor& hfd)
|
||||
uint64_t get_tx_version_and_hardfork_id(uint64_t tx_expected_block_height, const hard_forks_descriptor& hfd, size_t& tx_hardfork_id)
|
||||
{
|
||||
tx_hardfork_id = hfd.get_the_most_recent_hardfork_id_for_height(tx_expected_block_height);
|
||||
if (!hfd.is_hardfork_active_for_height(ZANO_HARDFORK_04_ZARCANUM, tx_expected_block_height))
|
||||
{
|
||||
return TRANSACTION_VERSION_PRE_HF4;
|
||||
}
|
||||
if (!hfd.is_hardfork_active_for_height(ZANO_HARDFORK_05, tx_expected_block_height))
|
||||
{
|
||||
return TRANSACTION_VERSION_POST_HF4;
|
||||
}
|
||||
return CURRENT_TRANSACTION_VERSION;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
uint64_t get_tx_version(uint64_t tx_expected_block_height, const hard_forks_descriptor& hfd)
|
||||
{
|
||||
[[maybe_unused]] size_t tx_hardfork_id{};
|
||||
return get_tx_version_and_hardfork_id(tx_expected_block_height, hfd, tx_hardfork_id);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
// TODO @#@# this function is obsolete and needs to be re-written
|
||||
uint64_t get_reward_from_miner_tx(const transaction& tx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ namespace currency
|
|||
uint64_t expiration_time;
|
||||
crypto::public_key spend_pub_key; // only for validations
|
||||
uint64_t tx_version;
|
||||
size_t tx_hardfork_id = 0;
|
||||
uint64_t mode_separate_fee = 0;
|
||||
|
||||
epee::misc_utils::events_dispatcher* pevents_dispatcher = nullptr;
|
||||
|
|
@ -187,6 +188,7 @@ namespace currency
|
|||
FIELD(expiration_time)
|
||||
FIELD(spend_pub_key)
|
||||
FIELD(tx_version)
|
||||
FIELD(tx_hardfork_id)
|
||||
FIELD(mode_separate_fee)
|
||||
if (flags & TX_FLAG_SIGNATURE_MODE_SEPARATE)
|
||||
{
|
||||
|
|
@ -295,6 +297,7 @@ namespace currency
|
|||
uint64_t& block_reward_without_fee,
|
||||
uint64_t& block_reward,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hadrfork_id,
|
||||
const blobdata& extra_nonce = blobdata(),
|
||||
size_t max_outs = CURRENCY_MINER_TX_MAX_OUTS,
|
||||
bool pos = false,
|
||||
|
|
@ -317,9 +320,11 @@ namespace currency
|
|||
const std::vector<attachment_v>& attachments,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
uint64_t unlock_time,
|
||||
uint8_t tx_outs_attr = CURRENCY_TO_KEY_OUT_RELAXED,
|
||||
bool shuffle = true);
|
||||
|
||||
bool construct_tx(const account_keys& sender_account_keys,
|
||||
const std::vector<tx_source_entry>& sources,
|
||||
const std::vector<tx_destination_entry>& destinations,
|
||||
|
|
@ -327,6 +332,7 @@ namespace currency
|
|||
const std::vector<attachment_v>& attachments,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
crypto::secret_key& one_time_secret_key,
|
||||
uint64_t unlock_time,
|
||||
uint8_t tx_outs_attr = CURRENCY_TO_KEY_OUT_RELAXED,
|
||||
|
|
@ -340,6 +346,7 @@ namespace currency
|
|||
const std::vector<attachment_v>& attachments,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
crypto::secret_key& one_time_secret_key,
|
||||
uint64_t unlock_time,
|
||||
const account_public_address& crypt_account,
|
||||
|
|
@ -348,6 +355,7 @@ namespace currency
|
|||
bool shuffle = true,
|
||||
uint64_t flags = 0);
|
||||
|
||||
uint64_t get_tx_version_and_hardfork_id(uint64_t tx_expected_block_height, const hard_forks_descriptor& hfd, size_t& tx_hardfork_id); // returns tx version and tx hardfork id based on the height of the block where the transaction is expected to be
|
||||
uint64_t get_tx_version(uint64_t tx_expected_block_height, const hard_forks_descriptor& hfd); // returns tx version based on the height of the block where the transaction is expected to be
|
||||
bool construct_tx(const account_keys& sender_account_keys, const finalize_tx_param& param, finalized_tx& result);
|
||||
bool get_or_calculate_asset_id(const asset_descriptor_operation& ado, crypto::point_t* p_result_point, crypto::public_key* p_result_pub_key);
|
||||
|
|
|
|||
|
|
@ -1162,7 +1162,7 @@ void wallet2::accept_proposal(const crypto::hash& contract_id, uint64_t b_accept
|
|||
|
||||
//build transaction
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
prepare_transaction(construct_param, ftp, msc);
|
||||
mark_transfers_as_spent(ftp.selected_transfers, std::string("contract <") + epee::string_tools::pod_to_hex(contract_id) + "> has been accepted with tx <" + epee::string_tools::pod_to_hex(get_transaction_hash(tx)) + ">");
|
||||
|
||||
|
|
@ -1182,10 +1182,10 @@ void wallet2::accept_proposal(const crypto::hash& contract_id, uint64_t b_accept
|
|||
*p_acceptance_tx = tx;
|
||||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
uint64_t wallet2::get_current_tx_version()
|
||||
uint64_t wallet2::get_current_tx_version_and_hardfork_id(size_t& tx_hardfork_id)
|
||||
{
|
||||
uint64_t tx_expected_block_height = get_top_block_height() + 1;
|
||||
return currency::get_tx_version(tx_expected_block_height, this->m_core_runtime_config.hard_forks);
|
||||
return currency::get_tx_version_and_hardfork_id(tx_expected_block_height, this->m_core_runtime_config.hard_forks, tx_hardfork_id);
|
||||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
void wallet2::finish_contract(const crypto::hash& contract_id, const std::string& release_type, currency::transaction* p_release_tx /* = nullptr */)
|
||||
|
|
@ -1299,7 +1299,7 @@ void wallet2::request_cancel_contract(const crypto::hash& contract_id, uint64_t
|
|||
construct_param.split_strategy_id = get_current_split_strategy();
|
||||
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
prepare_transaction(construct_param, ftp);
|
||||
currency::transaction tx = AUTO_VAL_INIT(tx);
|
||||
crypto::secret_key sk = AUTO_VAL_INIT(sk);
|
||||
|
|
@ -2399,7 +2399,7 @@ bool wallet2::sweep_bare_unspent_outputs(const currency::account_public_address&
|
|||
currency::finalized_tx ftx{};
|
||||
currency::finalize_tx_param ftp{};
|
||||
ftp.pevents_dispatcher = &m_debug_events_dispatcher;
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
|
||||
if (!prepare_tx_sources(decoys_count, /*use_all_decoys_if_found_less_than_required*/ true, ftp.sources, group.tids))
|
||||
{
|
||||
|
|
@ -5930,7 +5930,7 @@ void wallet2::build_escrow_release_templates(crypto::hash multisig_id,
|
|||
construct_params.extra.push_back(tsa);
|
||||
{
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
prepare_transaction(construct_params, ftp);
|
||||
crypto::secret_key sk = AUTO_VAL_INIT(sk);
|
||||
finalize_transaction(ftp, tx_release_template, sk, false);
|
||||
|
|
@ -5947,7 +5947,7 @@ void wallet2::build_escrow_release_templates(crypto::hash multisig_id,
|
|||
construct_params.extra.push_back(tsa);
|
||||
{
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
prepare_transaction(construct_params, ftp);
|
||||
crypto::secret_key sk = AUTO_VAL_INIT(sk);
|
||||
finalize_transaction(ftp, tx_burn_template, sk, false);
|
||||
|
|
@ -5968,7 +5968,7 @@ void wallet2::build_escrow_cancel_template(crypto::hash multisig_id,
|
|||
|
||||
construct_tx_param construct_params = AUTO_VAL_INIT(construct_params);
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
construct_params.fee = it->second.amount() - (ecrow_details.amount_a_pledge + ecrow_details.amount_to_pay + ecrow_details.amount_b_pledge);
|
||||
construct_params.multisig_id = multisig_id;
|
||||
construct_params.split_strategy_id = get_current_split_strategy();
|
||||
|
|
@ -6051,7 +6051,7 @@ void wallet2::build_escrow_template(const bc_services::contract_private_details&
|
|||
}
|
||||
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
prepare_transaction(ctp, ftp);
|
||||
|
||||
selected_transfers = ftp.selected_transfers;
|
||||
|
|
@ -6187,7 +6187,7 @@ void wallet2::send_escrow_proposal(const bc_services::contract_private_details&
|
|||
ctp.unlock_time = unlock_time;
|
||||
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
try
|
||||
{
|
||||
prepare_transaction(ctp, ftp);
|
||||
|
|
@ -6361,7 +6361,7 @@ bool wallet2::build_ionic_swap_template(const wallet_public::ionic_swap_proposal
|
|||
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.mode_separate_fee = ctp.fee;
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
prepare_transaction(ctp, ftp);
|
||||
|
||||
selected_transfers = ftp.selected_transfers;
|
||||
|
|
@ -6590,7 +6590,7 @@ bool wallet2::accept_ionic_swap_proposal(const wallet_public::ionic_swap_proposa
|
|||
|
||||
//build transaction
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
ftp.gen_context = ionic_context.gen_context;
|
||||
prepare_transaction(construct_param, ftp, msc);
|
||||
|
||||
|
|
@ -8159,7 +8159,7 @@ void wallet2::transfer(construct_tx_param& ctp,
|
|||
TIME_MEASURE_START(prepare_transaction_time);
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.pevents_dispatcher = &m_debug_events_dispatcher;
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
if (!prepare_transaction(ctp, ftp))
|
||||
{
|
||||
result.was_not_prepared = true;
|
||||
|
|
@ -8286,7 +8286,7 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public
|
|||
}
|
||||
|
||||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
ftp.tx_version = get_current_tx_version_and_hardfork_id(ftp.tx_hardfork_id);
|
||||
bool is_hf4 = this->is_in_hardfork_zone(ZANO_HARDFORK_04_ZARCANUM);
|
||||
if (!payment_id.empty())
|
||||
set_payment_id_to_tx(ftp.attachments, payment_id, is_hf4);
|
||||
|
|
|
|||
|
|
@ -857,7 +857,7 @@ private:
|
|||
bool handle_cancel_proposal(wallet_public::wallet_transfer_info& wti, const bc_services::escrow_cancel_templates_body& ectb, const std::vector<currency::payload_items_v>& decrypted_attach);
|
||||
bool handle_expiration_list(uint64_t tx_expiration_ts_median);
|
||||
void handle_contract_expirations(uint64_t tx_expiration_ts_median);
|
||||
uint64_t get_current_tx_version();
|
||||
uint64_t get_current_tx_version_and_hardfork_id(size_t& tx_hardfork_id);
|
||||
void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const wallet_public::wallet_transfer_info& wti) const;
|
||||
void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const std::string& reason = "internal intention") const;
|
||||
void load_votes_config();
|
||||
|
|
|
|||
|
|
@ -975,7 +975,9 @@ bool gen_alias_too_much_reward::generate(std::vector<test_event_entry>& events)
|
|||
d.flags |= tx_destination_entry_flags::tdef_explicit_native_asset_id | tx_destination_entry_flags::tdef_zero_amount_blinding_mask;
|
||||
transaction tx_0{};
|
||||
crypto::secret_key sk{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<currency::extra_v>({ ai }), empty_attachment, tx_0, get_tx_version_from_events(events), sk, 0);
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<currency::extra_v>({ ai }), empty_attachment, tx_0, tx_version, tx_hardfork_id, sk, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
if (tx_0.version <= TRANSACTION_VERSION_PRE_HF4)
|
||||
|
|
@ -1166,8 +1168,9 @@ bool gen_alias_too_small_reward::make_tx_reg_alias(std::vector<test_event_entry>
|
|||
destinations.push_back(tx_destination_entry(sources_amount - (alias_reward + TESTS_DEFAULT_FEE), miner_acc.get_public_address())); // change
|
||||
|
||||
crypto::secret_key stub = AUTO_VAL_INIT(stub);
|
||||
uint64_t tx_version = get_tx_version(get_block_height(prev_block), m_hardforks);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, extra, empty_attachment, tx, tx_version, stub, uint64_t(0));
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(get_block_height(prev_block), m_hardforks, tx_hardfork_id);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, extra, empty_attachment, tx, tx_version, tx_hardfork_id, stub, uint64_t(0));
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
PRINT_EVENT_N_TEXT(events, "make_tx_reg_alias -> construct_tx()");
|
||||
events.push_back(tx);
|
||||
|
|
@ -1382,8 +1385,9 @@ bool gen_alias_too_many_regs_in_block_template::generate(std::vector<test_event_
|
|||
destinations.push_back(tx_destination_entry(sources_amount - total_alias_cost, preminer_acc.get_public_address())); // return the change in order to keep median_fee low
|
||||
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
uint64_t tx_version = get_tx_version(get_block_height(blk_0r), m_hardforks);
|
||||
r = construct_tx(preminer_acc.get_keys(), sources, destinations, empty_attachment, tx_1, tx_version, 0);
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_0r), m_hardforks, tx_hardfork_id);
|
||||
r = construct_tx(preminer_acc.get_keys(), sources, destinations, empty_attachment, tx_1, tx_version, tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
events.push_back(tx_1);
|
||||
|
|
@ -1494,9 +1498,10 @@ bool gen_alias_update_for_free::generate(std::vector<test_event_entry>& events)
|
|||
}
|
||||
|
||||
transaction tx{};
|
||||
uint64_t tx_version = currency::get_tx_version(get_block_height(blk_0r) + 1, generator.get_hardforks());
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = currency::get_tx_version_and_hardfork_id(get_block_height(blk_0r) + 1, generator.get_hardforks(), tx_hardfork_id);
|
||||
crypto::secret_key sk{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<extra_v>({ ai }), empty_attachment, tx, tx_version, sk, 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<extra_v>({ ai }), empty_attachment, tx, tx_version, tx_hardfork_id, sk, 0);
|
||||
|
||||
/*tx_builder tb;
|
||||
tb.step1_init();
|
||||
|
|
|
|||
|
|
@ -321,10 +321,9 @@ bool gen_block_miner_tx_has_2_in::generate(std::vector<test_event_entry>& events
|
|||
destinations.push_back(de);
|
||||
|
||||
transaction tmp_tx;
|
||||
std::vector<currency::attachment_v> attachments;
|
||||
|
||||
uint64_t tx_version = get_tx_version(get_block_height(blk_0r), m_hardforks);
|
||||
if (!construct_tx(miner_account.get_keys(), sources, destinations, attachments, tmp_tx, tx_version, 0))
|
||||
if (!construct_tx(miner_account.get_keys(), sources, destinations, empty_extra, empty_attachment, tmp_tx, tx_version))
|
||||
return false;
|
||||
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
|
||||
|
|
@ -369,9 +368,8 @@ bool gen_block_miner_tx_with_txin_to_key::generate(std::vector<test_event_entry>
|
|||
destinations.push_back(de);
|
||||
|
||||
transaction tmp_tx = AUTO_VAL_INIT(tmp_tx);
|
||||
std::vector<currency::attachment_v> attachments;
|
||||
uint64_t tx_version = get_tx_version(get_block_height(blk_1r), m_hardforks);
|
||||
if (!construct_tx(miner_account.get_keys(), sources, destinations, attachments, tmp_tx, tx_version, 0))
|
||||
if (!construct_tx(miner_account.get_keys(), sources, destinations, empty_extra, empty_attachment, tmp_tx, tx_version))
|
||||
return false;
|
||||
|
||||
MAKE_MINER_TX_MANUALLY(miner_tx, blk_1);
|
||||
|
|
|
|||
|
|
@ -532,9 +532,10 @@ bool alt_blocks_validation_and_same_new_amount_in_two_txs::generate(std::vector<
|
|||
std::vector<tx_destination_entry> destinations;
|
||||
destinations.push_back(tx_destination_entry(new_amount, miner_acc.get_public_address()));
|
||||
destinations.push_back(tx_destination_entry(TESTS_DEFAULT_FEE, miner_acc.get_public_address())); //just to make two outputs (to please HF4 rules)
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
uint64_t tx_version = get_tx_version(get_block_height(blk_3), m_hardforks);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, tx_version, 0);
|
||||
transaction tx_1{};
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_3), m_hardforks, tx_hardfork_id);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, tx_version, tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
ADD_CUSTOM_EVENT(events, tx_1);
|
||||
|
||||
|
|
@ -544,8 +545,8 @@ bool alt_blocks_validation_and_same_new_amount_in_two_txs::generate(std::vector<
|
|||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources failed");
|
||||
transaction tx_2 = AUTO_VAL_INIT(tx_2);
|
||||
// use the same destinations
|
||||
tx_version = get_tx_version(get_block_height(blk_3), m_hardforks);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_2, tx_version, 0);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_3), m_hardforks, tx_hardfork_id);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_2, tx_version, tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
ADD_CUSTOM_EVENT(events, tx_2);
|
||||
|
||||
|
|
@ -913,16 +914,10 @@ bool alt_chain_and_block_tx_fee_median::generate(
|
|||
|
||||
CHECK_AND_ASSERT_MES(success, false, "fail to fill sources, destinations");
|
||||
|
||||
tx_version = get_tx_version(get_block_height(blk_1r),
|
||||
m_hardforks);
|
||||
size_t tx_hardfork_id{};
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_1r), m_hardforks, tx_hardfork_id);
|
||||
|
||||
success = construct_tx(miner.get_keys(),
|
||||
sources,
|
||||
destinations,
|
||||
empty_attachment,
|
||||
tx_0,
|
||||
tx_version,
|
||||
0);
|
||||
success = construct_tx(miner.get_keys(), sources, destinations, empty_attachment, tx_0, tx_version, tx_hardfork_id, 0);
|
||||
|
||||
CHECK_AND_ASSERT_MES(success, false, "fail to construct tx_0");
|
||||
|
||||
|
|
@ -934,8 +929,7 @@ bool alt_chain_and_block_tx_fee_median::generate(
|
|||
|
||||
// Transaction tx_1 is constructed and placed in block blk_2a.
|
||||
|
||||
tx_version = get_tx_version(get_block_height(blk_1r),
|
||||
m_hardforks);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_1r), m_hardforks, tx_hardfork_id);
|
||||
|
||||
success = fill_tx_sources_and_destinations(
|
||||
events,
|
||||
|
|
@ -950,13 +944,7 @@ bool alt_chain_and_block_tx_fee_median::generate(
|
|||
|
||||
CHECK_AND_ASSERT_MES(success, false, "fail to fill sources, destinations");
|
||||
|
||||
success = construct_tx(miner.get_keys(),
|
||||
sources,
|
||||
destinations,
|
||||
empty_attachment,
|
||||
tx_1,
|
||||
tx_version,
|
||||
0);
|
||||
success = construct_tx(miner.get_keys(), sources, destinations, empty_attachment, tx_1, tx_version, tx_hardfork_id, 0);
|
||||
|
||||
CHECK_AND_ASSERT_MES(success, false, "fail to construct tx_1");
|
||||
|
||||
|
|
|
|||
|
|
@ -299,6 +299,8 @@ bool test_generator::construct_block(currency::block& blk,
|
|||
tx_generation_context miner_tx_tgc{};
|
||||
uint64_t block_reward_without_fee = 0;
|
||||
uint64_t block_reward = 0;
|
||||
size_t tx_hardfork_id = 0;
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(height, m_hardforks, tx_hardfork_id);
|
||||
while (true)
|
||||
{
|
||||
r = construct_miner_tx(height, misc_utils::median(block_sizes),
|
||||
|
|
@ -310,7 +312,8 @@ bool test_generator::construct_block(currency::block& blk,
|
|||
blk.miner_tx,
|
||||
block_reward_without_fee,
|
||||
block_reward,
|
||||
get_tx_version(height, m_hardforks),
|
||||
tx_version,
|
||||
tx_hardfork_id,
|
||||
blobdata(),
|
||||
test_generator::get_test_gentime_settings().miner_tx_max_outs,
|
||||
static_cast<bool>(coin_stake_sources.size()),
|
||||
|
|
@ -956,10 +959,12 @@ bool test_generator::construct_block(int64_t manual_timestamp_adjustment,
|
|||
{
|
||||
uint64_t base_block_reward = 0;
|
||||
uint64_t block_reward = 0;
|
||||
size_t tx_hardfork_id = 0;
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(height, m_hardforks, tx_hardfork_id);
|
||||
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, base_block_reward, block_reward, get_tx_version(height, m_hardforks), blobdata(), 1))
|
||||
miner_acc.get_public_address(), miner_acc.get_public_address(), blk.miner_tx, base_block_reward, block_reward, tx_version, tx_hardfork_id, blobdata(), 1))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1745,8 +1750,9 @@ bool construct_tx_to_key(const currency::hard_forks_descriptor& hf,
|
|||
std::vector<tx_destination_entry> destinations;
|
||||
if (!fill_tx_sources_and_destinations(events, blk_head, from.get_keys(), to.get_public_address(), amount, fee, nmix, sources, destinations, check_for_spends, check_for_unlocktime))
|
||||
return false;
|
||||
uint64_t tx_version = currency::get_tx_version(get_block_height(blk_head) + 1, hf); // assuming the tx will be in the next block (blk_head + 1)
|
||||
return construct_tx(from.get_keys(), sources, destinations, extr, att, tx, tx_version, sk, 0, mix_attr);
|
||||
size_t tx_hardfork_id = 0;
|
||||
uint64_t tx_version = currency::get_tx_version_and_hardfork_id(get_block_height(blk_head) + 1, hf, tx_hardfork_id); // assuming the tx will be in the next block (blk_head + 1)
|
||||
return construct_tx(from.get_keys(), sources, destinations, extr, att, tx, tx_version, tx_hardfork_id, sk, 0, mix_attr);
|
||||
}
|
||||
|
||||
bool construct_tx_to_key(const currency::hard_forks_descriptor& hf,
|
||||
|
|
@ -1774,16 +1780,17 @@ bool construct_tx_to_key(const currency::hard_forks_descriptor& hf,
|
|||
return false;
|
||||
|
||||
uint64_t tx_expected_block_height = get_block_height(blk_head) + 1;
|
||||
uint64_t tx_version = currency::get_tx_version(tx_expected_block_height, hf);
|
||||
size_t tx_hardfork_id = 0;
|
||||
uint64_t tx_version = currency::get_tx_version_and_hardfork_id(tx_expected_block_height, hf, tx_hardfork_id);
|
||||
boost::multiprecision::int128_t change = get_sources_total_amount(sources);
|
||||
change -= spending_amount;
|
||||
if (change < 0)
|
||||
return false; // should never happen if fill_tx_sources succeded
|
||||
if (change == 0)
|
||||
return construct_tx(from.get_keys(), sources, destinations, extr, att, tx, tx_version, sk, 0, mix_attr);
|
||||
return construct_tx(from.get_keys(), sources, destinations, extr, att, tx, tx_version, tx_hardfork_id, sk, 0, mix_attr);
|
||||
std::vector<tx_destination_entry> local_dst = destinations;
|
||||
local_dst.push_back(tx_destination_entry(change.convert_to<uint64_t>(), from.get_public_address()));
|
||||
return construct_tx(from.get_keys(), sources, local_dst, extr, att, tx, tx_version, sk, 0, mix_attr);
|
||||
return construct_tx(from.get_keys(), sources, local_dst, extr, att, tx, tx_version, tx_hardfork_id, sk, 0, mix_attr);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1812,8 +1819,53 @@ bool construct_tx_with_many_outputs(const currency::hard_forks_descriptor& hf, s
|
|||
uint64_t sources_amount = get_sources_total_amount(sources);
|
||||
if (sources_amount > total_amount + fee)
|
||||
destinations.push_back(tx_destination_entry(sources_amount - (total_amount + fee), keys_from.account_address)); // change
|
||||
uint64_t tx_version = currency::get_tx_version(currency::get_block_height(blk_head), hf);
|
||||
return construct_tx(keys_from, sources, destinations, empty_attachment, tx, tx_version, 0);
|
||||
size_t tx_hardfork_id = 0;
|
||||
uint64_t tx_version = currency::get_tx_version_and_hardfork_id(currency::get_block_height(blk_head), hf, tx_hardfork_id);
|
||||
return construct_tx(keys_from, sources, destinations, empty_attachment, tx, tx_version, tx_hardfork_id, 0);
|
||||
}
|
||||
|
||||
bool construct_tx(const account_keys& sender_account_keys,
|
||||
const std::vector<tx_source_entry>& sources,
|
||||
const std::vector<tx_destination_entry>& destinations,
|
||||
const std::vector<extra_v>& extra,
|
||||
const std::vector<attachment_v>& attachments,
|
||||
transaction& tx,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
crypto::secret_key& one_time_secret_key,
|
||||
uint64_t unlock_time,
|
||||
uint64_t expiration_time,
|
||||
uint8_t tx_outs_attr,
|
||||
bool shuffle,
|
||||
uint64_t flags,
|
||||
uint64_t explicit_consolidated_tx_fee,
|
||||
tx_generation_context& gen_context)
|
||||
{
|
||||
// extra copy operation, but creating transaction is not sensitive to this
|
||||
finalize_tx_param ftp {};
|
||||
ftp.tx_version = tx_version;
|
||||
ftp.tx_hardfork_id = tx_hardfork_id;
|
||||
ftp.sources = sources;
|
||||
ftp.prepared_destinations = destinations;
|
||||
ftp.extra = extra;
|
||||
ftp.attachments = attachments;
|
||||
ftp.unlock_time = unlock_time;
|
||||
// ftp.crypt_address = crypt_destination_addr;
|
||||
ftp.expiration_time = expiration_time;
|
||||
ftp.tx_outs_attr = tx_outs_attr;
|
||||
ftp.shuffle = shuffle;
|
||||
ftp.flags = flags;
|
||||
ftp.mode_separate_fee = explicit_consolidated_tx_fee;
|
||||
|
||||
finalized_tx ft{};
|
||||
ft.tx = tx;
|
||||
ft.one_time_key = one_time_secret_key;
|
||||
ftp.gen_context = gen_context; // ftp, not ft here, this is UGLY -- sowle
|
||||
bool r = construct_tx(sender_account_keys, ftp, ft);
|
||||
tx = ft.tx;
|
||||
one_time_secret_key = ft.one_time_key;
|
||||
gen_context = ft.ftp.gen_context;
|
||||
return r;
|
||||
}
|
||||
|
||||
bool construct_tx(const account_keys& sender_account_keys,
|
||||
|
|
@ -1835,6 +1887,9 @@ bool construct_tx(const account_keys& sender_account_keys,
|
|||
// extra copy operation, but creating transaction is not sensitive to this
|
||||
finalize_tx_param ftp {};
|
||||
ftp.tx_version = tx_version;
|
||||
if (tx_version >= TRANSACTION_VERSION_POST_HF5)
|
||||
LOG_PRINT_YELLOW("warning: tx_hardfork_id not set for tx, while it seems to be HF5", LOG_LEVEL_0);
|
||||
ftp.tx_hardfork_id = 0;
|
||||
ftp.sources = sources;
|
||||
ftp.prepared_destinations = destinations;
|
||||
ftp.extra = extra;
|
||||
|
|
@ -1847,7 +1902,7 @@ bool construct_tx(const account_keys& sender_account_keys,
|
|||
ftp.flags = flags;
|
||||
ftp.mode_separate_fee = explicit_consolidated_tx_fee;
|
||||
|
||||
finalized_tx ft = AUTO_VAL_INIT(ft);
|
||||
finalized_tx ft{};
|
||||
ft.tx = tx;
|
||||
ft.one_time_key = one_time_secret_key;
|
||||
ftp.gen_context = gen_context; // ftp, not ft here, this is UGLY -- sowle
|
||||
|
|
@ -1858,6 +1913,63 @@ bool construct_tx(const account_keys& sender_account_keys,
|
|||
return r;
|
||||
}
|
||||
|
||||
bool construct_tx(const currency::account_keys& sender_account_keys,
|
||||
const std::vector<currency::tx_source_entry>& sources,
|
||||
const std::vector<currency::tx_destination_entry>& destinations,
|
||||
const std::vector<currency::extra_v>& extra,
|
||||
const std::vector<currency::attachment_v>& attachments,
|
||||
currency::transaction& tx,
|
||||
uint64_t tx_version,
|
||||
crypto::secret_key& one_time_secret_key,
|
||||
uint64_t unlock_time)
|
||||
{
|
||||
[[maybe_unused]] tx_generation_context gen_context{};
|
||||
return construct_tx(sender_account_keys,
|
||||
sources,
|
||||
destinations,
|
||||
extra,
|
||||
attachments,
|
||||
tx,
|
||||
tx_version,
|
||||
one_time_secret_key,
|
||||
unlock_time,
|
||||
0, /* expiration_time */
|
||||
CURRENCY_TO_KEY_OUT_RELAXED, /* tx_outs_attr */
|
||||
true, /* shuffle */
|
||||
0, /* flags */
|
||||
0, /* explicit_consolidated_tx_fee */
|
||||
gen_context /* tx_generation_context */
|
||||
);
|
||||
}
|
||||
|
||||
bool construct_tx(const currency::account_keys& sender_account_keys,
|
||||
const std::vector<currency::tx_source_entry>& sources,
|
||||
const std::vector<currency::tx_destination_entry>& destinations,
|
||||
const std::vector<currency::extra_v>& extra,
|
||||
const std::vector<currency::attachment_v>& attachments,
|
||||
currency::transaction& tx,
|
||||
uint64_t tx_version)
|
||||
{
|
||||
[[maybe_unused]] tx_generation_context gen_context{};
|
||||
[[maybe_unused]] crypto::secret_key tx_sec_key{};
|
||||
return construct_tx(sender_account_keys,
|
||||
sources,
|
||||
destinations,
|
||||
extra,
|
||||
attachments,
|
||||
tx,
|
||||
tx_version,
|
||||
tx_sec_key, /* one_time_secret_key */
|
||||
0, /* unlock_time */
|
||||
0, /* expiration_time */
|
||||
CURRENCY_TO_KEY_OUT_RELAXED, /* tx_outs_attr */
|
||||
true, /* shuffle */
|
||||
0, /* flags */
|
||||
0, /* explicit_consolidated_tx_fee */
|
||||
gen_context /* tx_generation_context */
|
||||
);
|
||||
}
|
||||
|
||||
uint64_t get_balance(const currency::account_keys& addr, const std::vector<currency::block>& blockchain, const map_hash2tx_t& mtx, bool dbg_log)
|
||||
{
|
||||
uint64_t res = 0;
|
||||
|
|
@ -2560,19 +2672,26 @@ void test_chain_unit_base::register_callback(const std::string& cb_name, verify_
|
|||
m_callbacks[cb_name] = cb;
|
||||
}
|
||||
|
||||
uint64_t test_chain_unit_base::get_tx_version_from_events(const std::vector<test_event_entry> &events)const
|
||||
uint64_t test_chain_unit_base::get_tx_version_from_events(const std::vector<test_event_entry> &events) const
|
||||
{
|
||||
[[maybe_unused]] size_t tx_hardfork_id{};
|
||||
return get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id);
|
||||
}
|
||||
|
||||
uint64_t test_chain_unit_base::get_tx_version_and_harfork_id_from_events(const std::vector<test_event_entry> &events, size_t& tx_hardfork_id) const
|
||||
{
|
||||
for (auto it = events.rbegin(); it!= events.rend(); it++)
|
||||
{
|
||||
if(it->type() == typeid(currency::block))
|
||||
{
|
||||
const currency::block& b = boost::get<currency::block>(*it);
|
||||
return currency::get_tx_version(get_block_height(b), m_hardforks);
|
||||
return currency::get_tx_version_and_hardfork_id(get_block_height(b), m_hardforks, tx_hardfork_id);
|
||||
}
|
||||
}
|
||||
return currency::get_tx_version(0, m_hardforks);
|
||||
return currency::get_tx_version_and_hardfork_id(0, m_hardforks, tx_hardfork_id);
|
||||
}
|
||||
|
||||
|
||||
bool test_chain_unit_base::verify(const std::string& cb_name, currency::core& c, size_t ev_index, const std::vector<test_event_entry> &events)
|
||||
{
|
||||
auto cb_it = m_callbacks.find(cb_name);
|
||||
|
|
|
|||
|
|
@ -257,6 +257,7 @@ public:
|
|||
bool need_core_proxy() const { return false; } // tests can override this in order to obtain core proxy (e.g. for wallet)
|
||||
void set_core_proxy(std::shared_ptr<tools::i_core_proxy>) { /* do nothing */ }
|
||||
uint64_t get_tx_version_from_events(const std::vector<test_event_entry> &events) const;
|
||||
uint64_t get_tx_version_and_harfork_id_from_events(const std::vector<test_event_entry> &events, size_t& tx_hardfork_id) const;
|
||||
|
||||
virtual void on_test_constructed() {} // called right after test class is constructed by the chaingen
|
||||
void on_test_generator_created(test_generator& generator) const; // tests can override this for special initialization
|
||||
|
|
@ -691,6 +692,41 @@ bool construct_tx(const currency::account_keys& sender_account_keys,
|
|||
uint64_t explicit_consolidated_tx_fee,
|
||||
currency::tx_generation_context& gen_context);
|
||||
|
||||
bool construct_tx(const currency::account_keys& sender_account_keys,
|
||||
const std::vector<currency::tx_source_entry>& sources,
|
||||
const std::vector<currency::tx_destination_entry>& destinations,
|
||||
const std::vector<currency::extra_v>& extra,
|
||||
const std::vector<currency::attachment_v>& attachments,
|
||||
currency::transaction& tx,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
crypto::secret_key& one_time_secret_key,
|
||||
uint64_t unlock_time,
|
||||
uint64_t expiration_time,
|
||||
uint8_t tx_outs_attr,
|
||||
bool shuffle,
|
||||
uint64_t flags,
|
||||
uint64_t explicit_consolidated_tx_fee,
|
||||
currency::tx_generation_context& gen_context);
|
||||
|
||||
bool construct_tx(const currency::account_keys& sender_account_keys,
|
||||
const std::vector<currency::tx_source_entry>& sources,
|
||||
const std::vector<currency::tx_destination_entry>& destinations,
|
||||
const std::vector<currency::extra_v>& extra,
|
||||
const std::vector<currency::attachment_v>& attachments,
|
||||
currency::transaction& tx,
|
||||
uint64_t tx_version,
|
||||
crypto::secret_key& one_time_secret_key,
|
||||
uint64_t unlock_time);
|
||||
|
||||
bool construct_tx(const currency::account_keys& sender_account_keys,
|
||||
const std::vector<currency::tx_source_entry>& sources,
|
||||
const std::vector<currency::tx_destination_entry>& destinations,
|
||||
const std::vector<currency::extra_v>& extra,
|
||||
const std::vector<currency::attachment_v>& attachments,
|
||||
currency::transaction& tx,
|
||||
uint64_t tx_version);
|
||||
|
||||
void get_confirmed_txs(const std::vector<currency::block>& blockchain, const map_hash2tx_t& mtx, map_hash2tx_t& confirmed_txs);
|
||||
bool find_block_chain(const std::vector<test_event_entry>& events, std::vector<currency::block>& blockchain, map_hash2tx_t& mtx, const crypto::hash& head);
|
||||
bool fill_tx_sources(std::vector<currency::tx_source_entry>& sources, const std::vector<test_event_entry>& events,
|
||||
|
|
@ -994,10 +1030,12 @@ bool test_generator::construct_block_gentime_with_coinbase_cb(const currency::bl
|
|||
|
||||
uint64_t block_reward_without_fee = 0;
|
||||
uint64_t block_reward = 0;
|
||||
size_t tx_hardfork_id = 0;
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(height, m_hardforks, tx_hardfork_id);
|
||||
|
||||
currency::keypair tx_sec_key = currency::keypair::generate();
|
||||
r = construct_miner_tx(height, epee::misc_utils::median(block_sizes), already_generated_coins, 0 /* current_block_size !HACK! */, 0,
|
||||
acc.get_public_address(), acc.get_public_address(), miner_tx, block_reward_without_fee, block_reward, get_tx_version(height, m_hardforks), currency::blobdata(), /* max outs: */ 1,
|
||||
acc.get_public_address(), acc.get_public_address(), miner_tx, block_reward_without_fee, block_reward, tx_version, tx_hardfork_id, currency::blobdata(), /* max outs: */ 1,
|
||||
/* pos: */ false, currency::pos_entry(), /* ogc_ptr: */ nullptr, &tx_sec_key);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_miner_tx failed");
|
||||
|
||||
|
|
|
|||
|
|
@ -313,9 +313,10 @@ inline bool put_alias_via_tx_to_list(const currency::hard_forks_descriptor& hf,
|
|||
el.flags |= currency::tx_destination_entry_flags::tdef_explicit_native_asset_id | currency::tx_destination_entry_flags::tdef_zero_amount_blinding_mask; // all alias-burn outputs must have explicit native asset id and zero amount mask
|
||||
}
|
||||
|
||||
uint64_t tx_version = currency::get_tx_version(get_block_height(head_block) + 1, generator.get_hardforks()); // assuming the tx will be in the next block (head_block + 1)
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = currency::get_tx_version_and_hardfork_id(get_block_height(head_block) + 1, generator.get_hardforks(), tx_hardfork_id); // assuming the tx will be in the next block (head_block + 1)
|
||||
tx_set.emplace_back();
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, extra, empty_attachment, tx_set.back(), tx_version, generator.last_tx_generated_secret_key, 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, extra, empty_attachment, tx_set.back(), tx_version, tx_hardfork_id, generator.last_tx_generated_secret_key, 0);
|
||||
PRINT_EVENT_N_TEXT(events, "put_alias_via_tx_to_list()");
|
||||
events.push_back(tx_set.back());
|
||||
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ bool gen_and_play_intermitted_by_blockchain_saveload(const char* const genclass_
|
|||
|
||||
|
||||
#define GENERATE_AND_PLAY(genclass) \
|
||||
if (!skip_all_till_the_end && ((!postponed_tests.count(#genclass) && run_single_test.empty()) || (!run_single_test.empty() && std::string::npos != std::string(#genclass).find(run_single_test)))) \
|
||||
if (!skip_all_till_the_end && ((!postponed_tests.count(#genclass) && run_single_test.empty()) || (!run_single_test.empty() && std::string(#genclass) == run_single_test))) \
|
||||
{ \
|
||||
TIME_MEASURE_START_MS(t); \
|
||||
++tests_count; \
|
||||
|
|
@ -422,7 +422,7 @@ bool gen_and_play_intermitted_by_blockchain_saveload(const char* const genclass_
|
|||
}
|
||||
|
||||
#define GENERATE_AND_PLAY_HF(genclass, hardfork_str_mask) \
|
||||
if (!skip_all_till_the_end && ((!postponed_tests.count(#genclass) && run_single_test.empty()) || (!run_single_test.empty() && std::string::npos != std::string(#genclass).find(run_single_test)))) \
|
||||
if (!skip_all_till_the_end && ((!postponed_tests.count(#genclass) && run_single_test.empty()) || (!run_single_test.empty() && std::string(#genclass) == run_single_test))) \
|
||||
{ \
|
||||
std::vector<size_t> hardforks = parse_hardfork_str_mask(hardfork_str_mask); \
|
||||
CHECK_AND_ASSERT_MES(!hardforks.empty(), false, "invalid hardforks mask: " << hardfork_str_mask); \
|
||||
|
|
@ -1276,6 +1276,9 @@ int main(int argc, char* argv[])
|
|||
GENERATE_AND_PLAY(hardfork_4_wallet_sweep_bare_outs);
|
||||
GENERATE_AND_PLAY_HF(hardfork_4_pop_tx_from_global_index, "4-*");
|
||||
|
||||
// HF5
|
||||
GENERATE_AND_PLAY_HF(hard_fork_5_tx_version, "5-*");
|
||||
|
||||
// atomics
|
||||
GENERATE_AND_PLAY(atomic_simple_test);
|
||||
GENERATE_AND_PLAY(atomic_test_wrong_redeem_wrong_refund);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include "hard_fork_1.h"
|
||||
#include "hard_fork_2.h"
|
||||
#include "hard_fork_4.h"
|
||||
#include "hard_fork_5.h"
|
||||
#include "atomic_tests.h"
|
||||
#include "isolate_auditable_and_proof.h"
|
||||
#include "zarcanum_test.h"
|
||||
|
|
|
|||
|
|
@ -930,8 +930,8 @@ bool gen_checkpoints_and_invalid_tx_to_pool::generate(std::vector<test_event_ent
|
|||
r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc, miner_acc, MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
|
||||
transaction tx_0 = AUTO_VAL_INIT(tx_0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0);
|
||||
transaction tx_0{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_extra, empty_attachment, tx_0, get_tx_version_from_events(events));
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
// invalidate tx_0 signature
|
||||
|
|
|
|||
|
|
@ -95,7 +95,9 @@ bool gen_double_spend_in_tx<txs_kept_by_block>::generate(std::vector<test_event_
|
|||
|
||||
currency::transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
std::vector<currency::attachment_v> attachments;
|
||||
if (!construct_tx(bob_account.get_keys(), sources, destinations, attachments, tx_1, this->get_tx_version_from_events(events), uint64_t(0)))
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_from_events(events);
|
||||
if (!construct_tx(bob_account.get_keys(), sources, destinations, attachments, tx_1, tx_version, tx_hardfork_id, uint64_t(0)))
|
||||
return false;
|
||||
|
||||
SET_EVENT_VISITOR_SETT(events, event_visitor_settings::set_txs_kept_by_block, txs_kept_by_block);
|
||||
|
|
|
|||
|
|
@ -181,8 +181,9 @@ bool pos_emission_test::generate(std::vector<test_event_entry> &events)
|
|||
for (size_t i = 0; i < m_pos_entries_to_generate; ++i)
|
||||
destinations.push_back(tx_destination_entry(pos_entry_amount, alice_acc.get_public_address()));
|
||||
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(preminer_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0);
|
||||
transaction tx_1{};
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(preminer_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_1);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_1, blk_0r, miner_acc, tx_1);
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ inline bool build_custom_escrow_template(const std::vector<test_event_entry>& ev
|
|||
bc_services::contract_private_details& cpd, uint64_t unlock_time, uint64_t expiration_time, size_t nmix, uint64_t b_fee_release,
|
||||
uint64_t custom_config_mask,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
transaction& escrow_template_tx, /* OUT */
|
||||
crypto::secret_key& tx_key_sec, /* OUT */
|
||||
std::vector<tx_source_entry>& used_sources /* IN/OUT */)
|
||||
|
|
@ -231,7 +232,7 @@ inline bool build_custom_escrow_template(const std::vector<test_event_entry>& ev
|
|||
if (custom_config_mask & eccf_template_additional_attach)
|
||||
attachments.push_back(tx_comment({ get_random_text(1024) }));
|
||||
|
||||
r = construct_tx(a_keys, sources, destinations, extra, attachments, escrow_template_tx, tx_version, tx_key_sec, unlock_time, crypt_addr, expiration_time, CURRENCY_TO_KEY_OUT_RELAXED, true, flags);
|
||||
r = construct_tx(a_keys, sources, destinations, extra, attachments, escrow_template_tx, tx_version, tx_hardfork_id, tx_key_sec, unlock_time, crypt_addr, expiration_time, CURRENCY_TO_KEY_OUT_RELAXED, true, flags);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
if (custom_config_mask & eccf_template_no_tx_flags)
|
||||
|
|
@ -266,6 +267,7 @@ inline bool build_custom_escrow_proposal(const std::vector<test_event_entry>& ev
|
|||
uint64_t a_fee_proposal, uint64_t b_fee_release,
|
||||
uint64_t custom_config_mask,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
transaction& escrow_proposal_tx, /* OUT */
|
||||
std::vector<tx_source_entry>& used_sources,/* IN/OUT */
|
||||
bc_services::proposal_body* p_pb = nullptr /* OUT */ )
|
||||
|
|
@ -283,7 +285,7 @@ inline bool build_custom_escrow_proposal(const std::vector<test_event_entry>& ev
|
|||
p_pb = &local_pb;
|
||||
if (~custom_config_mask & eccf_proposal_sa_empty_body)
|
||||
{
|
||||
r = build_custom_escrow_template(events, head, a_keys, cpd, template_unlock_time, template_expiration_time, nmix, b_fee_release, custom_config_mask, tx_version, p_pb->tx_template, p_pb->tx_onetime_secret_key, used_sources);
|
||||
r = build_custom_escrow_template(events, head, a_keys, cpd, template_unlock_time, template_expiration_time, nmix, b_fee_release, custom_config_mask, tx_version, tx_hardfork_id, p_pb->tx_template, p_pb->tx_onetime_secret_key, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_template failed");
|
||||
}
|
||||
|
||||
|
|
@ -309,7 +311,7 @@ inline bool build_custom_escrow_proposal(const std::vector<test_event_entry>& ev
|
|||
account_public_address crypt_addr = cpd.b_addr;
|
||||
|
||||
crypto::secret_key tx_key_sec; // stub, not used
|
||||
r = construct_tx(a_keys, sources, destinations, empty_extra, attachments, escrow_proposal_tx, tx_version, tx_key_sec, unlock_time, crypt_addr, expiration_time, 0, true, (~custom_config_mask & eccf_proposal_inv_flags) ? 0 : TX_FLAG_SIGNATURE_MODE_SEPARATE);
|
||||
r = construct_tx(a_keys, sources, destinations, empty_extra, attachments, escrow_proposal_tx, tx_version, tx_hardfork_id, tx_key_sec, unlock_time, crypt_addr, expiration_time, 0, true, (~custom_config_mask & eccf_proposal_inv_flags) ? 0 : TX_FLAG_SIGNATURE_MODE_SEPARATE);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
append_vector_by_another_vector(used_sources, sources);
|
||||
|
|
@ -321,7 +323,8 @@ inline bool build_custom_escrow_release_template(
|
|||
const account_keys& b_keys,
|
||||
const bc_services::contract_private_details& cpd,
|
||||
uint64_t unlock_time, uint64_t expiration_time,
|
||||
uint64_t tx_version,
|
||||
uint64_t tx_version,
|
||||
size_t tx_hardfork_id,
|
||||
const transaction& escrow_template_tx, /* IN (needed for ms output, tx pub key) */
|
||||
uint64_t custom_config_mask, /* IN */
|
||||
transaction& tx /* OUT */
|
||||
|
|
@ -420,7 +423,7 @@ inline bool build_custom_escrow_release_template(
|
|||
|
||||
crypto::secret_key one_time_secret_key = AUTO_VAL_INIT(one_time_secret_key);
|
||||
account_public_address crypt_address = AUTO_VAL_INIT(crypt_address);
|
||||
bool r = construct_tx(b_keys, sources, destinations, extra, attachments, tx, tx_version, one_time_secret_key, unlock_time, crypt_address, expiration_time, 0, true, tx_flags);
|
||||
bool r = construct_tx(b_keys, sources, destinations, extra, attachments, tx, tx_version, tx_hardfork_id, one_time_secret_key, unlock_time, crypt_address, expiration_time, 0, true, tx_flags);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
bool tx_fully_signed = false;
|
||||
r = sign_multisig_input_in_tx(tx, 0, b_keys, escrow_template_tx, &tx_fully_signed);
|
||||
|
|
@ -470,6 +473,7 @@ inline bool build_custom_escrow_accept_proposal(
|
|||
uint64_t custom_config_mask, /* IN */
|
||||
crypto::secret_key one_time_secret_key, /* IN */
|
||||
uint64_t tx_version, /* IN */
|
||||
size_t tx_hardfork_id, /* IN */
|
||||
transaction& tx, /* IN (escrow template), OUT */
|
||||
std::vector<tx_source_entry>& used_sources /* IN/OUT */
|
||||
)
|
||||
|
|
@ -496,9 +500,9 @@ inline bool build_custom_escrow_accept_proposal(
|
|||
|
||||
// generate release templates
|
||||
bc_services::escrow_relese_templates_body rtb = AUTO_VAL_INIT(rtb);
|
||||
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_NORMAL, b_keys, cpd, release_unlock_time, release_expiration_time, tx_version, tx, custom_config_mask, rtb.tx_normal_template);
|
||||
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_NORMAL, b_keys, cpd, release_unlock_time, release_expiration_time, tx_version, tx_hardfork_id, tx, custom_config_mask, rtb.tx_normal_template);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_release_template(normal) failed");
|
||||
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_BURN, b_keys, cpd, release_unlock_time, release_expiration_time, tx_version, tx, custom_config_mask, rtb.tx_burn_template);
|
||||
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_BURN, b_keys, cpd, release_unlock_time, release_expiration_time, tx_version, tx_hardfork_id, tx, custom_config_mask, rtb.tx_burn_template);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_release_template(burn) failed");
|
||||
|
||||
// put release templates into the extra
|
||||
|
|
@ -529,7 +533,7 @@ inline bool build_custom_escrow_accept_proposal(
|
|||
sources.back().separately_signed_tx_complete = true;
|
||||
|
||||
account_public_address crypt_address = AUTO_VAL_INIT(crypt_address);
|
||||
r = construct_tx(b_keys, sources, destinations, extra, attachments, tx, tx_version, one_time_secret_key, 0, crypt_address, 0, 0, true, tx_flags); // see comment above regarding unlock_time and expiration_time
|
||||
r = construct_tx(b_keys, sources, destinations, extra, attachments, tx, tx_version, tx_hardfork_id, one_time_secret_key, 0, crypt_address, 0, 0, true, tx_flags); // see comment above regarding unlock_time and expiration_time
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
return true;
|
||||
|
|
@ -545,6 +549,7 @@ inline bool build_custom_escrow_cancel_proposal(
|
|||
uint64_t custom_config_mask, /* IN */
|
||||
const transaction& escrow_template_tx, /* IN */
|
||||
uint64_t tx_version, /* IN */
|
||||
size_t tx_hardfork_id, /* IN */
|
||||
transaction& tx, /* OUT */
|
||||
std::vector<tx_source_entry>& used_sources /* IN/OUT */
|
||||
)
|
||||
|
|
@ -568,7 +573,7 @@ inline bool build_custom_escrow_cancel_proposal(
|
|||
|
||||
// generate cancel release template
|
||||
bc_services::escrow_cancel_templates_body ctb = AUTO_VAL_INIT(ctb);
|
||||
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_CANCEL, a_keys, cpd, release_unlock_time, release_expiration_time, tx_version, escrow_template_tx, custom_config_mask, ctb.tx_cancel_template);
|
||||
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_CANCEL, a_keys, cpd, release_unlock_time, release_expiration_time, tx_version, tx_hardfork_id, escrow_template_tx, custom_config_mask, ctb.tx_cancel_template);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_release_template(cancel) failed");
|
||||
|
||||
// put release templates into the extra
|
||||
|
|
@ -593,7 +598,7 @@ inline bool build_custom_escrow_cancel_proposal(
|
|||
if (~custom_config_mask & eccf_cancellation_inv_crypt_address)
|
||||
crypt_address = cpd.b_addr;
|
||||
crypto::secret_key one_time_secret_key = AUTO_VAL_INIT(one_time_secret_key);
|
||||
r = construct_tx(a_keys, sources, destinations, extra, attachments, tx, tx_version, one_time_secret_key, unlock_time, crypt_address, expiration_time, 0, true, tx_flags);
|
||||
r = construct_tx(a_keys, sources, destinations, extra, attachments, tx, tx_version, tx_hardfork_id, one_time_secret_key, unlock_time, crypt_address, expiration_time, 0, true, tx_flags);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -503,10 +503,11 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
|
|||
|
||||
// 1. create normal proposal and make sure it goes correctly through out the whole mechanism (test self-check)
|
||||
// if it fails, it means build_custom_escrow_proposal() produced incorrect proposal
|
||||
uint64_t tx_version = get_tx_version(get_block_height(blk_1r), m_hardforks);
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_1r), m_hardforks, tx_hardfork_id);
|
||||
uint64_t normal_escrow_mask = eccf_proposal_additional_attach | eccf_template_additional_extra | eccf_template_additional_attach;
|
||||
transaction normal_escrow_proposal_tx = AUTO_VAL_INIT(normal_escrow_proposal_tx);
|
||||
r = build_custom_escrow_proposal(events, blk_1r, miner_acc.get_keys(), cpd, 0, 0, 0, blk_1r.timestamp + 3600, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, normal_escrow_mask, tx_version, normal_escrow_proposal_tx, used_sources);
|
||||
r = build_custom_escrow_proposal(events, blk_1r, miner_acc.get_keys(), cpd, 0, 0, 0, blk_1r.timestamp + 3600, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, normal_escrow_mask, tx_version, tx_hardfork_id, normal_escrow_proposal_tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
|
||||
|
||||
events.push_back(normal_escrow_proposal_tx);
|
||||
|
|
@ -550,9 +551,9 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
|
|||
uint64_t config_mask = custom_config_masks[i].mask;
|
||||
cpd.comment = "#" + std::to_string(i) + " " + custom_config_masks[i].name;
|
||||
|
||||
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
|
||||
transaction escrow_proposal_tx = AUTO_VAL_INIT(escrow_proposal_tx);
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, 0, 0, top_block.timestamp + 3600, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, config_mask, tx_version, escrow_proposal_tx, used_sources);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(top_block), m_hardforks, tx_hardfork_id);
|
||||
transaction escrow_proposal_tx{};
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, 0, 0, top_block.timestamp + 3600, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, config_mask, tx_version, tx_hardfork_id, escrow_proposal_tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
|
||||
|
||||
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(escrow_proposal_tx) << " is built for mask: " << cpd.comment, LOG_LEVEL_0);
|
||||
|
|
@ -579,10 +580,10 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
|
|||
|
||||
{
|
||||
cpd.comment = "incorrect unlock time (past)";
|
||||
transaction tx = AUTO_VAL_INIT(tx);
|
||||
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
|
||||
transaction tx{};
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(top_block), m_hardforks, tx_hardfork_id);
|
||||
// set unlock time to the past (suppose it's incorrect for escrow proposals)
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, top_block.timestamp, 0, top_block.timestamp, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx, used_sources);
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, top_block.timestamp, 0, top_block.timestamp, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx_hardfork_id, tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
|
||||
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(tx) << " is built for " << cpd.comment, LOG_LEVEL_0);
|
||||
events.push_back(tx);
|
||||
|
|
@ -592,11 +593,11 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
|
|||
|
||||
{
|
||||
cpd.comment = "incorrect unlock time (future)";
|
||||
transaction tx = AUTO_VAL_INIT(tx);
|
||||
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
|
||||
transaction tx{};
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(top_block), m_hardforks, tx_hardfork_id);
|
||||
// set unlock time to the future (suppose it's incorrect for escrow proposals)
|
||||
uint64_t unlock_time = top_block.timestamp + 365 * 24 * 60 * 60;
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, unlock_time, 0, unlock_time, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx, used_sources);
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, unlock_time, 0, unlock_time, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx_hardfork_id, tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
|
||||
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(tx) << " is built for " << cpd.comment, LOG_LEVEL_0);
|
||||
events.push_back(tx);
|
||||
|
|
@ -606,9 +607,9 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
|
|||
|
||||
{
|
||||
cpd.comment = "template zero expiration time";
|
||||
transaction tx = AUTO_VAL_INIT(tx);
|
||||
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, 0, 0, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx, used_sources);
|
||||
transaction tx{};
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(top_block), m_hardforks, tx_hardfork_id);
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, 0, 0, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx_hardfork_id, tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
|
||||
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(tx) << " is built for " << cpd.comment, LOG_LEVEL_0);
|
||||
events.push_back(tx);
|
||||
|
|
@ -618,11 +619,11 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
|
|||
|
||||
{
|
||||
cpd.comment = "proposal non-zero expiration time";
|
||||
transaction tx = AUTO_VAL_INIT(tx);
|
||||
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
|
||||
transaction tx{};
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(top_block), m_hardforks, tx_hardfork_id);
|
||||
uint64_t proposal_expiration_time = top_block.timestamp + 12 * 60 * 60;
|
||||
uint64_t template_expiration_time = top_block.timestamp + 12 * 60 * 60;
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, proposal_expiration_time, 0, template_expiration_time, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx, used_sources);
|
||||
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, proposal_expiration_time, 0, template_expiration_time, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx_hardfork_id, tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
|
||||
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(tx) << " is built for " << cpd.comment, LOG_LEVEL_0);
|
||||
events.push_back(tx);
|
||||
|
|
@ -1149,17 +1150,18 @@ bool escrow_incorrect_proposal_acceptance::generate(std::vector<test_event_entry
|
|||
// create escrow proposal
|
||||
bc_services::proposal_body prop = AUTO_VAL_INIT(prop);
|
||||
transaction escrow_proposal_tx = AUTO_VAL_INIT(escrow_proposal_tx);
|
||||
uint64_t tx_version = get_tx_version(get_block_height(blk_1r), m_hardforks);
|
||||
r = build_custom_escrow_proposal(events, blk_1r, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_1r.timestamp + 36000, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, eccf_normal, tx_version, escrow_proposal_tx, used_sources, &prop);
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_1r), m_hardforks, tx_hardfork_id);
|
||||
r = build_custom_escrow_proposal(events, blk_1r, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_1r.timestamp + 36000, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, eccf_normal, tx_version, tx_hardfork_id, escrow_proposal_tx, used_sources, &prop);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
|
||||
events.push_back(escrow_proposal_tx);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1r, miner_acc, escrow_proposal_tx);
|
||||
|
||||
// create normal acceptance
|
||||
tx_version = get_tx_version(get_block_height(blk_2), m_hardforks);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_2), m_hardforks, tx_hardfork_id);
|
||||
transaction escrow_normal_acceptance_tx = prop.tx_template;
|
||||
uint64_t normal_acceptance_mask = eccf_acceptance_no_tsa_compression;
|
||||
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), m_cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, tx_version, escrow_normal_acceptance_tx, used_sources);
|
||||
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), m_cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, tx_version, tx_hardfork_id, escrow_normal_acceptance_tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_accept_proposal failed");
|
||||
|
||||
events.push_back(escrow_normal_acceptance_tx);
|
||||
|
|
@ -1258,10 +1260,10 @@ bool escrow_incorrect_proposal_acceptance::generate(std::vector<test_event_entry
|
|||
const auto &ccm_el = custom_config_masks[i];
|
||||
uint64_t mask = ccm_el.mask;
|
||||
|
||||
tx_version = get_tx_version(get_block_height(prev_block), m_hardforks);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(prev_block), m_hardforks, tx_hardfork_id);
|
||||
transaction incorrect_acceptance_tx = prop.tx_template;
|
||||
r = build_custom_escrow_accept_proposal(events, prev_block, 0, bob_acc.get_keys(), m_cpd, ccm_el.unlock_time, ccm_el.expiration_time, ccm_el.release_unlock_time, ccm_el.release_expiration_time,
|
||||
bob_fee_acceptance, m_bob_fee_release, mask, prop.tx_onetime_secret_key, tx_version, incorrect_acceptance_tx, used_sources);
|
||||
bob_fee_acceptance, m_bob_fee_release, mask, prop.tx_onetime_secret_key, tx_version, tx_hardfork_id, incorrect_acceptance_tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_accept_proposal failed");
|
||||
|
||||
// In order to use the same escrow proposal to test different invalid acceptance we need to switch chains after each try
|
||||
|
|
@ -1494,8 +1496,9 @@ bool escrow_custom_test::generate(std::vector<test_event_entry>& events) const
|
|||
destinations.push_back(tx_destination_entry(chunk_amount, bob_acc.get_public_address()));
|
||||
}
|
||||
// no change back to the miner - it will become a fee
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0);
|
||||
transaction tx_1{};
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
events.push_back(tx_1);
|
||||
|
|
@ -1949,7 +1952,8 @@ bool escrow_incorrect_cancel_proposal::generate(std::vector<test_event_entry>& e
|
|||
}
|
||||
// no change back to the miner - it will become a fee
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0);
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
events.push_back(tx_1);
|
||||
|
|
@ -1969,27 +1973,27 @@ bool escrow_incorrect_cancel_proposal::generate(std::vector<test_event_entry>& e
|
|||
|
||||
// create normal escrow proposal
|
||||
bc_services::proposal_body prop = AUTO_VAL_INIT(prop);
|
||||
uint64_t tx_version = get_tx_version(get_block_height(blk_1r), m_hardforks);
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_1r), m_hardforks, tx_hardfork_id);
|
||||
transaction escrow_proposal_tx = AUTO_VAL_INIT(escrow_proposal_tx);
|
||||
r = build_custom_escrow_proposal(events, blk_1r, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_1r.timestamp + 36000, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, eccf_normal, tx_version, escrow_proposal_tx, used_sources, &prop);
|
||||
r = build_custom_escrow_proposal(events, blk_1r, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_1r.timestamp + 36000, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, eccf_normal, tx_version, tx_hardfork_id, escrow_proposal_tx, used_sources, &prop);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
|
||||
events.push_back(escrow_proposal_tx);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1r, miner_acc, escrow_proposal_tx);
|
||||
|
||||
// create normal escrow proposal acceptance
|
||||
transaction escrow_normal_acceptance_tx = prop.tx_template;
|
||||
tx_version = get_tx_version(get_block_height(blk_2), m_hardforks);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_2), m_hardforks, tx_hardfork_id);
|
||||
uint64_t normal_acceptance_mask = eccf_acceptance_no_tsa_compression;
|
||||
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), m_cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, tx_version, escrow_normal_acceptance_tx, used_sources);
|
||||
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), m_cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, tx_version, tx_hardfork_id, escrow_normal_acceptance_tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_accept_proposal failed");
|
||||
|
||||
events.push_back(escrow_normal_acceptance_tx);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_3, blk_2, miner_acc, escrow_normal_acceptance_tx);
|
||||
|
||||
// create normal cancel proposal
|
||||
tx_version = get_tx_version(get_block_height(blk_3), m_hardforks);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_3), m_hardforks, tx_hardfork_id);
|
||||
transaction escrow_normal_cancel_proposal_tx = AUTO_VAL_INIT(escrow_normal_cancel_proposal_tx);
|
||||
r = build_custom_escrow_cancel_proposal(events, blk_3, 0, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_3.timestamp + 3600, TESTS_DEFAULT_FEE, eccf_normal, prop.tx_template, tx_version, escrow_normal_cancel_proposal_tx, used_sources);
|
||||
r = build_custom_escrow_cancel_proposal(events, blk_3, 0, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_3.timestamp + 3600, TESTS_DEFAULT_FEE, eccf_normal, prop.tx_template, tx_version, tx_hardfork_id, escrow_normal_cancel_proposal_tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_cancel_proposal failed");
|
||||
|
||||
events.push_back(escrow_normal_cancel_proposal_tx);
|
||||
|
|
@ -2057,9 +2061,9 @@ bool escrow_incorrect_cancel_proposal::generate(std::vector<test_event_entry>& e
|
|||
uint64_t mask = ccm_el.mask;
|
||||
|
||||
transaction incorrect_cancellation_proposal_tx = prop.tx_template;
|
||||
uint64_t tx_version = get_tx_version(get_block_height(blk_3), m_hardforks);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_3), m_hardforks, tx_hardfork_id);
|
||||
r = build_custom_escrow_cancel_proposal(events, prev_block, 0, alice_acc.get_keys(), m_cpd, ccm_el.unlock_time, ccm_el.expiration_time, ccm_el.release_unlock_time, ccm_el.release_expiration_time,
|
||||
TESTS_DEFAULT_FEE, mask, prop.tx_template, tx_version, incorrect_cancellation_proposal_tx, used_sources);
|
||||
TESTS_DEFAULT_FEE, mask, prop.tx_template, tx_version, tx_hardfork_id, incorrect_cancellation_proposal_tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_cancel_proposal failed");
|
||||
|
||||
// In order to use the same escrow proposal to test different invalid cancellations we need to switch chains after each try
|
||||
|
|
@ -2985,9 +2989,10 @@ bool escrow_proposal_acceptance_in_alt_chain::generate(std::vector<test_event_en
|
|||
|
||||
// escrow proposal
|
||||
bc_services::proposal_body prop = AUTO_VAL_INIT(prop);
|
||||
uint64_t tx_version = get_tx_version(get_block_height(blk_1), m_hardforks);
|
||||
size_t tx_hardfork_tx{};
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_1), m_hardforks, tx_hardfork_tx);
|
||||
transaction escrow_proposal_tx = AUTO_VAL_INIT(escrow_proposal_tx);
|
||||
r = build_custom_escrow_proposal(events, blk_1, alice_acc.get_keys(), cpd, 0, 0, 0, blk_1.timestamp + 36000, 0, TESTS_DEFAULT_FEE, bob_fee_release, eccf_normal, tx_version, escrow_proposal_tx, used_sources, &prop);
|
||||
r = build_custom_escrow_proposal(events, blk_1, alice_acc.get_keys(), cpd, 0, 0, 0, blk_1.timestamp + 36000, 0, TESTS_DEFAULT_FEE, bob_fee_release, eccf_normal, tx_version, tx_hardfork_tx, escrow_proposal_tx, used_sources, &prop);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
|
||||
events.push_back(escrow_proposal_tx);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1, miner_acc, escrow_proposal_tx);
|
||||
|
|
@ -2995,10 +3000,10 @@ bool escrow_proposal_acceptance_in_alt_chain::generate(std::vector<test_event_en
|
|||
MAKE_NEXT_BLOCK(events, blk_3, blk_2, miner_acc);
|
||||
|
||||
// escrow proposal acceptance
|
||||
tx_version = get_tx_version(get_block_height(blk_2), m_hardforks);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_2), m_hardforks, tx_hardfork_tx);
|
||||
transaction escrow_normal_acceptance_tx = prop.tx_template;
|
||||
uint64_t normal_acceptance_mask = eccf_normal; //eccf_acceptance_no_tsa_compression;
|
||||
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, tx_version, escrow_normal_acceptance_tx, used_sources);
|
||||
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, tx_version, tx_hardfork_tx, escrow_normal_acceptance_tx, used_sources);
|
||||
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_accept_proposal failed");
|
||||
|
||||
events.push_back(escrow_normal_acceptance_tx);
|
||||
|
|
|
|||
|
|
@ -98,8 +98,9 @@ bool random_outs_and_burnt_coins::generate(std::vector<test_event_entry>& events
|
|||
r = fill_tx_sources(sources, events, blk_0r, miner_acc.get_keys(), m_amount * m_fake_amounts_count + TESTS_DEFAULT_FEE, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources failed");
|
||||
|
||||
transaction tx_0 = AUTO_VAL_INIT(tx_0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0);
|
||||
transaction tx_0{};
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
uint64_t burned_tx_amount_total = get_burned_amount(tx_0);
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ bool hard_fork_1_checkpoint_basic_test::generate(std::vector<test_event_entry>&
|
|||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources failed");
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, std::vector<tx_destination_entry>{ tx_destination_entry(MK_TEST_COINS(90) - TESTS_DEFAULT_FEE, miner_acc.get_public_address()) },
|
||||
empty_attachment, tx_1, get_tx_version_from_events(events), stake_lock_time /* try to use stake unlock time -- should not work as it is not a coinbase */);
|
||||
empty_attachment, tx_1, get_tx_version_from_events(events), 0, stake_lock_time /* try to use stake unlock time -- should not work as it is not a coinbase */);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
DO_CALLBACK(events, "mark_invalid_tx");
|
||||
|
|
@ -882,7 +882,7 @@ bool hard_fork_1_pos_locked_height_vs_time::generate(std::vector<test_event_entr
|
|||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources failed");
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, std::vector<tx_destination_entry>{ tx_destination_entry(stake_amount / 2, miner_acc.get_public_address()) },
|
||||
empty_attachment, tx_1, get_tx_version_from_events(events), stake_unlock_time /* try to use stake unlock time -- should not work as it is not a coinbase */);
|
||||
empty_attachment, tx_1, get_tx_version_from_events(events), 0, stake_unlock_time /* try to use stake unlock time -- should not work as it is not a coinbase */);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
DO_CALLBACK(events, "mark_invalid_tx");
|
||||
|
|
|
|||
|
|
@ -82,7 +82,9 @@ bool hard_fork_4_consolidated_txs::generate(std::vector<test_event_entry>& event
|
|||
destinations.push_back(tx_destination_entry(m_bob_amount, bob_acc.get_public_address()));
|
||||
|
||||
add_flags_to_all_destination_entries(tx_destination_entry_flags::tdef_explicit_native_asset_id, destinations);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_extra, empty_attachment, tx_1, get_tx_version_from_events(events), one_time_secret_key,
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_extra, empty_attachment, tx_1, tx_version, tx_hardfork_id, one_time_secret_key,
|
||||
0, 0, 0, true, TX_FLAG_SIGNATURE_MODE_SEPARATE, TX_DEFAULT_FEE, gen_context);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
|
|
@ -119,7 +121,9 @@ bool hard_fork_4_consolidated_txs::generate(std::vector<test_event_entry>& event
|
|||
|
||||
std::vector<tx_destination_entry> destinations;
|
||||
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_extra, empty_attachment, tx_1, get_tx_version_from_events(events), one_time_secret_key,
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_extra, empty_attachment, tx_1, tx_version, tx_hardfork_id, one_time_secret_key,
|
||||
0, 0, 0, true, TX_FLAG_SIGNATURE_MODE_SEPARATE, 0 /* note zero fee here */, gen_context);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
|
|
|
|||
93
tests/core_tests/hard_fork_5.cpp
Normal file
93
tests/core_tests/hard_fork_5.cpp
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
// Copyright (c) 2024 Zano Project
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#include "chaingen.h"
|
||||
#include "hard_fork_5.h"
|
||||
#include "random_helper.h"
|
||||
|
||||
using namespace currency;
|
||||
|
||||
hard_fork_5_tx_version::hard_fork_5_tx_version()
|
||||
{
|
||||
REGISTER_CALLBACK_METHOD(hard_fork_5_tx_version, c1);
|
||||
}
|
||||
|
||||
bool hard_fork_5_tx_version::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
//
|
||||
// Test idea: ensure that the correct tx.hardfork_id is required after HF5.
|
||||
//
|
||||
bool r = false;
|
||||
uint64_t ts = test_core_time::get_time();
|
||||
m_accounts.resize(TOTAL_ACCS_COUNT);
|
||||
account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate(); miner_acc.set_createtime(ts);
|
||||
account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate(); alice_acc.set_createtime(ts);
|
||||
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, ts);
|
||||
DO_CALLBACK(events, "configure_core"); // default configure_core callback will initialize core runtime config with m_hardforks
|
||||
REWIND_BLOCKS_N_WITH_TIME(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 3);
|
||||
|
||||
// make a simple tx just to check HF5 tx.hardfork_id rule basic validity
|
||||
MAKE_TX(events, tx_1, miner_acc, alice_acc, MK_TEST_COINS(1), blk_0r);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_1, blk_0r, miner_acc, tx_1);
|
||||
|
||||
//
|
||||
// construct a tx with an incorrect hardfork_id and make sure it won't be accepted by either the tx pool or the core
|
||||
//
|
||||
std::vector<tx_source_entry> sources;
|
||||
std::vector<tx_destination_entry> destinations;
|
||||
|
||||
r = fill_tx_sources_and_destinations(events, blk_1, miner_acc, alice_acc, MK_TEST_COINS(7), TX_DEFAULT_FEE, 4, sources, destinations);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
|
||||
transaction tx_2{};
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_1) + 1, m_hardforks, tx_hardfork_id);
|
||||
size_t incorrect_tx_hardfork_id = 0;
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_2, tx_version, incorrect_tx_hardfork_id, 0); // note using incorrect hardfork id here
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
// mark as invalid, shouldn't be accepted by the tx pool
|
||||
DO_CALLBACK(events, "mark_invalid_tx");
|
||||
ADD_CUSTOM_EVENT(events, tx_2);
|
||||
|
||||
// now add tx_2 as 'kept_by_block', with tx pool checks turned off
|
||||
ADD_CUSTOM_EVENT(events, event_visitor_settings(event_visitor_settings::set_txs_kept_by_block, true));
|
||||
events.push_back(tx_2); // now tx should be accepted by the pool
|
||||
ADD_CUSTOM_EVENT(events, event_visitor_settings(event_visitor_settings::set_txs_kept_by_block, false));
|
||||
// the block shouldn't be accepted, because of invalid tx_2
|
||||
DO_CALLBACK(events, "mark_invalid_block");
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_2_bad, blk_1, miner_acc, tx_2);
|
||||
|
||||
|
||||
//
|
||||
// reconstruct the same tx, now using the correct tx_hardfork_id, and make sure it will be accepted
|
||||
//
|
||||
tx_2 = transaction{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_2, tx_version, tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
ADD_CUSTOM_EVENT(events, tx_2);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1, miner_acc, tx_2);
|
||||
|
||||
REWIND_BLOCKS_N_WITH_TIME(events, blk_2r, blk_2, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
// epilogue
|
||||
|
||||
DO_CALLBACK(events, "c1");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hard_fork_5_tx_version::c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry> &events)
|
||||
{
|
||||
std::shared_ptr<tools::wallet2> alice_wlt = init_playtime_test_wallet(events, c, ALICE_ACC_IDX);
|
||||
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 0, false, "Incorrect txs count in the pool");
|
||||
|
||||
size_t blocks_fetched = 0;
|
||||
alice_wlt->refresh(blocks_fetched);
|
||||
CHECK_AND_ASSERT_EQ(blocks_fetched, 2 * CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 5);
|
||||
|
||||
CHECK_AND_ASSERT_MES(check_balance_via_wallet(*alice_wlt.get(), "alice_wlt", MK_TEST_COINS(8)), false, "");
|
||||
|
||||
return true;
|
||||
}
|
||||
14
tests/core_tests/hard_fork_5.h
Normal file
14
tests/core_tests/hard_fork_5.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) 2024 Zano Project
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#pragma once
|
||||
#include "chaingen.h"
|
||||
#include "wallet_tests_basic.h"
|
||||
|
||||
|
||||
struct hard_fork_5_tx_version : public wallet_test
|
||||
{
|
||||
hard_fork_5_tx_version();
|
||||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
bool c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry> &events);
|
||||
};
|
||||
|
|
@ -157,9 +157,10 @@ bool gen_uint_overflow_2::generate(std::vector<test_event_entry>& events) const
|
|||
// sources.front().amount = destinations[0].amount + destinations[2].amount + destinations[3].amount + TESTS_DEFAULT_FEE
|
||||
destinations.push_back(tx_destination_entry(sources.front().amount - TX_MAX_TRANSFER_AMOUNT - TX_MAX_TRANSFER_AMOUNT + 1 - TESTS_DEFAULT_FEE, bob_addr));
|
||||
|
||||
currency::transaction tx_1;
|
||||
currency::transaction tx_1{};
|
||||
std::vector<currency::attachment_v> attachments;
|
||||
if (!construct_tx(miner_account.get_keys(), sources, destinations, attachments, tx_1, get_tx_version_from_events(events), 0))
|
||||
size_t tx_hardfork_id{};
|
||||
if (!construct_tx(miner_account.get_keys(), sources, destinations, attachments, tx_1, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0))
|
||||
return false;
|
||||
events.push_back(tx_1);
|
||||
|
||||
|
|
@ -186,7 +187,7 @@ bool gen_uint_overflow_2::generate(std::vector<test_event_entry>& events) const
|
|||
|
||||
currency::transaction tx_2;
|
||||
std::vector<currency::attachment_v> attachments2;
|
||||
if (!construct_tx(bob_account.get_keys(), sources, destinations, attachments2, tx_2, get_tx_version_from_events(events), 0))
|
||||
if (!construct_tx(bob_account.get_keys(), sources, destinations, attachments2, tx_2, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0))
|
||||
return false;
|
||||
events.push_back(tx_2);
|
||||
|
||||
|
|
|
|||
|
|
@ -237,8 +237,9 @@ bool block_template_vs_invalid_txs_from_pool::generate(std::vector<test_event_en
|
|||
std::vector<tx_source_entry> sources;
|
||||
r = fill_tx_sources(sources, events, blk_0r, miner_acc.get_keys(), de.amount + TESTS_DEFAULT_FEE, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources failed");
|
||||
transaction tx_1m = AUTO_VAL_INIT(tx_1m);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, std::vector<tx_destination_entry>({ de }), empty_attachment, tx_1m, get_tx_version_from_events(events), 0);
|
||||
transaction tx_1m;
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, std::vector<tx_destination_entry>({ de }), empty_attachment, tx_1m, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_1m);
|
||||
|
||||
|
|
@ -269,18 +270,18 @@ bool block_template_vs_invalid_txs_from_pool::generate(std::vector<test_event_en
|
|||
se.real_out_tx_key = get_tx_pub_key_from_extra(tx_1m);
|
||||
se.ms_keys_count = boost::get<txout_multisig>(boost::get<currency::tx_out_bare>(tx_1m.vout[se.real_output_in_tx_index]).target).keys.size();
|
||||
se.ms_sigs_count = 1;
|
||||
transaction tx_2m = AUTO_VAL_INIT(tx_2m);
|
||||
transaction tx_2m{};
|
||||
r = construct_tx(bob_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, miner_acc.get_public_address()) }),
|
||||
empty_attachment, tx_2m, get_tx_version_from_events(events), 0);
|
||||
empty_attachment, tx_2m, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
bool input_fully_signed = false;
|
||||
r = sign_multisig_input_in_tx(tx_2m, 0, bob_acc.get_keys(), tx_1m, &input_fully_signed);
|
||||
CHECK_AND_ASSERT_MES(r && input_fully_signed, false, "sign_multisig_input_in_tx failed, input_fully_signed=" << input_fully_signed);
|
||||
events.push_back(tx_2m);
|
||||
|
||||
transaction tx_2ma = AUTO_VAL_INIT(tx_2ma);
|
||||
transaction tx_2ma{};
|
||||
r = construct_tx(bob_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, miner_acc.get_public_address()) }),
|
||||
empty_attachment, tx_2ma, get_tx_version_from_events(events), 0);
|
||||
empty_attachment, tx_2ma, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
input_fully_signed = false;
|
||||
r = sign_multisig_input_in_tx(tx_2ma, 0, bob_acc.get_keys(), tx_1m, &input_fully_signed);
|
||||
|
|
@ -436,8 +437,9 @@ bool test_blockchain_vs_spent_multisig_outs::generate(std::vector<test_event_ent
|
|||
r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc.get_keys(), ms_addr_list, MK_TEST_COINS(2), TESTS_DEFAULT_FEE, 0,
|
||||
sources, destinations, true, true, 1);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_0 = AUTO_VAL_INIT(tx_0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0);
|
||||
transaction tx_0{};
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_0);
|
||||
|
||||
|
|
@ -457,8 +459,8 @@ bool test_blockchain_vs_spent_multisig_outs::generate(std::vector<test_event_ent
|
|||
sources.push_back(se);
|
||||
destinations.clear();
|
||||
destinations.push_back(tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, miner_acc.get_public_address()));
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0);
|
||||
transaction tx_1{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
bool is_fully_signed = false;
|
||||
r = sign_multisig_input_in_tx(tx_1, 0, miner_acc.get_keys(), tx_0, &is_fully_signed);
|
||||
|
|
|
|||
|
|
@ -495,7 +495,8 @@ bool assets_and_explicit_native_coins_in_outs::generate(std::vector<test_event_e
|
|||
std::vector<tx_destination_entry> destinations;
|
||||
r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc, alice_acc, m_alice_initial_balance, TESTS_DEFAULT_FEE, 0, sources, destinations, true /* spends */, false /* unlock time */);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0);
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
ADD_CUSTOM_EVENT(events, tx_0);
|
||||
|
|
@ -701,7 +702,8 @@ bool asset_depoyment_and_few_zc_utxos::generate(std::vector<test_event_entry>& e
|
|||
m_alice_initial_balance = TESTS_DEFAULT_FEE * 100;
|
||||
r = fill_tx_sources(sources, events, blk_0r, miner_acc.get_keys(), m_alice_initial_balance + TESTS_DEFAULT_FEE, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources failed");
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0);
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
ADD_CUSTOM_EVENT(events, tx_0);
|
||||
|
|
@ -1017,16 +1019,10 @@ bool asset_operation_and_hardfork_checks::generate(
|
|||
|
||||
CHECK_AND_ASSERT_MES(success, false, "fail to fill sources, destinations");
|
||||
|
||||
tx_version = get_tx_version(get_block_height(blk_0r),
|
||||
m_hardforks);
|
||||
size_t tx_hardfork_id{};
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_0r), m_hardforks, tx_hardfork_id);
|
||||
|
||||
success = construct_tx(miner.get_keys(),
|
||||
sources,
|
||||
destinations,
|
||||
empty_attachment,
|
||||
tx_0,
|
||||
tx_version,
|
||||
0);
|
||||
success = construct_tx(miner.get_keys(), sources, destinations, empty_attachment, tx_0, tx_version, tx_hardfork_id, 0);
|
||||
|
||||
CHECK_AND_ASSERT_MES(success, false, "fail to construct tx_0");
|
||||
|
||||
|
|
@ -1058,7 +1054,7 @@ bool asset_operation_and_hardfork_checks::generate(
|
|||
/* to = */ alice.get_public_address(),
|
||||
/* asset_id = */ currency::null_pkey);
|
||||
|
||||
tx_version = get_tx_version(get_block_height(blk_1r), m_hardforks);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_1r), m_hardforks, tx_hardfork_id);
|
||||
size_t hf_n = m_hardforks.get_the_most_recent_hardfork_id_for_height(get_block_height(blk_1r));
|
||||
fill_ado_version_based_onhardfork(m_ado_hello, hf_n);
|
||||
fill_adb_version_based_onhardfork(*m_ado_hello.opt_descriptor, hf_n);
|
||||
|
|
@ -1069,6 +1065,7 @@ bool asset_operation_and_hardfork_checks::generate(
|
|||
empty_attachment,
|
||||
tx_1,
|
||||
tx_version,
|
||||
tx_hardfork_id,
|
||||
stub,
|
||||
0);
|
||||
|
||||
|
|
@ -1105,8 +1102,7 @@ bool asset_operation_and_hardfork_checks::generate(
|
|||
|
||||
CHECK_AND_ASSERT_MES(success, false, "fail to fill sources, destinations");
|
||||
|
||||
tx_version = get_tx_version(get_block_height(blk_2r),
|
||||
m_hardforks);
|
||||
tx_version = get_tx_version_and_hardfork_id(get_block_height(blk_2r), m_hardforks, tx_hardfork_id);
|
||||
|
||||
hf_n = m_hardforks.get_the_most_recent_hardfork_id_for_height(get_block_height(blk_2r));
|
||||
fill_ado_version_based_onhardfork(m_ado_hello, hf_n);
|
||||
|
|
@ -1118,6 +1114,7 @@ bool asset_operation_and_hardfork_checks::generate(
|
|||
empty_attachment,
|
||||
tx_2,
|
||||
tx_version,
|
||||
tx_hardfork_id,
|
||||
stub,
|
||||
0);
|
||||
|
||||
|
|
@ -1159,6 +1156,7 @@ bool asset_operation_and_hardfork_checks::generate(
|
|||
/* attachments = */ {m_ado_bye},
|
||||
tx_3,
|
||||
tx_version,
|
||||
hf_n,
|
||||
0);
|
||||
|
||||
CHECK_AND_ASSERT_MES(success, false, "fail to construct tx_3");
|
||||
|
|
@ -1199,6 +1197,7 @@ bool asset_operation_and_hardfork_checks::generate(
|
|||
/* attachments = */ {m_ado_bye},
|
||||
tx_4,
|
||||
tx_version,
|
||||
hf_n,
|
||||
stub,
|
||||
0);
|
||||
|
||||
|
|
@ -2083,6 +2082,7 @@ bool asset_current_and_total_supplies_comparative_constraints::generate(std::vec
|
|||
GENERATE_ACCOUNT(miner);
|
||||
GENERATE_ACCOUNT(alice);
|
||||
transaction tx_0{}, tx_1{}, tx_2{}, tx_3{}, tx_4{};
|
||||
size_t tx_hardfork_id{};
|
||||
|
||||
m_accounts.push_back(miner);
|
||||
m_accounts.push_back(alice);
|
||||
|
|
@ -2106,7 +2106,7 @@ bool asset_current_and_total_supplies_comparative_constraints::generate(std::vec
|
|||
|
||||
success = fill_tx_sources_and_destinations(events, top, miner.get_keys(), alice.get_public_address(), MK_TEST_COINS(8), TESTS_DEFAULT_FEE, 0, sources, destinations);
|
||||
CHECK_AND_ASSERT_EQ(success, true);
|
||||
success = construct_tx(miner.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version(get_block_height(top), m_hardforks), 0);
|
||||
success = construct_tx(miner.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_and_hardfork_id(get_block_height(top), m_hardforks, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_EQ(success, true);
|
||||
}
|
||||
|
||||
|
|
@ -2130,7 +2130,7 @@ bool asset_current_and_total_supplies_comparative_constraints::generate(std::vec
|
|||
destinations.emplace_back(ado.opt_descriptor->current_supply, alice.get_public_address(), null_pkey);
|
||||
CHECK_AND_ASSERT_EQ(ado.opt_descriptor->total_max_supply, 0);
|
||||
CHECK_AND_ASSERT_EQ(ado.opt_descriptor->total_max_supply, ado.opt_descriptor->current_supply);
|
||||
success = construct_tx(alice.get_keys(), sources, destinations, {ado}, empty_attachment, tx_1, get_tx_version(get_block_height(top), m_hardforks), one_time, 0);
|
||||
success = construct_tx(alice.get_keys(), sources, destinations, {ado}, empty_attachment, tx_1, get_tx_version_and_hardfork_id(get_block_height(top), m_hardforks, tx_hardfork_id), tx_hardfork_id, one_time, 0);
|
||||
CHECK_AND_ASSERT_EQ(success, true);
|
||||
}
|
||||
|
||||
|
|
@ -2155,7 +2155,7 @@ bool asset_current_and_total_supplies_comparative_constraints::generate(std::vec
|
|||
CHECK_AND_ASSERT_EQ(success, true);
|
||||
destinations.emplace_back(ado.opt_descriptor->current_supply, alice.get_public_address(), null_pkey);
|
||||
CHECK_AND_ASSERT_MES(ado.opt_descriptor->current_supply > ado.opt_descriptor->total_max_supply, false, "current_supply <= total_max_supply");
|
||||
success = construct_tx(alice.get_keys(), sources, destinations, {ado}, empty_attachment, tx_2, get_tx_version(get_block_height(top), m_hardforks), one_time, 0);
|
||||
success = construct_tx(alice.get_keys(), sources, destinations, {ado}, empty_attachment, tx_2, get_tx_version_and_hardfork_id(get_block_height(top), m_hardforks, tx_hardfork_id), tx_hardfork_id, one_time, 0);
|
||||
CHECK_AND_ASSERT_EQ(success, true);
|
||||
}
|
||||
|
||||
|
|
@ -2180,7 +2180,7 @@ bool asset_current_and_total_supplies_comparative_constraints::generate(std::vec
|
|||
CHECK_AND_ASSERT_EQ(success, true);
|
||||
destinations.emplace_back(ado.opt_descriptor->current_supply, alice.get_public_address(), null_pkey);
|
||||
CHECK_AND_ASSERT(ado.opt_descriptor->current_supply <= ado.opt_descriptor->total_max_supply, false);
|
||||
success = construct_tx(alice.get_keys(), sources, destinations, {ado}, empty_attachment, tx_3, get_tx_version(get_block_height(top), m_hardforks), one_time, 0);
|
||||
success = construct_tx(alice.get_keys(), sources, destinations, {ado}, empty_attachment, tx_3, get_tx_version_and_hardfork_id(get_block_height(top), m_hardforks, tx_hardfork_id), tx_hardfork_id, one_time, 0);
|
||||
CHECK_AND_ASSERT_EQ(success, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -880,7 +880,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc.get_keys(), ms_addr_list, amount, TESTS_DEFAULT_FEE, 0, sources, destinations, true, true, 4);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx = AUTO_VAL_INIT(tx);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r == false, false, "construct_tx was expected to fail, but successed");
|
||||
|
||||
|
||||
|
|
@ -893,7 +893,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_1);
|
||||
|
||||
|
|
@ -917,7 +917,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
|
||||
// Transaction should be successfully created, but rejected by the core
|
||||
transaction tx_2 = AUTO_VAL_INIT(tx_2);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ de }), empty_attachment, tx_2, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ de }), empty_attachment, tx_2, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
bool tx_fully_signed = false;
|
||||
r = sign_multisig_input_in_tx(tx_2, 0, bob_acc.get_keys(), tx_1, &tx_fully_signed);
|
||||
|
|
@ -947,7 +947,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
se.ms_sigs_count = 2;
|
||||
|
||||
transaction tx_3 = AUTO_VAL_INIT(tx_3);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, bob_acc.get_public_address()) }), empty_attachment, tx_3, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, bob_acc.get_public_address()) }), empty_attachment, tx_3, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
r = sign_multisig_input_in_tx(tx_3, 0, bob_acc.get_keys(), tx_1, &tx_fully_signed);
|
||||
CHECK_AND_ASSERT_MES(r && !tx_fully_signed, false, "sign_multisig_input_in_tx failed, tx_fully_signed : " << tx_fully_signed);
|
||||
|
|
@ -966,7 +966,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
|
||||
transaction tx_4 = AUTO_VAL_INIT(tx_4);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_4, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_4, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_4);
|
||||
|
||||
|
|
@ -984,7 +984,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
se.ms_sigs_count = 3;
|
||||
|
||||
transaction tx_5 = AUTO_VAL_INIT(tx_5);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, alice_acc.get_public_address()) }), empty_attachment, tx_5, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, alice_acc.get_public_address()) }), empty_attachment, tx_5, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
// use sign_multisig_input_in_tx_custom to create tx with more signatures (3) than minimum_sigs (1)
|
||||
|
|
@ -1009,7 +1009,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
|
||||
transaction tx_6 = AUTO_VAL_INIT(tx_6);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_6, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_6, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_6);
|
||||
|
||||
|
|
@ -1028,7 +1028,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
se.ms_sigs_count = 4;
|
||||
|
||||
transaction tx_7 = AUTO_VAL_INIT(tx_7);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, alice_acc.get_public_address()) }), empty_attachment, tx_7, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, alice_acc.get_public_address()) }), empty_attachment, tx_7, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
// use sign_multisig_input_in_tx_custom to create tx with more signatures (4) than minimum_sigs (1)
|
||||
|
|
@ -1051,7 +1051,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
|
||||
transaction tx_8 = AUTO_VAL_INIT(tx_8);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_8, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_8, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_8);
|
||||
|
||||
|
|
@ -1071,7 +1071,7 @@ bool multisig_minimum_sigs::generate(std::vector<test_event_entry>& events) cons
|
|||
se.ms_sigs_count = redundant_keys_count;
|
||||
|
||||
transaction tx_9 = AUTO_VAL_INIT(tx_9);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, alice_acc.get_public_address()) }), empty_attachment, tx_9, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, alice_acc.get_public_address()) }), empty_attachment, tx_9, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
boost::get<currency::NLSAG_sig>(tx_9.signatures[0]).s.resize(redundant_keys_count, invalid_signature);
|
||||
|
|
@ -1202,7 +1202,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, get_tx_version_from_events(events), 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), 0, 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);
|
||||
|
|
@ -1232,7 +1232,7 @@ bool multisig_and_unlock_time::generate(std::vector<test_event_entry>& events) c
|
|||
// tx_2 should be created ok, but rejected by the core, as one of input refers to a locked tx
|
||||
// Note: tx_2 has unlock_time_2 specified
|
||||
transaction tx_2 = AUTO_VAL_INIT(tx_2);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_2, get_tx_version_from_events(events), unlock_time_2, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_2, get_tx_version_from_events(events), 0, unlock_time_2, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
bool tx_fully_signed = false;
|
||||
|
|
@ -1256,7 +1256,7 @@ bool multisig_and_unlock_time::generate(std::vector<test_event_entry>& events) c
|
|||
r = fill_tx_sources_and_destinations(events, blk_2, alice_acc, bob_acc, amount - TESTS_DEFAULT_FEE * 2, TESTS_DEFAULT_FEE, 0 /*nmix*/, sources, destinations, true, false /* check_for_unlocktime */);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_3{};
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3, get_tx_version_from_events(events), 0, 0 /* unlock time */, 0 /* mix attib */);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
ADD_CUSTOM_EVENT(events, tx_3);
|
||||
|
||||
|
|
@ -1281,7 +1281,7 @@ bool multisig_and_unlock_time::generate(std::vector<test_event_entry>& events) c
|
|||
crypto::secret_key stub_key = AUTO_VAL_INIT(stub_key);
|
||||
etc_tx_details_expiration_time extra_expiration_time = AUTO_VAL_INIT(extra_expiration_time);
|
||||
extra_expiration_time.v = expiration_time;
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<extra_v>({ extra_expiration_time }), empty_attachment, tx_4, get_tx_version_from_events(events), stub_key, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<extra_v>({ extra_expiration_time }), empty_attachment, tx_4, get_tx_version_from_events(events), 0, stub_key, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
CHECK_AND_ASSERT_MES(get_tx_expiration_time(tx_4) == expiration_time, false, "Expiration time was not correctly set");
|
||||
DO_CALLBACK(events, "mark_invalid_tx");
|
||||
|
|
@ -1289,7 +1289,7 @@ bool multisig_and_unlock_time::generate(std::vector<test_event_entry>& events) c
|
|||
|
||||
// add similar tx (same sources and destinations) with no expiration_time - should be accepted by the core
|
||||
transaction tx_5 = AUTO_VAL_INIT(tx_5);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_extra, empty_attachment, tx_5, get_tx_version_from_events(events), stub_key, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_extra, empty_attachment, tx_5, get_tx_version_from_events(events), 0, stub_key, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_5);
|
||||
|
||||
|
|
@ -1316,7 +1316,7 @@ bool multisig_and_unlock_time::generate(std::vector<test_event_entry>& events) c
|
|||
extra_expiration_time = AUTO_VAL_INIT(extra_expiration_time);
|
||||
extra_expiration_time.v = expiration_time;
|
||||
transaction tx_6 = AUTO_VAL_INIT(tx_6);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<extra_v>({ extra_expiration_time }), empty_attachment, tx_6, get_tx_version_from_events(events), stub_key, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<extra_v>({ extra_expiration_time }), empty_attachment, tx_6, get_tx_version_from_events(events), 0, stub_key, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
CHECK_AND_ASSERT_MES(get_tx_expiration_time(tx_6) == expiration_time, false, "Expiration time was not correctly set");
|
||||
r = sign_multisig_input_in_tx(tx_6, tx_5_ms_out_idx, miner_acc.get_keys(), tx_5, &tx_fully_signed);
|
||||
|
|
@ -1429,7 +1429,7 @@ bool multisig_and_coinbase::generate(std::vector<test_event_entry>& events) cons
|
|||
destinations.assign({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, bob_acc.get_public_address()) });
|
||||
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
bool fully_signed_tx = false;
|
||||
r = sign_multisig_input_in_tx(tx_1, 0, alice_acc.get_keys(), blk_1.miner_tx, &fully_signed_tx);
|
||||
|
|
@ -1459,7 +1459,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, get_tx_version_from_events(events), 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), 0, 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
|
||||
|
|
@ -1477,7 +1477,7 @@ bool multisig_and_coinbase::generate(std::vector<test_event_entry>& events) cons
|
|||
r = generator.construct_block_manually(b, prev_block, miner_acc, test_generator::bf_miner_tx, 0, 0, 0, null_hash, 1, miner_tx);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_block_manually failed");
|
||||
}
|
||||
events.push_back(blk_3);
|
||||
ADD_CUSTOM_EVENT(events, blk_3);
|
||||
|
||||
// rewind blocks to be able to spend mined money
|
||||
REWIND_BLOCKS_N(events, blk_3r, blk_3, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
|
@ -1493,7 +1493,7 @@ bool multisig_and_coinbase::generate(std::vector<test_event_entry>& events) cons
|
|||
|
||||
transaction tx_2 = AUTO_VAL_INIT(tx_2);
|
||||
r = construct_tx(alice_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ tx_destination_entry(se.amount - TESTS_DEFAULT_FEE, alice_acc.get_public_address()) }),
|
||||
empty_attachment, tx_2, get_tx_version_from_events(events), 0);
|
||||
empty_attachment, tx_2, get_tx_version_from_events(events), 0, 0);
|
||||
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
r = sign_multisig_input_in_tx(tx_2, 0, alice_acc.get_keys(), blk_3.miner_tx, &fully_signed_tx);
|
||||
|
|
@ -1638,7 +1638,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, "fda3e645fbfd0f4852aa68e6ad021c9005c9faf2d7ba6b1b3c8e24efb9c0e8d0");
|
||||
checkpoints.add_checkpoint(15, "a78fa870608991aa773d5d5aaf684ac77fea30c3e103b00d3c05c15912215c31");
|
||||
c.set_checkpoints(std::move(checkpoints));
|
||||
|
||||
return true;
|
||||
|
|
@ -2259,7 +2259,7 @@ bool multisig_n_participants_seq_signing::generate(std::vector<test_event_entry>
|
|||
r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc.get_keys(), ms_addr_list, ms_amount, TESTS_DEFAULT_FEE, 0, sources, destinations, true, true, m_minimum_signs_to_spend);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0, 0);
|
||||
events.push_back(tx_1);
|
||||
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_1, blk_0r, miner_acc, tx_1);
|
||||
|
|
@ -2289,7 +2289,7 @@ bool multisig_n_participants_seq_signing::generate(std::vector<test_event_entry>
|
|||
|
||||
// construct a transaction (no participants keys are provided, thus no signs for ms input are created)
|
||||
transaction tx = AUTO_VAL_INIT(tx);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
// sign the transaction by (m_minimum_signs_to_spend) participants in random order
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ bool offer_removing_and_selected_output::generate(std::vector<test_event_entry>&
|
|||
std::vector<tx_source_entry> sources;
|
||||
r = fill_tx_sources(sources, events, blk_0r, miner_acc.get_keys(), destinations_amount + TESTS_DEFAULT_FEE, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources failed");
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_0);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_1, blk_0r, miner_acc, tx_0);
|
||||
|
|
|
|||
|
|
@ -174,7 +174,8 @@ bool pos_mining_with_decoys::generate(std::vector<test_event_entry>& events) con
|
|||
destinations.emplace_back(COIN, carol_acc.get_public_address());
|
||||
|
||||
transaction tx_0{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0);
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_0);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_1, blk_0r, miner_acc, tx_0);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ void pos_block_builder::step1_init_header(const hard_forks_descriptor& hardforks
|
|||
m_height = block_height;
|
||||
|
||||
m_context.zarcanum = hardforks.is_hardfork_active_for_height(ZANO_HARDFORK_04_ZARCANUM, m_height);
|
||||
m_miner_tx_version = get_tx_version_and_hardfork_id(m_height, hardforks, m_miner_tx_hardfork_id);
|
||||
|
||||
m_step = 1;
|
||||
}
|
||||
|
|
@ -160,7 +161,6 @@ void pos_block_builder::step4_generate_coinbase_tx(size_t median_size,
|
|||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(m_step == 3, "pos_block_builder: incorrect step sequence");
|
||||
|
||||
uint64_t tx_version = m_context.zarcanum ? TRANSACTION_VERSION_POST_HF4 : TRANSACTION_VERSION_PRE_HF4;
|
||||
pos_entry pe{};
|
||||
pe.stake_unlock_time = 0; // TODO
|
||||
pe.amount = m_context.stake_amount;
|
||||
|
|
@ -171,7 +171,8 @@ void pos_block_builder::step4_generate_coinbase_tx(size_t median_size,
|
|||
size_t estimated_block_size = m_txs_total_size;
|
||||
m_block.miner_tx = transaction{};
|
||||
bool r = construct_miner_tx(m_height, median_size, already_generated_coins, estimated_block_size, m_total_fee,
|
||||
reward_receiver_address, stakeholder_address, m_block.miner_tx, block_reward_without_fee, m_block_reward, tx_version, extra_nonce, max_outs, true, pe, &m_miner_tx_tgc, tx_one_time_key_to_use);
|
||||
reward_receiver_address, stakeholder_address, m_block.miner_tx, block_reward_without_fee, m_block_reward, m_miner_tx_version, m_miner_tx_hardfork_id,
|
||||
extra_nonce, max_outs, true, pe, &m_miner_tx_tgc, tx_one_time_key_to_use);
|
||||
CHECK_AND_ASSERT_THROW_MES(r, "construct_miner_tx failed");
|
||||
|
||||
estimated_block_size = m_txs_total_size + get_object_blobsize(m_block.miner_tx);
|
||||
|
|
@ -180,7 +181,8 @@ void pos_block_builder::step4_generate_coinbase_tx(size_t median_size,
|
|||
{
|
||||
m_block.miner_tx = transaction{};
|
||||
r = construct_miner_tx(m_height, median_size, already_generated_coins, estimated_block_size, m_total_fee,
|
||||
reward_receiver_address, stakeholder_address, m_block.miner_tx, block_reward_without_fee, m_block_reward, tx_version, extra_nonce, max_outs, true, pe, &m_miner_tx_tgc, tx_one_time_key_to_use);
|
||||
reward_receiver_address, stakeholder_address, m_block.miner_tx, block_reward_without_fee, m_block_reward, m_miner_tx_version, m_miner_tx_hardfork_id,
|
||||
extra_nonce, max_outs, true, pe, &m_miner_tx_tgc, tx_one_time_key_to_use);
|
||||
CHECK_AND_ASSERT_THROW_MES(r, "construct_homemade_pos_miner_tx failed");
|
||||
|
||||
cumulative_size = m_txs_total_size + get_object_blobsize(m_block.miner_tx);
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ struct pos_block_builder
|
|||
uint64_t m_total_fee = 0;
|
||||
//currency::stake_kernel m_stake_kernel {};
|
||||
size_t m_height = 0;
|
||||
size_t m_miner_tx_hardfork_id = 0;
|
||||
uint64_t m_miner_tx_version = 0;
|
||||
size_t m_pos_stake_output_gindex = 0;
|
||||
uint64_t m_block_reward = 0;
|
||||
currency::tx_generation_context m_miner_tx_tgc {};
|
||||
|
|
|
|||
|
|
@ -42,17 +42,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, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4);
|
||||
construct_miner_tx(0, 0, 0, 10, 0, miner_acc1.get_keys().account_address, miner_acc1.get_keys().account_address, tx_mine_1, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0);
|
||||
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, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc2.get_keys().account_address, miner_acc2.get_keys().account_address, tx_mine_2, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0);
|
||||
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, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc3.get_keys().account_address, miner_acc3.get_keys().account_address, tx_mine_3, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0);
|
||||
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, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc4.get_keys().account_address, miner_acc4.get_keys().account_address, tx_mine_4, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0);
|
||||
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, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc5.get_keys().account_address, miner_acc5.get_keys().account_address, tx_mine_5, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0);
|
||||
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, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4);
|
||||
construct_miner_tx(0, 0, 0, 0, 0, miner_acc6.get_keys().account_address, miner_acc6.get_keys().account_address, tx_mine_6, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0);
|
||||
|
||||
//fill inputs entry
|
||||
typedef tx_source_entry::output_entry tx_output_entry;
|
||||
|
|
@ -101,7 +101,7 @@ bool test_transaction_generation_and_ring_signature()
|
|||
|
||||
transaction tx_rc1;
|
||||
std::vector<currency::attachment_v> attachments;
|
||||
bool r = construct_tx(miner_acc2.get_keys(), sources, destinations, attachments, tx_rc1, get_tx_version(0, hf), 0);
|
||||
bool r = construct_tx(miner_acc2.get_keys(), sources, destinations, attachments, tx_rc1, get_tx_version(0, hf), 0, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to construct transaction");
|
||||
|
||||
crypto::hash pref_hash = get_transaction_prefix_hash(tx_rc1);
|
||||
|
|
@ -139,7 +139,7 @@ bool test_block_creation()
|
|||
uint64_t block_reward_without_fee = 0;
|
||||
uint64_t block_reward = 0;
|
||||
block b;
|
||||
r = construct_miner_tx(90, epee::misc_utils::median(szs), 3553616528562147, 33094, 10000000, adr, adr, b.miner_tx, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4);
|
||||
r = construct_miner_tx(90, epee::misc_utils::median(szs), 3553616528562147, 33094, 10000000, adr, adr, b.miner_tx, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1239,8 +1239,9 @@ bool tx_expiration_time::generate(std::vector<test_event_entry>& events) const
|
|||
std::vector<tx_destination_entry> destinations;
|
||||
r = fill_tx_sources_and_destinations(events, blk_2, alice_acc.get_keys(), bob_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_2 = AUTO_VAL_INIT(tx_2);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_2, get_tx_version_from_events(events), 0);
|
||||
transaction tx_2{};
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_2, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
set_tx_expiration_time(tx_2, ts_median + TX_EXPIRATION_MEDIAN_SHIFT + 1); // one second greather than minimum allowed
|
||||
r = resign_tx(alice_acc.get_keys(), sources, tx_2);
|
||||
|
|
@ -1258,7 +1259,7 @@ bool tx_expiration_time::generate(std::vector<test_event_entry>& events) const
|
|||
r = fill_tx_sources_and_destinations(events, blk_3, alice_acc.get_keys(), bob_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_3 = AUTO_VAL_INIT(tx_3);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3, get_tx_version_from_events(events), 0);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
set_tx_expiration_time(tx_3, ts_median + TX_EXPIRATION_MEDIAN_SHIFT + 0); // exact expiration time, should not pass (see core condition above)
|
||||
r = resign_tx(alice_acc.get_keys(), sources, tx_3);
|
||||
|
|
@ -1322,8 +1323,9 @@ bool tx_expiration_time_and_block_template::generate(std::vector<test_event_entr
|
|||
std::vector<tx_destination_entry> destinations;
|
||||
bool r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc.get_keys(), miner_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_from_events(events), 0);
|
||||
transaction tx_1{};
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
uint64_t tx_1_expiration_time = ts_median + TX_EXPIRATION_MEDIAN_SHIFT + 1; // one second greather than minimum allowed
|
||||
set_tx_expiration_time(tx_1, tx_1_expiration_time);
|
||||
|
|
@ -1394,8 +1396,9 @@ bool tx_expiration_time_and_chain_switching::generate(std::vector<test_event_ent
|
|||
std::vector<tx_destination_entry> destinations;
|
||||
r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc.get_keys(), miner_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_0 = AUTO_VAL_INIT(tx_0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0);
|
||||
transaction tx_0{};
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
uint64_t tx_0_expiration_time = ts_median + TX_EXPIRATION_MEDIAN_SHIFT + 0; // one second less than minimum allowed (see condition above)
|
||||
set_tx_expiration_time(tx_0, tx_0_expiration_time);
|
||||
|
|
@ -1515,8 +1518,9 @@ bool tx_key_image_pool_conflict::generate(std::vector<test_event_entry>& events)
|
|||
std::vector<tx_destination_entry> destinations;
|
||||
r = fill_tx_sources_and_destinations(events, blk_0r, m_miner_acc.get_keys(), bob_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_0 = AUTO_VAL_INIT(tx_0);
|
||||
r = construct_tx(m_miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_from_events(events), 0);
|
||||
transaction tx_0{};
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(m_miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
LOG_PRINT_YELLOW("tx_0 = " << get_transaction_hash(tx_0), LOG_LEVEL_0);
|
||||
// do not push tx_0 into events yet
|
||||
|
|
@ -1643,15 +1647,18 @@ bool tx_version_against_hardfork::generate(std::vector<test_event_entry>& events
|
|||
// tx_1 tx_1 is accepted
|
||||
|
||||
uint64_t tx_version_good = 0, tx_version_bad = 0;
|
||||
size_t tx_hardfork_id = 0;
|
||||
|
||||
// select good and bad tx versions based on active hardfork
|
||||
size_t most_recent_hardfork_id = m_hardforks.get_the_most_recent_hardfork_id_for_height(get_block_height(blk_0r));
|
||||
switch(most_recent_hardfork_id)
|
||||
{
|
||||
case ZANO_HARDFORK_04_ZARCANUM:
|
||||
tx_hardfork_id = 0;
|
||||
case ZANO_HARDFORK_05:
|
||||
tx_version_good = TRANSACTION_VERSION_POST_HF4;
|
||||
tx_version_bad = TRANSACTION_VERSION_PRE_HF4;
|
||||
tx_hardfork_id = ZANO_HARDFORK_05;
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("hardfork " << most_recent_hardfork_id << " is not supported by this test");
|
||||
|
|
@ -1667,7 +1674,7 @@ bool tx_version_against_hardfork::generate(std::vector<test_event_entry>& events
|
|||
r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc.get_keys(), miner_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_0{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, tx_version_good, 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, tx_version_good, tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
events.push_back(tx_0);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_1, blk_0r, miner_acc, tx_0);
|
||||
|
|
@ -1681,7 +1688,7 @@ bool tx_version_against_hardfork::generate(std::vector<test_event_entry>& events
|
|||
r = fill_tx_sources_and_destinations(events, blk_0, miner_acc.get_keys(), miner_acc.get_public_address(), MK_TEST_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_1{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, tx_version_bad, 0);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_0, tx_version_bad, tx_hardfork_id, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
// check tx pool rejection
|
||||
DO_CALLBACK(events, "mark_invalid_tx");
|
||||
|
|
|
|||
|
|
@ -1661,7 +1661,9 @@ bool gen_wallet_alias_and_unconfirmed_txs::generate(std::vector<test_event_entry
|
|||
d.flags |= tx_destination_entry_flags::tdef_explicit_native_asset_id | tx_destination_entry_flags::tdef_zero_amount_blinding_mask;
|
||||
transaction tx_alice_alias{};
|
||||
crypto::secret_key sk{};
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<currency::extra_v>({ ai }), empty_attachment, tx_alice_alias, get_tx_version_from_events(events), sk, 0);
|
||||
size_t tx_hardfork_id{};
|
||||
uint64_t tx_version = get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, std::vector<currency::extra_v>({ ai }), empty_attachment, tx_alice_alias, tx_version, tx_hardfork_id, sk, 0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
ADD_CUSTOM_EVENT(events, tx_alice_alias);
|
||||
|
||||
|
|
@ -2306,7 +2308,7 @@ bool generate_oversized_offer(size_t min_size, size_t max_size, bc_services::off
|
|||
// construct fake tx to estimate it's size
|
||||
transaction tx = AUTO_VAL_INIT(tx);
|
||||
crypto::secret_key one_time_secret_key;
|
||||
if (!construct_tx(account_keys(), std::vector<tx_source_entry>(), std::vector<tx_destination_entry>(), empty_extra, att_container, tx, tx_version, one_time_secret_key, 0, 0, true, 0))
|
||||
if (!construct_tx(account_keys(), std::vector<tx_source_entry>(), std::vector<tx_destination_entry>(), empty_extra, att_container, tx, tx_version, 0, one_time_secret_key, 0, 0, true, 0))
|
||||
return false;
|
||||
|
||||
size_t sz = get_object_blobsize(tx);
|
||||
|
|
|
|||
|
|
@ -520,7 +520,8 @@ bool zarcanum_txs_with_big_shuffled_decoy_set_shuffled::generate(std::vector<tes
|
|||
CHECK_AND_ASSERT_MES(shuffle_source_entries(sources), false, "shuffle_source_entries failed");
|
||||
|
||||
transaction tx_1_a{};
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_1_a, get_tx_version_from_events(events), 0 /* unlock time */);
|
||||
size_t tx_hardfork_id{};
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_1_a, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0 /* unlock time */);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
ADD_CUSTOM_EVENT(events, tx_1_a);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1r, miner_acc, tx_1_a);
|
||||
|
|
@ -532,7 +533,7 @@ bool zarcanum_txs_with_big_shuffled_decoy_set_shuffled::generate(std::vector<tes
|
|||
CHECK_AND_ASSERT_MES(fill_tx_sources_and_destinations(events, blk_2, alice_acc, miner_acc, alice_amount - TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, nmix, sources, destinations), false, "");
|
||||
CHECK_AND_ASSERT_MES(shuffle_source_entries(sources), false, "shuffle_source_entries failed");
|
||||
transaction tx_1_b{};
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_1_b, get_tx_version_from_events(events), 0 /* unlock time */);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_1_b, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0 /* unlock time */);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
ADD_CUSTOM_EVENT(events, tx_1_b);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_3, blk_2, miner_acc, tx_1_b);
|
||||
|
|
@ -571,7 +572,7 @@ bool zarcanum_txs_with_big_shuffled_decoy_set_shuffled::generate(std::vector<tes
|
|||
CHECK_AND_ASSERT_MES(fill_tx_sources_and_destinations(events, blk_5r, alice_acc, miner_acc, alice_amount - TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, nmix, sources, destinations), false, "");
|
||||
CHECK_AND_ASSERT_MES(shuffle_source_entries(sources), false, "shuffle_source_entries failed");
|
||||
transaction tx_3_a{};
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3_a, get_tx_version_from_events(events), 0 /* unlock time */);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3_a, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0 /* unlock time */);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
ADD_CUSTOM_EVENT(events, tx_3_a);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_6, blk_5r, miner_acc, tx_3_a);
|
||||
|
|
@ -583,7 +584,7 @@ bool zarcanum_txs_with_big_shuffled_decoy_set_shuffled::generate(std::vector<tes
|
|||
CHECK_AND_ASSERT_MES(fill_tx_sources_and_destinations(events, blk_6, alice_acc, miner_acc, alice_amount - TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, nmix, sources, destinations), false, "");
|
||||
CHECK_AND_ASSERT_MES(shuffle_source_entries(sources), false, "shuffle_source_entries failed");
|
||||
transaction tx_3_b{};
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3_b, get_tx_version_from_events(events), 0 /* unlock time */);
|
||||
r = construct_tx(alice_acc.get_keys(), sources, destinations, empty_attachment, tx_3_b, get_tx_version_and_harfork_id_from_events(events, tx_hardfork_id), tx_hardfork_id, 0 /* unlock time */);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
ADD_CUSTOM_EVENT(events, tx_3_b);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_7, blk_6, miner_acc, tx_3_b);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@ bool create_block_template_manually(const currency::block& prev_block, boost::mu
|
|||
result.miner_tx,
|
||||
block_reward_without_fee,
|
||||
block_reward,
|
||||
TRANSACTION_VERSION_PRE_HF4);
|
||||
TRANSACTION_VERSION_PRE_HF4,
|
||||
0);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_miner_tx failed");
|
||||
|
||||
size_t coinbase_size = get_object_blobsize(result.miner_tx);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
// SOFTWARE.
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstdint>
|
||||
using namespace std;
|
||||
|
||||
#ifndef KECCAKF_ROUNDS
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public:
|
|||
uint64_t block_reward_without_fee = 0;
|
||||
|
||||
uint64_t block_reward = 0;
|
||||
if(!construct_miner_tx(0, 0, 0, 2, 0, m_bob.get_keys().account_address, m_bob.get_keys().account_address, m_tx, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 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, block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0, blobdata(), CURRENCY_MINER_TX_MAX_OUTS))
|
||||
return false;
|
||||
m_tx_pub_key = get_tx_pub_key_from_extra(m_tx);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Copyright (c) 2014-2024 Zano Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
|
@ -16,7 +17,7 @@ TEST(parse_and_validate_tx_extra, is_correct_parse_and_validate_tx_extra)
|
|||
currency::blobdata b = "dsdsdfsdfsf";
|
||||
uint64_t block_reward_without_fee = 0, block_reward = 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,
|
||||
block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, b, 1);
|
||||
block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0, b, 1);
|
||||
ASSERT_TRUE(r);
|
||||
crypto::public_key tx_pub_key;
|
||||
r = currency::parse_and_validate_tx_extra(tx, tx_pub_key);
|
||||
|
|
@ -30,7 +31,7 @@ TEST(parse_and_validate_tx_extra, is_correct_extranonce_too_big)
|
|||
currency::blobdata b(260, 0);
|
||||
uint64_t block_reward_without_fee = 0, block_reward = 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,
|
||||
block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, b, 1);
|
||||
block_reward_without_fee, block_reward, TRANSACTION_VERSION_PRE_HF4, 0, b, 1);
|
||||
ASSERT_FALSE(r);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue