diff options
author | Antonio Juarez <antonio.maria.juarez@live.com> | 2014-04-02 17:00:17 +0100 |
---|---|---|
committer | Antonio Juarez <antonio.maria.juarez@live.com> | 2014-04-02 17:00:17 +0100 |
commit | 29c2859a3e8a935ef605534c6c36333894980d50 (patch) | |
tree | 1d31daa09741cc82ecc24c0c89f15b84e74cb12d /tests/core_tests | |
parent | some fixes (diff) | |
download | monero-29c2859a3e8a935ef605534c6c36333894980d50.tar.xz |
json rpc for wallet and bugfix
Diffstat (limited to 'tests/core_tests')
-rw-r--r-- | tests/core_tests/block_reward.cpp | 2 | ||||
-rw-r--r-- | tests/core_tests/chaingen.cpp | 15 | ||||
-rw-r--r-- | tests/core_tests/transaction_tests.cpp | 18 |
3 files changed, 17 insertions, 18 deletions
diff --git a/tests/core_tests/block_reward.cpp b/tests/core_tests/block_reward.cpp index 14d181d75..7950738a6 100644 --- a/tests/core_tests/block_reward.cpp +++ b/tests/core_tests/block_reward.cpp @@ -16,7 +16,7 @@ namespace const account_public_address& miner_address, std::vector<size_t>& block_sizes, size_t target_tx_size, size_t target_block_size, uint64_t fee = 0) { - if (!construct_miner_tx(height, already_generated_coins, miner_address, miner_tx, fee, block_sizes, target_block_size)) + if (!construct_miner_tx(height, misc_utils::median(block_sizes), already_generated_coins, target_block_size, fee, miner_address, miner_tx)) return false; size_t current_size = get_object_blobsize(miner_tx); diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index c876e3a75..f00323518 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -71,8 +71,8 @@ uint64_t test_generator::get_already_generated_coins(const cryptonote::block& bl void test_generator::add_block(const cryptonote::block& blk, size_t tsx_size, std::vector<size_t>& block_sizes, uint64_t already_generated_coins) { const size_t block_size = tsx_size + get_object_blobsize(blk.miner_tx); - bool block_too_big; - uint64_t block_reward = get_block_reward(block_sizes, block_size, block_too_big, already_generated_coins); + uint64_t block_reward; + get_block_reward(misc_utils::median(block_sizes), block_size, already_generated_coins, block_reward); m_blocks_info[get_block_hash(blk)] = block_info(blk.prev_id, already_generated_coins + block_reward, block_size); } @@ -108,7 +108,7 @@ bool test_generator::construct_block(cryptonote::block& blk, uint64_t height, co size_t target_block_size = txs_size + get_object_blobsize(blk.miner_tx); while (true) { - if (!construct_miner_tx(height, already_generated_coins, miner_acc.get_keys().m_account_address, blk.miner_tx, total_fee, block_sizes, target_block_size, 10)) + if (!construct_miner_tx(height, misc_utils::median(block_sizes), already_generated_coins, target_block_size, total_fee, miner_acc.get_keys().m_account_address, blk.miner_tx, blobdata(), 10)) return false; size_t actual_block_size = txs_size + get_object_blobsize(blk.miner_tx); @@ -209,7 +209,7 @@ bool test_generator::construct_block_manually(block& blk, const block& prev_bloc { 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 CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE - if (!construct_miner_tx(height, already_generated_coins, miner_acc.get_keys().m_account_address, blk.miner_tx, 0, block_sizes, current_block_size, 1)) + if (!construct_miner_tx(height, misc_utils::median(block_sizes), already_generated_coins, current_block_size, 0, miner_acc.get_keys().m_account_address, blk.miner_tx, blobdata(), 1)) return false; } @@ -496,14 +496,13 @@ bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins tx.vin.push_back(in); // This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE - std::vector<size_t> block_sizes; - bool block_too_big = false; - uint64_t block_reward = get_block_reward(block_sizes, 0, block_too_big, already_generated_coins) + fee; - if (block_too_big) + uint64_t block_reward; + if (!get_block_reward(0, 0, already_generated_coins, block_reward)) { LOG_PRINT_L0("Block is too big"); return false; } + block_reward += fee; crypto::key_derivation derivation; crypto::public_key out_eph_public_key; diff --git a/tests/core_tests/transaction_tests.cpp b/tests/core_tests/transaction_tests.cpp index 4da9446cd..07e6661d8 100644 --- a/tests/core_tests/transaction_tests.cpp +++ b/tests/core_tests/transaction_tests.cpp @@ -7,6 +7,7 @@ #include "cryptonote_core/cryptonote_basic_impl.h" #include "cryptonote_core/account.h" #include "cryptonote_core/cryptonote_format_utils.h" +#include "misc_language.h" using namespace cryptonote; @@ -35,19 +36,18 @@ bool test_transaction_generation_and_ring_signature() rv_acc.generate(); account_base rv_acc2; rv_acc2.generate(); - std::vector<size_t> b; transaction tx_mine_1; - construct_miner_tx(0, 0, miner_acc1.get_keys().m_account_address, tx_mine_1, 0, b, 10); + construct_miner_tx(0, 0, 0, 10, 0, miner_acc1.get_keys().m_account_address, tx_mine_1); transaction tx_mine_2; - construct_miner_tx(0, 0, miner_acc2.get_keys().m_account_address, tx_mine_2, 0, b, 0); + construct_miner_tx(0, 0, 0, 0, 0, miner_acc2.get_keys().m_account_address, tx_mine_2); transaction tx_mine_3; - construct_miner_tx(0, 0, miner_acc3.get_keys().m_account_address, tx_mine_3, 0, b, 0); + construct_miner_tx(0, 0, 0, 0, 0, miner_acc3.get_keys().m_account_address, tx_mine_3); transaction tx_mine_4; - construct_miner_tx(0, 0, miner_acc4.get_keys().m_account_address, tx_mine_4, 0, b, 0); + construct_miner_tx(0, 0, 0, 0, 0, miner_acc4.get_keys().m_account_address, tx_mine_4); transaction tx_mine_5; - construct_miner_tx(0, 0, miner_acc5.get_keys().m_account_address, tx_mine_5, 0, b, 0); + construct_miner_tx(0, 0, 0, 0, 0, miner_acc5.get_keys().m_account_address, tx_mine_5); transaction tx_mine_6; - construct_miner_tx(0, 0, miner_acc6.get_keys().m_account_address, tx_mine_6, 0, b, 0); + construct_miner_tx(0, 0, 0, 0, 0, miner_acc6.get_keys().m_account_address, tx_mine_6); //fill inputs entry typedef tx_source_entry::output_entry tx_output_entry; @@ -111,7 +111,7 @@ bool test_transaction_generation_and_ring_signature() std::vector<size_t> outs; uint64_t money = 0; - + r = lookup_acc_outs(rv_acc.get_keys(), tx_rc1, get_tx_pub_key_from_extra(tx_rc1), outs, money); CHECK_AND_ASSERT_MES(r, false, "failed to lookup_acc_outs"); CHECK_AND_ASSERT_MES(td.amount == money, false, "wrong money amount in new transaction"); @@ -130,7 +130,7 @@ bool test_block_creation() bool r = get_account_address_from_str(adr, "0099be99c70ef10fd534c43c88e9d13d1c8853213df7e362afbec0e4ee6fec4948d0c190b58f4b356cd7feaf8d9d0a76e7c7e5a9a0a497a6b1faf7a765882dd08ac2"); CHECK_AND_ASSERT_MES(r, false, "failed to import"); block b; - r = construct_miner_tx(90, 3553616528562147, adr, b.miner_tx, 10000000, szs, 33094, 11); + r = construct_miner_tx(90, epee::misc_utils::median(szs), 3553616528562147, 33094, 10000000, adr, b.miner_tx, blobdata(), 11); return r; } |