1
0
Fork 0
forked from lthn/blockchain

coretests: zarcanum_pos_math added to the list, now it exposes a bug with PoS block validation

This commit is contained in:
sowle 2022-11-16 21:56:32 +01:00
parent a7198b3313
commit 93a1aacaca
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
2 changed files with 15 additions and 2 deletions

View file

@ -1082,6 +1082,7 @@ int main(int argc, char* argv[])
//GENERATE_AND_PLAY(zarcanum_test_n_inputs_validation);
GENERATE_AND_PLAY(zarcanum_gen_time_balance);
GENERATE_AND_PLAY(zarcanum_txs_with_big_shuffled_decoy_set_shuffled);
GENERATE_AND_PLAY(zarcanum_pos_block_math);
// GENERATE_AND_PLAY(gen_block_reward);
// END OF TESTS */

View file

@ -393,14 +393,26 @@ bool zarcanum_pos_block_math::generate(std::vector<test_event_entry>& events) co
blk_1_pos = pb.m_block;
}
//CHECK_AND_ASSERT_MES(blk_1_pos.miner_tx.signatures.size() == 1, false, "unexpected signatures size");
//zarcanum_sig& sig = boost::get<zarcanum_sig>(blk_1_pos.miner_tx.signatures[0]);
//sig.y0 = 0; // invalidate sig
generator.add_block_info(blk_1_pos, std::list<transaction>{});
ADD_CUSTOM_EVENT(events, blk_1_pos);
// make a PoS block and than change its nonce, so its hash also changes
// this block should fail
std::list<currency::account_base> miner_stake_sources( {miner_acc} );
MAKE_NEXT_POS_BLOCK(events, blk_2, blk_1_pos, miner_acc, miner_stake_sources);
generator.remove_block_info(blk_2);
events.pop_back();
blk_2.nonce = 0xc0ffee; // this will change block's hash
generator.add_block_info(blk_2, std::list<transaction>{});
DO_CALLBACK(events, "mark_invalid_block");
ADD_CUSTOM_EVENT(events, blk_2);
MAKE_NEXT_POS_BLOCK(events, blk_3, blk_2, miner_acc, miner_stake_sources);
MAKE_NEXT_POS_BLOCK(events, blk_4, blk_3, miner_acc, miner_stake_sources);
//MAKE_NEXT_POS_BLOCK(events, blk_3, blk_2, miner_acc, miner_stake_sources);
//MAKE_NEXT_POS_BLOCK(events, blk_4, blk_3, miner_acc, miner_stake_sources);
return true;
}