1
0
Fork 0
forked from lthn/blockchain

initial coretests for auditability, work in progress

This commit is contained in:
sowle 2020-04-27 16:09:02 +03:00
parent 33d385db5f
commit 3a2fb378a4
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
4 changed files with 96 additions and 1 deletions

View file

@ -37,3 +37,4 @@
#include "hard_fork_1_consensus_test.h"
#include "hard_fork_1_bad_pos_source.h"
#include "hard_fork_1.h"
#include "hard_fork_2.h"

View file

@ -0,0 +1,72 @@
// Copyright (c) 2020 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_2.h"
//#include "pos_block_builder.h"
//#include "tx_builder.h"
//#include "random_helper.h"
using namespace currency;
//------------------------------------------------------------------------------
hard_fork_2_base_test::hard_fork_2_base_test(size_t hardfork_height)
: m_hardfork_height(hardfork_height)
{
REGISTER_CALLBACK_METHOD(hard_fork_2_base_test, configure_core);
}
bool hard_fork_2_base_test::configure_core(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
{
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
pc.min_coinstake_age = TESTS_POS_CONFIG_MIN_COINSTAKE_AGE;
pc.pos_minimum_heigh = TESTS_POS_CONFIG_POS_MINIMUM_HEIGH;
pc.hard_fork_01_starts_after_height = m_hardfork_height;
pc.hard_fork_02_starts_after_height = m_hardfork_height;
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;
}
//------------------------------------------------------------------------------
hard_fork_2_tx_payer_in_wallet::hard_fork_2_tx_payer_in_wallet()
: hard_fork_2_base_test(16)
{
REGISTER_CALLBACK_METHOD(hard_fork_2_tx_payer_in_wallet, c1); }
bool hard_fork_2_tx_payer_in_wallet::generate(std::vector<test_event_entry>& events) const
{
// Test idea: make sure that wallet uses tx_payer_old only before HF2 and tx_payer after
m_accounts.resize(TOTAL_ACCS_COUNT);
account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate();
account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate();
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 3);
DO_CALLBACK(events, "c1");
// REWIND_BLOCKS_N(events, blk_1r, blk_1, miner_acc, WALLET_DEFAULT_TX_SPENDABLE_AGE);
return true;
}
bool hard_fork_2_tx_payer_in_wallet::c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
{
bool r = false, stub_bool = false;
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 0, false, "Incorrect txs count in the pool: " << c.get_pool_transactions_count());
std::shared_ptr<tools::wallet2> miner_wlt = init_playtime_test_wallet(events, c, m_accounts[MINER_ACC_IDX]);
CHECK_AND_ASSERT_MES(refresh_wallet_and_check_balance("", "Miner", miner_wlt, COIN * (CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 3), true), false, "");
/*r = mine_next_pow_block_in_playtime(m_accounts[MINER_ACC_IDX].get_public_address(), c);
CHECK_AND_ASSERT_MES(r, false, "mine_next_pow_block_in_playtime failed");
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 0, false, "Incorrect txs count in the pool: " << c.get_pool_transactions_count());
*/
return true;
}

View file

@ -0,0 +1,22 @@
// Copyright (c) 2020 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_2_base_test : virtual public test_chain_unit_enchanced
{
hard_fork_2_base_test(size_t hardfork_height);
bool configure_core(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
size_t m_hardfork_height;
};
struct hard_fork_2_tx_payer_in_wallet : public hard_fork_2_base_test, public wallet_test
{
hard_fork_2_tx_payer_in_wallet();
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);
};

View file

@ -1434,7 +1434,7 @@ bool gen_wallet_decrypted_attachments::generate(std::vector<test_event_entry>& e
CREATE_TEST_WALLET(alice_wlt, alice_acc, blk_0);
REFRESH_TEST_WALLET_AT_GEN_TIME(events, alice_wlt, blk_0r, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
// these attachments will be use across all the transactions in this test
// these attachments will be used across all the transactions in this test
currency::tx_payer a_tx_payer = AUTO_VAL_INIT(a_tx_payer);
a_tx_payer.acc_addr = miner_acc.get_keys().account_address;
currency::tx_comment a_tx_comment = AUTO_VAL_INIT(a_tx_comment);