mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 00:37:43 +00:00
tests: fix some double spending tests
Some tests assume the first output in a transaction goes to the recipient. However, it can be the change. When it is, the recipient's keys will not recognize this output. To fix this, we send all we have, to ensure there is no change, and the first output goes to the recipient. I'm not sure why this worked with Cryptonote. The tests sent 17 coins, which seems way smaller than the first Bytecoin block reward, so there would have been change too. Maybe outputs were not shuffled originally.
This commit is contained in:
parent
2358d0d5be
commit
d0a8362b6b
1 changed files with 8 additions and 7 deletions
|
@ -32,13 +32,14 @@
|
||||||
#include "chaingen.h"
|
#include "chaingen.h"
|
||||||
|
|
||||||
const size_t invalid_index_value = std::numeric_limits<size_t>::max();
|
const size_t invalid_index_value = std::numeric_limits<size_t>::max();
|
||||||
|
const uint64_t FIRST_BLOCK_REWARD = 17592186044415;
|
||||||
|
|
||||||
|
|
||||||
template<class concrete_test>
|
template<class concrete_test>
|
||||||
class gen_double_spend_base : public test_chain_unit_base
|
class gen_double_spend_base : public test_chain_unit_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint64_t send_amount = MK_COINS(17);
|
static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE;
|
||||||
|
|
||||||
gen_double_spend_base();
|
gen_double_spend_base();
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ private:
|
||||||
template<bool txs_keeped_by_block>
|
template<bool txs_keeped_by_block>
|
||||||
struct gen_double_spend_in_tx : public gen_double_spend_base< gen_double_spend_in_tx<txs_keeped_by_block> >
|
struct gen_double_spend_in_tx : public gen_double_spend_base< gen_double_spend_in_tx<txs_keeped_by_block> >
|
||||||
{
|
{
|
||||||
static const uint64_t send_amount = MK_COINS(17);
|
static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE;
|
||||||
static const bool has_invalid_tx = true;
|
static const bool has_invalid_tx = true;
|
||||||
static const size_t expected_pool_txs_count = 0;
|
static const size_t expected_pool_txs_count = 0;
|
||||||
static const uint64_t expected_bob_balance = send_amount;
|
static const uint64_t expected_bob_balance = send_amount;
|
||||||
|
@ -73,7 +74,7 @@ struct gen_double_spend_in_tx : public gen_double_spend_base< gen_double_spend_i
|
||||||
template<bool txs_keeped_by_block>
|
template<bool txs_keeped_by_block>
|
||||||
struct gen_double_spend_in_the_same_block : public gen_double_spend_base< gen_double_spend_in_the_same_block<txs_keeped_by_block> >
|
struct gen_double_spend_in_the_same_block : public gen_double_spend_base< gen_double_spend_in_the_same_block<txs_keeped_by_block> >
|
||||||
{
|
{
|
||||||
static const uint64_t send_amount = MK_COINS(17);
|
static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE;
|
||||||
static const bool has_invalid_tx = !txs_keeped_by_block;
|
static const bool has_invalid_tx = !txs_keeped_by_block;
|
||||||
static const size_t expected_pool_txs_count = has_invalid_tx ? 1 : 2;
|
static const size_t expected_pool_txs_count = has_invalid_tx ? 1 : 2;
|
||||||
static const uint64_t expected_bob_balance = send_amount;
|
static const uint64_t expected_bob_balance = send_amount;
|
||||||
|
@ -86,7 +87,7 @@ struct gen_double_spend_in_the_same_block : public gen_double_spend_base< gen_do
|
||||||
template<bool txs_keeped_by_block>
|
template<bool txs_keeped_by_block>
|
||||||
struct gen_double_spend_in_different_blocks : public gen_double_spend_base< gen_double_spend_in_different_blocks<txs_keeped_by_block> >
|
struct gen_double_spend_in_different_blocks : public gen_double_spend_base< gen_double_spend_in_different_blocks<txs_keeped_by_block> >
|
||||||
{
|
{
|
||||||
static const uint64_t send_amount = MK_COINS(17);
|
static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE;
|
||||||
static const bool has_invalid_tx = !txs_keeped_by_block;
|
static const bool has_invalid_tx = !txs_keeped_by_block;
|
||||||
static const size_t expected_pool_txs_count = has_invalid_tx ? 0 : 1;
|
static const size_t expected_pool_txs_count = has_invalid_tx ? 0 : 1;
|
||||||
static const uint64_t expected_bob_balance = 0;
|
static const uint64_t expected_bob_balance = 0;
|
||||||
|
@ -99,7 +100,7 @@ struct gen_double_spend_in_different_blocks : public gen_double_spend_base< gen_
|
||||||
template<bool txs_keeped_by_block>
|
template<bool txs_keeped_by_block>
|
||||||
struct gen_double_spend_in_alt_chain_in_the_same_block : public gen_double_spend_base< gen_double_spend_in_alt_chain_in_the_same_block<txs_keeped_by_block> >
|
struct gen_double_spend_in_alt_chain_in_the_same_block : public gen_double_spend_base< gen_double_spend_in_alt_chain_in_the_same_block<txs_keeped_by_block> >
|
||||||
{
|
{
|
||||||
static const uint64_t send_amount = MK_COINS(17);
|
static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE;
|
||||||
static const bool has_invalid_tx = !txs_keeped_by_block;
|
static const bool has_invalid_tx = !txs_keeped_by_block;
|
||||||
static const size_t expected_pool_txs_count = has_invalid_tx ? 1 : 2;
|
static const size_t expected_pool_txs_count = has_invalid_tx ? 1 : 2;
|
||||||
static const uint64_t expected_bob_balance = send_amount;
|
static const uint64_t expected_bob_balance = send_amount;
|
||||||
|
@ -112,7 +113,7 @@ struct gen_double_spend_in_alt_chain_in_the_same_block : public gen_double_spend
|
||||||
template<bool txs_keeped_by_block>
|
template<bool txs_keeped_by_block>
|
||||||
struct gen_double_spend_in_alt_chain_in_different_blocks : public gen_double_spend_base< gen_double_spend_in_alt_chain_in_different_blocks<txs_keeped_by_block> >
|
struct gen_double_spend_in_alt_chain_in_different_blocks : public gen_double_spend_base< gen_double_spend_in_alt_chain_in_different_blocks<txs_keeped_by_block> >
|
||||||
{
|
{
|
||||||
static const uint64_t send_amount = MK_COINS(17);
|
static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE;
|
||||||
static const bool has_invalid_tx = !txs_keeped_by_block;
|
static const bool has_invalid_tx = !txs_keeped_by_block;
|
||||||
static const size_t expected_pool_txs_count = has_invalid_tx ? 1 : 2;
|
static const size_t expected_pool_txs_count = has_invalid_tx ? 1 : 2;
|
||||||
static const uint64_t expected_bob_balance = send_amount;
|
static const uint64_t expected_bob_balance = send_amount;
|
||||||
|
@ -125,7 +126,7 @@ struct gen_double_spend_in_alt_chain_in_different_blocks : public gen_double_spe
|
||||||
class gen_double_spend_in_different_chains : public test_chain_unit_base
|
class gen_double_spend_in_different_chains : public test_chain_unit_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint64_t send_amount = MK_COINS(17);
|
static const uint64_t send_amount = FIRST_BLOCK_REWARD - TESTS_DEFAULT_FEE;
|
||||||
static const size_t expected_blockchain_height = 4 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW;
|
static const size_t expected_blockchain_height = 4 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW;
|
||||||
|
|
||||||
gen_double_spend_in_different_chains();
|
gen_double_spend_in_different_chains();
|
||||||
|
|
Loading…
Reference in a new issue