forked from townforge/townforge
610 lines
29 KiB
C++
610 lines
29 KiB
C++
// Copyright (c) 2014-2019, The Monero Project
|
|
//
|
|
// All rights reserved.
|
|
//
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
// permitted provided that the following conditions are met:
|
|
//
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
// conditions and the following disclaimer.
|
|
//
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
// of conditions and the following disclaimer in the documentation and/or other
|
|
// materials provided with the distribution.
|
|
//
|
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
// used to endorse or promote products derived from this software without specific
|
|
// prior written permission.
|
|
//
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
//
|
|
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
|
|
|
#pragma once
|
|
#include "chaingen.h"
|
|
|
|
struct gen_cc_tx_validation_base : public test_chain_unit_base
|
|
{
|
|
gen_cc_tx_validation_base()
|
|
: m_invalid_tx_index(0)
|
|
, m_invalid_block_index(0)
|
|
{
|
|
REGISTER_CALLBACK_METHOD(gen_cc_tx_validation_base, mark_invalid_tx);
|
|
REGISTER_CALLBACK_METHOD(gen_cc_tx_validation_base, mark_invalid_block);
|
|
REGISTER_CALLBACK_METHOD(gen_cc_tx_validation_base, check_final_state);
|
|
REGISTER_CALLBACK_METHOD(gen_cc_tx_validation_base, generate_game_update_command);
|
|
}
|
|
|
|
bool check_tx_verification_context(const cryptonote::tx_verification_context& tvc, bool tx_added, size_t event_idx, const cryptonote::transaction& /*tx*/)
|
|
{
|
|
if (m_invalid_tx_index == event_idx)
|
|
return tvc.m_verifivation_failed;
|
|
else
|
|
return !tvc.m_verifivation_failed && tx_added;
|
|
}
|
|
|
|
bool check_block_verification_context(const cryptonote::block_verification_context& bvc, size_t event_idx, const cryptonote::block& /*block*/)
|
|
{
|
|
if (m_invalid_block_index == event_idx)
|
|
return bvc.m_verifivation_failed;
|
|
else
|
|
return !bvc.m_verifivation_failed;
|
|
}
|
|
|
|
bool mark_invalid_block(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/)
|
|
{
|
|
m_invalid_block_index = ev_index + 1;
|
|
return true;
|
|
}
|
|
|
|
bool mark_invalid_tx(cryptonote::core& /*c*/, size_t ev_index, const std::vector<test_event_entry>& /*events*/)
|
|
{
|
|
m_invalid_tx_index = ev_index + 1;
|
|
return true;
|
|
}
|
|
|
|
bool check_final_state(cryptonote::core &c, size_t, const std::vector<test_event_entry> &events)
|
|
{
|
|
return check_final_state(c, events);
|
|
}
|
|
|
|
virtual bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events) { return true; }
|
|
|
|
virtual bool generate_game_update_command(cryptonote::core &c, size_t ev_index, const std::vector<test_event_entry> &events_);
|
|
|
|
enum preparation_t { prep_none, prep_create_accounts, prep_large_balance, prep_buy_stuff };
|
|
enum validity_t { valid, invalid };
|
|
bool generate_with_full(std::vector<test_event_entry>& events,
|
|
const boost::optional<cryptonote::cc_account_source> &cc_source, boost::optional<cryptonote::cc_account_dest> cc_dest,
|
|
preparation_t preparation, unsigned int n_txes, unsigned int mixin, uint64_t amount_paid,
|
|
bool bare, const std::vector<std::tuple<std::string, cryptonote::cc_command_t, uint64_t>> &bare_cmds,
|
|
bool pop_block, validity_t valid, bool update,
|
|
const std::function<void(std::vector<cryptonote::tx_source_entry> &sources, std::vector<cryptonote::tx_destination_entry> &destinations)> &pre_tx,
|
|
const std::function<void(cryptonote::transaction &tx)> &post_tx) const;
|
|
bool generate_with(std::vector<test_event_entry>& events,
|
|
const boost::optional<cryptonote::cc_account_source> &cc_source, boost::optional<cryptonote::cc_account_dest> cc_dest,
|
|
preparation_t preparation, unsigned int n_txes, unsigned int mixin, uint64_t amount_paid,
|
|
bool bare, const std::vector<std::tuple<std::string, cryptonote::cc_command_t, uint64_t>> &bare_cmds,
|
|
bool pop_block, validity_t valid,
|
|
const std::function<void(std::vector<cryptonote::tx_source_entry> &sources, std::vector<cryptonote::tx_destination_entry> &destinations)> &pre_tx,
|
|
const std::function<void(cryptonote::transaction &tx)> &post_tx) const;
|
|
|
|
private:
|
|
size_t m_invalid_tx_index;
|
|
size_t m_invalid_block_index;
|
|
};
|
|
|
|
template<>
|
|
struct get_test_options<gen_cc_tx_validation_base> {
|
|
const std::pair<uint8_t, uint64_t> hard_forks[2] = {std::make_pair(12, 0), std::make_pair(0, 0)};
|
|
const cryptonote::test_options test_options = {
|
|
hard_forks, 0
|
|
};
|
|
};
|
|
|
|
struct gen_cc_tx_valid_non_cc : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_non_cc>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
// create_account
|
|
|
|
struct gen_cc_tx_valid_create_account : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_create_account>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_create_account_low_fee : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_create_account_low_fee>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_create_account_including_deposit : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_create_account_including_deposit>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
// transfer
|
|
|
|
struct gen_cc_tx_invalid_cc_one_in_no_out_invalid_cc_account : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_one_in_no_out_invalid_cc_account>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_one_in_one_out_invalid_cc_account : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_one_in_one_out_invalid_cc_account>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_4_accounts : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_4_accounts>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_one_in_one_out : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_one_in_one_out>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_one_in_one_out_more_than_inputs : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_one_in_one_out_more_than_inputs>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_one_in_one_out_more_than_rct_inputs_but_balance_is_large_enough : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_one_in_one_out_more_than_rct_inputs_but_balance_is_large_enough>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_one_in_one_out_more_than_rct_inputs_but_balance_is_not_large_enough : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_one_in_one_out_more_than_rct_inputs_but_balance_is_not_large_enough>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_multiple_txes_spend_more_than_balance : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_multiple_txes_spend_more_than_balance>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bad_signature : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bad_signature>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_signature_by_wrong_keys : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_signature_by_wrong_keys>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_one_in_no_out : public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_one_in_no_out>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_pop_reverts: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_pop_reverts>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_one_in_no_out: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_one_in_no_out>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_no_in_one_out: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_no_in_one_out>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_one_in_one_out: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_one_in_one_out>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_transfer_whole_balance_nothing_left_for_fee: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_transfer_whole_balance_nothing_left_for_fee>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
// buy_land
|
|
|
|
struct gen_cc_tx_valid_cc_bare_buy_land_min_size: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
static uint64_t land_cost;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_buy_land_min_size>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_buy_land_max_size: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
static uint64_t land_cost;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_buy_land_max_size>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_buy_land_too_small: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_buy_land_too_small>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_buy_land_not_enough_balance: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_buy_land_not_enough_balance>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_buy_land_overlapping: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_buy_land_overlapping>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
// build
|
|
|
|
struct gen_cc_tx_valid_cc_bare_build_whole_flag: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
static uint64_t build_cost;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_build_whole_flag>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_build_part_of_flag: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
static uint64_t build_cost;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_build_part_of_flag>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_build_out_of_flag: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_build_out_of_flag>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_build_invalid_flag: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_build_invalid_flag>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_build_not_owned: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_build_not_owned>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_build_too_long_decoded_block_data: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_build_too_long_decoded_block_data>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_build_stacked: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
static uint64_t build_cost;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_build_stacked>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_build_not_enough_blocks: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_build_not_enough_blocks>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
// buy_blocks
|
|
|
|
struct gen_cc_tx_valid_cc_bare_buy_blocks: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
static uint64_t blocks_cost;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_buy_blocks>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_buy_blocks_type_0: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_buy_blocks_type_0>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_buy_blocks_amount_0: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_buy_blocks_amount_0>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_buy_blocks_balance_overflow: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_buy_blocks_balance_overflow>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_buy_blocks_balance_overflow_in_aggregate: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_buy_blocks_balance_overflow_in_aggregate>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_buy_blocks_duplicate_type: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_buy_blocks_duplicate_type>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
// trade/match
|
|
|
|
struct gen_cc_tx_valid_cc_bare_trade_bid_blocks: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_trade_bid_blocks>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_trade_offer_blocks: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_trade_offer_blocks>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_trade_bid_invalid_type: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_trade_bid_invalid_type>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_trade_bid_block_id_0: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_trade_bid_block_id_0>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_trade_bid_invalid_block_id: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_trade_bid_invalid_block_id>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_trade_bid_expired: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_trade_bid_expired>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_trade_bid_not_enough_money: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_trade_bid_not_enough_money>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_trade_bid_amount_0: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_trade_bid_amount_0>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_trade_offer_amount_0: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_trade_offer_amount_0>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_match_blocks_matching_amounts: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_match_blocks_matching_amounts>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_match_blocks_partial_buy: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_match_blocks_partial_buy>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_match_blocks_partial_sell: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_match_blocks_partial_sell>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_match_0: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_match_0>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_match_more_than_trade: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_match_more_than_trade>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_trade_from_account_0: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_trade_from_account_0>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_match_non_trade_tx: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_match_non_trade_tx>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_match_duplicate_trade_tx: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_match_duplicate_trade_tx>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_match_two_buys_from_one_sell: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_match_two_buys_from_one_sell>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_maker_no_fee: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_maker_no_fee>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_taker_no_fee: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_taker_no_fee>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_trade_flag: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
static uint64_t land_cost;
|
|
static uint64_t blocks_cost;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_trade_flag>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_trade_flag_build_destroyed: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_trade_flag_build_destroyed>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_repair: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
bool generate_game_update_command(cryptonote::core &c, size_t ev_index, const std::vector<test_event_entry> &events_);
|
|
static uint64_t money_cost;
|
|
static int64_t game_update_account1_delta;
|
|
static int64_t game_update_treasury_delta;
|
|
static std::map<uint32_t, uint32_t> item_balances;
|
|
static uint32_t expected_repair;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_repair>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_repair_past_max: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_repair_past_max>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_repair_negative: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_repair_negative>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_repair_invalid_flag: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_repair_invalid_flag>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_repair_unowned_flag: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_repair_unowned_flag>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_huge_game_update: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
bool generate_game_update_command(cryptonote::core &c, size_t ev_index, const std::vector<test_event_entry> &events_);
|
|
static int64_t game_update_account1_delta;
|
|
static int64_t game_update_treasury_delta;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_huge_game_update>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_valid_cc_bare_new_item: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
bool check_final_state(cryptonote::core &c, const std::vector<test_event_entry> &events);
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_valid_cc_bare_new_item>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_new_item_zero_amount: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_new_item_zero_amount>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_new_item_no_name: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_new_item_no_name>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_new_item_invalid_name: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_new_item_invalid_name>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_new_item_duplicate_name: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_new_item_duplicate_name>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_ignore_wrong_account: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_ignore_wrong_account>: public get_test_options<gen_cc_tx_validation_base> {};
|
|
|
|
struct gen_cc_tx_invalid_cc_bare_new_event_badge_wrong_account: public gen_cc_tx_validation_base
|
|
{
|
|
bool generate(std::vector<test_event_entry>& events) const;
|
|
};
|
|
template<> struct get_test_options<gen_cc_tx_invalid_cc_bare_new_event_badge_wrong_account>: public get_test_options<gen_cc_tx_validation_base> {};
|