forked from lthn/blockchain
coretests: multiassets_basic_test improved to reflect recent changes with tx pool validation
This commit is contained in:
parent
754a29a709
commit
dd04d6367b
3 changed files with 89 additions and 6 deletions
|
|
@ -1,11 +1,9 @@
|
|||
// Copyright (c) 2014-2022 Zano Project
|
||||
// Copyright (c) 2014-2024 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#define USE_INSECURE_RANDOM_RPNG_ROUTINES // turns on pseudorandom number generator manupulations for tests
|
||||
|
||||
#include "chaingen.h"
|
||||
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2022 Zano Project
|
||||
// Copyright (c) 2014-2024 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -9,7 +9,8 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#define USE_INSECURE_RANDOM_RPNG_ROUTINES // turns on pseudorandom number generator manupulations for tests
|
||||
#define USE_INSECURE_RANDOM_RPNG_ROUTINES // turns on pseudorandom number generator manupulations for tests
|
||||
#define TX_POOL_USE_UNSECURE_TEST_FUNCTIONS // turns on special tests functions of tx pool
|
||||
|
||||
#include "currency_core/currency_basic.h"
|
||||
#include "currency_core/currency_core.h"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2023 Zano Project
|
||||
// Copyright (c) 2014-2024 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
|
@ -186,7 +186,20 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v
|
|||
CHECK_AND_ASSERT_MES(r, false, "Failed to get_asset_info");
|
||||
|
||||
asset_info.meta_info = "{\"some2\": \"info2\"}";
|
||||
r = false;
|
||||
try
|
||||
{
|
||||
miner_wlt->update_asset(asset_id, asset_info, tx);
|
||||
}
|
||||
catch(tools::error::tx_rejected&)
|
||||
{
|
||||
r = true;
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(r, false, "Test failed, broken ownership passed");
|
||||
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(true);
|
||||
miner_wlt->update_asset(asset_id, asset_info, tx);
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(false);
|
||||
r = mine_next_pow_blocks_in_playtime(miner_wlt->get_account().get_public_address(), c, 2);
|
||||
CHECK_AND_ASSERT_MES(!r, false, "Test failed, broken ownership passed");
|
||||
c.get_tx_pool().purge_transactions();
|
||||
|
|
@ -202,25 +215,54 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v
|
|||
CHECK_AND_ASSERT_MES(r, false, "Failed to get_asset_info");
|
||||
|
||||
asset_info.ticker = "XXX";
|
||||
r = false;
|
||||
try
|
||||
{
|
||||
miner_wlt->update_asset(asset_id, asset_info, tx);
|
||||
}
|
||||
catch(tools::error::tx_rejected&)
|
||||
{
|
||||
r = true;
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(r, false, "update_asset succeeded, but this shouldn't happened");
|
||||
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(true);
|
||||
miner_wlt->update_asset(asset_id, asset_info, tx);
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count());
|
||||
r = mine_next_pow_block_in_playtime(miner_wlt->get_account().get_public_address(), c);
|
||||
CHECK_AND_ASSERT_MES(!r, false, "block with a bad tx was unexpectedly mined");
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); // make sure tx was not confirmed
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(false);
|
||||
c.get_tx_pool().purge_transactions();
|
||||
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 0, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); // make sure tx was not added
|
||||
|
||||
|
||||
// check update_asset() with modified 'full_name'
|
||||
r = c.get_blockchain_storage().get_asset_info(asset_id, asset_info);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to get_asset_info");
|
||||
|
||||
asset_info.full_name = "XXX";
|
||||
r = false;
|
||||
try
|
||||
{
|
||||
miner_wlt->update_asset(asset_id, asset_info, tx);
|
||||
}
|
||||
catch(tools::error::tx_rejected&)
|
||||
{
|
||||
r = true;
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(r, false, "update_asset succeeded, but this shouldn't happened");
|
||||
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(true);
|
||||
miner_wlt->update_asset(asset_id, asset_info, tx);
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count());
|
||||
r = mine_next_pow_block_in_playtime(miner_wlt->get_account().get_public_address(), c);
|
||||
CHECK_AND_ASSERT_MES(!r, false, "block with a bad tx was unexpectedly mined");
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); // make sure tx was not confirmed
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(false);
|
||||
c.get_tx_pool().purge_transactions();
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 0, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); // make sure tx was not added
|
||||
miner_wlt->refresh();
|
||||
|
||||
|
||||
|
|
@ -229,13 +271,27 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v
|
|||
CHECK_AND_ASSERT_MES(r, false, "Failed to get_asset_info");
|
||||
|
||||
asset_info.decimal_point = 3;
|
||||
r = false;
|
||||
try
|
||||
{
|
||||
miner_wlt->update_asset(asset_id, asset_info, tx);
|
||||
}
|
||||
catch(tools::error::tx_rejected&)
|
||||
{
|
||||
r = true;
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(r, false, "update_asset succeeded, but this shouldn't happened");
|
||||
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(true);
|
||||
miner_wlt->update_asset(asset_id, asset_info, tx);
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count());
|
||||
r = mine_next_pow_block_in_playtime(miner_wlt->get_account().get_public_address(), c);
|
||||
CHECK_AND_ASSERT_MES(!r, false, "block with a bad tx was unexpectedly mined");
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); // make sure tx was not confirmed
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(false);
|
||||
c.get_tx_pool().purge_transactions();
|
||||
miner_wlt->refresh();
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 0, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); // make sure tx was not added
|
||||
|
||||
|
||||
// check update_asset() with modified 'owner'
|
||||
|
|
@ -258,14 +314,29 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v
|
|||
o.pado->descriptor.current_supply += 1000000;
|
||||
});
|
||||
//test emit function but re-adjust current_supply to wrong amount
|
||||
r = false;
|
||||
try
|
||||
{
|
||||
miner_wlt->emit_asset(asset_id, destinations, tx);
|
||||
}
|
||||
catch(tools::error::tx_rejected&)
|
||||
{
|
||||
r = true;
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(r, false, "emit_asset succeeded, but this shouldn't happened");
|
||||
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(true);
|
||||
miner_wlt->emit_asset(asset_id, destinations, tx);
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count());
|
||||
r = mine_next_pow_block_in_playtime(miner_wlt->get_account().get_public_address(), c);
|
||||
CHECK_AND_ASSERT_MES(!r, false, "block with a bad tx was unexpectedly mined");
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); // make sure tx was not confirmed
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(false);
|
||||
c.get_tx_pool().purge_transactions();
|
||||
miner_wlt->refresh();
|
||||
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 0, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); // make sure tx was not added
|
||||
|
||||
//------------------- tests that trying to break stuff -------------------
|
||||
//test burn that burns more than tx has
|
||||
miner_wlt->get_debug_events_dispatcher().UNSUBSCRIBE_ALL();
|
||||
|
|
@ -276,11 +347,24 @@ bool multiassets_basic_test::c1(currency::core& c, size_t ev_index, const std::v
|
|||
});
|
||||
|
||||
|
||||
r = false;
|
||||
try
|
||||
{
|
||||
miner_wlt->burn_asset(asset_id, 10000000000000, tx);
|
||||
}
|
||||
catch(tools::error::tx_rejected&)
|
||||
{
|
||||
r = true;
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(r, false, "burn_asset succeeded, but this shouldn't happened");
|
||||
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(true);
|
||||
miner_wlt->burn_asset(asset_id, 10000000000000, tx);
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count());
|
||||
r = mine_next_pow_block_in_playtime(miner_wlt->get_account().get_public_address(), c);
|
||||
CHECK_AND_ASSERT_MES(!r, false, "block with a bad tx was unexpectedly mined");
|
||||
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Unexpected number of txs in the pool: " << c.get_pool_transactions_count()); // make sure tx was not confirmed
|
||||
c.get_tx_pool().unsecure_disable_tx_validation_on_addition(false);
|
||||
c.get_tx_pool().purge_transactions();
|
||||
miner_wlt->refresh();
|
||||
miner_wlt->get_debug_events_dispatcher().UNSUBSCRIBE_ALL();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue