mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
core_tests: add tests for hard fork behaviors (MRL-0004)
We also replace the --fakechain option with an optional structure containing details about configuration for the core/blockchain, for test purposes. This seems more future friendly.
This commit is contained in:
parent
945fe90e08
commit
a333c42cde
10 changed files with 48 additions and 25 deletions
|
@ -38,7 +38,8 @@ set(core_tests_sources
|
|||
integer_overflow.cpp
|
||||
ring_signature_1.cpp
|
||||
transaction_tests.cpp
|
||||
tx_validation.cpp)
|
||||
tx_validation.cpp
|
||||
v2_tests.cpp)
|
||||
|
||||
set(core_tests_headers
|
||||
block_reward.h
|
||||
|
@ -52,7 +53,8 @@ set(core_tests_headers
|
|||
integer_overflow.h
|
||||
ring_signature_1.h
|
||||
transaction_tests.h
|
||||
tx_validation.h)
|
||||
tx_validation.h
|
||||
v2_tests.h)
|
||||
|
||||
add_executable(coretests
|
||||
${core_tests_sources}
|
||||
|
|
|
@ -471,6 +471,14 @@ inline bool replay_events_through_core(cryptonote::core& cr, const std::vector<t
|
|||
}
|
||||
//--------------------------------------------------------------------------
|
||||
template<class t_test_class>
|
||||
struct get_test_options {
|
||||
const std::pair<uint8_t, uint64_t> hard_forks[1] = {std::make_pair(1, 0)};
|
||||
const cryptonote::test_options test_options = {
|
||||
hard_forks
|
||||
};
|
||||
};
|
||||
//--------------------------------------------------------------------------
|
||||
template<class t_test_class>
|
||||
inline bool do_replay_events(std::vector<test_event_entry>& events)
|
||||
{
|
||||
boost::program_options::options_description desc("Allowed options");
|
||||
|
@ -485,15 +493,12 @@ inline bool do_replay_events(std::vector<test_event_entry>& events)
|
|||
if (!r)
|
||||
return false;
|
||||
|
||||
// hardcode a --fakechain option for tests
|
||||
static const char * const fakechain[] = {"", "--fakechain"};
|
||||
boost::program_options::store(boost::program_options::parse_command_line(2, fakechain, desc), vm);
|
||||
|
||||
cryptonote::cryptonote_protocol_stub pr; //TODO: stub only for this kind of test, make real validation of relayed objects
|
||||
cryptonote::core c(&pr);
|
||||
// FIXME: make sure that vm has arg_testnet_on set to true or false if
|
||||
// this test needs for it to be so.
|
||||
if (!c.init(vm))
|
||||
const get_test_options<t_test_class> gto;
|
||||
if (!c.init(vm, >o.test_options))
|
||||
{
|
||||
std::cout << concolor::magenta << "Failed to init core" << concolor::normal << std::endl;
|
||||
return false;
|
||||
|
|
|
@ -168,6 +168,13 @@ int main(int argc, char* argv[])
|
|||
|
||||
GENERATE_AND_PLAY(gen_block_reward);
|
||||
|
||||
GENERATE_AND_PLAY(gen_v2_tx_mixable_0_mixin);
|
||||
GENERATE_AND_PLAY(gen_v2_tx_mixable_low_mixin);
|
||||
GENERATE_AND_PLAY(gen_v2_tx_unmixable_only);
|
||||
GENERATE_AND_PLAY(gen_v2_tx_unmixable_one);
|
||||
GENERATE_AND_PLAY(gen_v2_tx_unmixable_two);
|
||||
GENERATE_AND_PLAY(gen_v2_tx_dust);
|
||||
|
||||
std::cout << (failed_tests.empty() ? concolor::green : concolor::magenta);
|
||||
std::cout << "\nREPORT:\n";
|
||||
std::cout << " Test run: " << tests_count << '\n';
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "integer_overflow.h"
|
||||
#include "ring_signature_1.h"
|
||||
#include "tx_validation.h"
|
||||
#include "v2_tests.h"
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue