fix test case compile errors

This commit is contained in:
Javier Smooth
2015-05-10 16:36:15 -07:00
parent 2ea054d8f1
commit b4e3cfa771
4 changed files with 22 additions and 16 deletions
+5 -5
View File
@@ -45,7 +45,7 @@ namespace
for (size_t i = 0; i < new_block_count; ++i)
{
block blk_next;
difficulty_type diffic = next_difficulty(timestamps, cummulative_difficulties);
difficulty_type diffic = next_difficulty(timestamps, cummulative_difficulties, get_block_height(blk_prev)+1);
if (!generator.construct_block_manually(blk_next, blk_prev, miner_account,
test_generator::bf_timestamp | test_generator::bf_diffic, 0, 0, blk_prev.timestamp, crypto::hash(), diffic))
return false;
@@ -175,9 +175,9 @@ bool gen_block_invalid_nonce::generate(std::vector<test_event_entry>& events) co
return false;
// Create invalid nonce
difficulty_type diffic = next_difficulty(timestamps, commulative_difficulties);
assert(1 < diffic);
const block& blk_last = boost::get<block>(events.back());
difficulty_type diffic = next_difficulty(timestamps, commulative_difficulties, get_block_height(blk_last)+1);
assert(1 < diffic);
uint64_t timestamp = blk_last.timestamp;
block blk_3;
do
@@ -570,7 +570,7 @@ bool gen_block_invalid_binary_format::generate(std::vector<test_event_entry>& ev
do
{
blk_last = boost::get<block>(events.back());
diffic = next_difficulty(timestamps, cummulative_difficulties);
diffic = next_difficulty(timestamps, cummulative_difficulties, get_block_height(blk_last)+1);
if (!lift_up_difficulty(events, timestamps, cummulative_difficulties, generator, 1, blk_last, miner_account))
return false;
std::cout << "Block #" << events.size() << ", difficulty: " << diffic << std::endl;
@@ -585,7 +585,7 @@ bool gen_block_invalid_binary_format::generate(std::vector<test_event_entry>& ev
std::vector<crypto::hash> tx_hashes;
tx_hashes.push_back(get_transaction_hash(tx_0));
size_t txs_size = get_object_blobsize(tx_0);
diffic = next_difficulty(timestamps, cummulative_difficulties);
diffic = next_difficulty(timestamps, cummulative_difficulties, get_block_height(blk_last)+1);
if (!generator.construct_block_manually(blk_test, blk_last, miner_account,
test_generator::bf_diffic | test_generator::bf_timestamp | test_generator::bf_tx_hashes, 0, 0, blk_last.timestamp,
crypto::hash(), diffic, transaction(), tx_hashes, txs_size))
+5 -5
View File
@@ -94,11 +94,11 @@ uint64_t test_generator::get_already_generated_coins(const cryptonote::block& bl
return get_already_generated_coins(blk_hash);
}
void test_generator::add_block(const cryptonote::block& blk, size_t tsx_size, std::vector<size_t>& block_sizes, uint64_t already_generated_coins)
void test_generator::add_block(const cryptonote::block& blk, size_t tsx_size, std::vector<size_t>& block_sizes, uint64_t already_generated_coins, size_t height)
{
const size_t block_size = tsx_size + get_object_blobsize(blk.miner_tx);
uint64_t block_reward;
get_block_reward(misc_utils::median(block_sizes), block_size, already_generated_coins, block_reward);
get_block_reward(misc_utils::median(block_sizes), block_size, already_generated_coins, block_reward, height);
m_blocks_info[get_block_hash(blk)] = block_info(blk.prev_id, already_generated_coins + block_reward, block_size);
}
@@ -182,7 +182,7 @@ bool test_generator::construct_block(cryptonote::block& blk, uint64_t height, co
while (!miner::find_nonce_for_given_block(blk, get_test_difficulty(), height))
blk.timestamp++;
add_block(blk, txs_size, block_sizes, already_generated_coins);
add_block(blk, txs_size, block_sizes, already_generated_coins,height);
return true;
}
@@ -244,7 +244,7 @@ bool test_generator::construct_block_manually(block& blk, const block& prev_bloc
difficulty_type a_diffic = actual_params & bf_diffic ? diffic : get_test_difficulty();
fill_nonce(blk, a_diffic, height);
add_block(blk, txs_sizes, block_sizes, already_generated_coins);
add_block(blk, txs_sizes, block_sizes, already_generated_coins, height);
return true;
}
@@ -526,7 +526,7 @@ bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins
// This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
uint64_t block_reward;
if (!get_block_reward(0, 0, already_generated_coins, block_reward))
if (!get_block_reward(0, 0, already_generated_coins, block_reward, height))
{
LOG_PRINT_L0("Block is too big");
return false;
+1 -1
View File
@@ -228,7 +228,7 @@ public:
uint64_t get_already_generated_coins(const crypto::hash& blk_id) const;
uint64_t get_already_generated_coins(const cryptonote::block& blk) const;
void add_block(const cryptonote::block& blk, size_t tsx_size, std::vector<size_t>& block_sizes, uint64_t already_generated_coins);
void add_block(const cryptonote::block& blk, size_t tsx_size, std::vector<size_t>& block_sizes, uint64_t already_generated_coins, size_t height);
bool construct_block(cryptonote::block& blk, uint64_t height, const crypto::hash& prev_id,
const cryptonote::account_base& miner_acc, uint64_t timestamp, uint64_t already_generated_coins,
std::vector<size_t>& block_sizes, const std::list<cryptonote::transaction>& tx_list);
+11 -5
View File
@@ -46,8 +46,10 @@ namespace
uint64_t m_block_reward;
};
// block 100k is below any hard fork, TODO add tests above hard forks
#define TEST_ALREADY_GENERATED_COINS(already_generated_coins, expected_reward) \
m_block_not_too_big = get_block_reward(0, current_block_size, already_generated_coins, m_block_reward); \
m_block_not_too_big = get_block_reward(0, current_block_size, already_generated_coins, m_block_reward, 100000); \
ASSERT_TRUE(m_block_not_too_big); \
ASSERT_EQ(m_block_reward, UINT64_C(expected_reward));
@@ -78,14 +80,16 @@ namespace
protected:
virtual void SetUp()
{
m_block_not_too_big = get_block_reward(0, 0, already_generated_coins, m_standard_block_reward);
// block 100k is below any hard fork, TODO add tests above hard forks
m_block_not_too_big = get_block_reward(0, 0, already_generated_coins, m_standard_block_reward, 100000);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE, m_standard_block_reward);
}
void do_test(size_t median_block_size, size_t current_block_size)
{
m_block_not_too_big = get_block_reward(median_block_size, current_block_size, already_generated_coins, m_block_reward);
// block 100k is below any hard fork, TODO add tests above hard forks
m_block_not_too_big = get_block_reward(median_block_size, current_block_size, already_generated_coins, m_block_reward, 100000);
}
static const uint64_t already_generated_coins = 0;
@@ -167,14 +171,16 @@ namespace
m_last_block_sizes_median = 7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE;
m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), 0, already_generated_coins, m_standard_block_reward);
// block 100k is below any hard fork, TODO add tests above hard forks
m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), 0, already_generated_coins, m_standard_block_reward,100000);
ASSERT_TRUE(m_block_not_too_big);
ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE, m_standard_block_reward);
}
void do_test(size_t current_block_size)
{
m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), current_block_size, already_generated_coins, m_block_reward);
// block 100k is below any hard fork, TODO add tests above hard forks
m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), current_block_size, already_generated_coins, m_block_reward, 100000);
}
static const uint64_t already_generated_coins = 0;