Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::testing::tester Class Reference

provides utility function to simplify the creation of unit tests More...

#include <tester.hpp>

Inheritance diagram for sysio::testing::tester:
Collaboration diagram for sysio::testing::tester:

Public Member Functions

 tester (setup_policy policy=setup_policy::full, db_read_mode read_mode=db_read_mode::SPECULATIVE, std::optional< uint32_t > genesis_max_inline_action_size=std::optional< uint32_t >{}, std::optional< uint32_t > config_max_nonprivileged_inline_action_size=std::optional< uint32_t >{})
 
 tester (controller::config config, const genesis_state &genesis)
 
 tester (controller::config config)
 
 tester (controller::config config, protocol_feature_set &&pfs, const genesis_state &genesis)
 
 tester (const fc::temp_directory &tempdir, bool use_genesis)
 
template<typename Lambda >
 tester (const fc::temp_directory &tempdir, Lambda conf_edit, bool use_genesis)
 
signed_block_ptr produce_block (fc::microseconds skip_time=fc::milliseconds(config::block_interval_ms)) override
 
signed_block_ptr produce_empty_block (fc::microseconds skip_time=fc::milliseconds(config::block_interval_ms)) override
 
signed_block_ptr finish_block () override
 
bool validate ()
 
signed_block_ptr produce_block (std::vector< transaction_trace_ptr > &traces)
 
- Public Member Functions inherited from sysio::testing::base_tester
virtual ~base_tester ()
 
void init (const setup_policy policy=setup_policy::full, db_read_mode read_mode=db_read_mode::SPECULATIVE, std::optional< uint32_t > genesis_max_inline_action_size=std::optional< uint32_t >{}, std::optional< uint32_t > config_max_nonprivileged_inline_action_size=std::optional< uint32_t >{})
 
void init (controller::config config, const snapshot_reader_ptr &snapshot)
 
void init (controller::config config, const genesis_state &genesis)
 
void init (controller::config config)
 
void init (controller::config config, protocol_feature_set &&pfs, const snapshot_reader_ptr &snapshot)
 
void init (controller::config config, protocol_feature_set &&pfs, const genesis_state &genesis)
 
void init (controller::config config, protocol_feature_set &&pfs)
 
void execute_setup_policy (const setup_policy policy)
 
void close ()
 
template<typename Lambda >
void open (protocol_feature_set &&pfs, std::optional< chain_id_type > expected_chain_id, Lambda lambda)
 
void open (protocol_feature_set &&pfs, const snapshot_reader_ptr &snapshot)
 
void open (protocol_feature_set &&pfs, const genesis_state &genesis)
 
void open (protocol_feature_set &&pfs, std::optional< chain_id_type > expected_chain_id={})
 
void open (const snapshot_reader_ptr &snapshot)
 
void open (const genesis_state &genesis)
 
void open (std::optional< chain_id_type > expected_chain_id={})
 
bool is_same_chain (base_tester &other)
 
signed_block_ptr produce_block (std::vector< transaction_trace_ptr > &traces)
 
void produce_blocks (uint32_t n=1, bool empty=false)
 
void produce_blocks_until_end_of_round ()
 
void produce_blocks_for_n_rounds (const uint32_t num_of_rounds=1)
 
void produce_min_num_of_blocks_to_spend_time_wo_inactive_prod (const fc::microseconds target_elapsed_time=fc::microseconds())
 
void push_block (signed_block_ptr b)
 
vector< transaction_id_typeget_scheduled_transactions () const
 
unapplied_transaction_queueget_unapplied_transaction_queue ()
 
transaction_trace_ptr push_transaction (packed_transaction &trx, fc::time_point deadline=fc::time_point::maximum(), uint32_t billed_cpu_time_us=DEFAULT_BILLED_CPU_TIME_US)
 
transaction_trace_ptr push_transaction (signed_transaction &trx, fc::time_point deadline=fc::time_point::maximum(), uint32_t billed_cpu_time_us=DEFAULT_BILLED_CPU_TIME_US, bool no_throw=false)
 
action_result push_action (action &&cert_act, uint64_t authorizer)
 
transaction_trace_ptr push_action (const account_name &code, const action_name &acttype, const account_name &actor, const variant_object &data, uint32_t expiration=DEFAULT_EXPIRATION_DELTA, uint32_t delay_sec=0)
 
transaction_trace_ptr push_action (const account_name &code, const action_name &acttype, const vector< account_name > &actors, const variant_object &data, uint32_t expiration=DEFAULT_EXPIRATION_DELTA, uint32_t delay_sec=0)
 
transaction_trace_ptr push_action (const account_name &code, const action_name &acttype, const vector< permission_level > &auths, const variant_object &data, uint32_t expiration=DEFAULT_EXPIRATION_DELTA, uint32_t delay_sec=0)
 
action get_action (account_name code, action_name acttype, vector< permission_level > auths, const variant_object &data) const
 
void set_transaction_headers (transaction &trx, uint32_t expiration=DEFAULT_EXPIRATION_DELTA, uint32_t delay_sec=0) const
 
vector< transaction_trace_ptrcreate_accounts (vector< account_name > names, bool multisig=false, bool include_code=true)
 
void set_before_preactivate_bios_contract ()
 
void set_before_producer_authority_bios_contract ()
 
void set_bios_contract ()
 
vector< producer_authorityget_producer_authorities (const vector< account_name > &producer_names) const
 
transaction_trace_ptr set_producers (const vector< account_name > &producer_names)
 
transaction_trace_ptr set_producer_schedule (const vector< producer_authority > &schedule)
 
transaction_trace_ptr set_producers_legacy (const vector< account_name > &producer_names)
 
void link_authority (account_name account, account_name code, permission_name req, action_name type={})
 
void unlink_authority (account_name account, account_name code, action_name type={})
 
void set_authority (account_name account, permission_name perm, authority auth, permission_name parent, const vector< permission_level > &auths, const vector< private_key_type > &keys)
 
void set_authority (account_name account, permission_name perm, authority auth, permission_name parent=config::owner_name)
 
void delete_authority (account_name account, permission_name perm, const vector< permission_level > &auths, const vector< private_key_type > &keys)
 
void delete_authority (account_name account, permission_name perm)
 
transaction_trace_ptr create_account (account_name name, account_name creator=config::system_account_name, bool multisig=false, bool include_code=true)
 
transaction_trace_ptr push_reqauth (account_name from, const vector< permission_level > &auths, const vector< private_key_type > &keys)
 
transaction_trace_ptr push_reqauth (account_name from, string role, bool multi_sig=false)
 
transaction_trace_ptr push_dummy (account_name from, const string &v="blah", uint32_t billed_cpu_time_us=DEFAULT_BILLED_CPU_TIME_US)
 
transaction_trace_ptr transfer (account_name from, account_name to, asset amount, string memo, account_name currency)
 
transaction_trace_ptr transfer (account_name from, account_name to, string amount, string memo, account_name currency)
 
transaction_trace_ptr issue (account_name to, string amount, account_name currency, string memo)
 
template<typename ObjectType >
const auto & get (const chainbase::oid< ObjectType > &key)
 
template<typename ObjectType , typename IndexBy , typename... Args>
const auto & get (Args &&... args)
 
template<typename ObjectType , typename IndexBy , typename... Args>
const auto * find (Args &&... args)
 
void set_code (account_name name, const char *wast, const private_key_type *signer=nullptr)
 
void set_code (account_name name, const vector< uint8_t > wasm, const private_key_type *signer=nullptr)
 
void set_abi (account_name name, const char *abi_json, const private_key_type *signer=nullptr)
 
bool chain_has_transaction (const transaction_id_type &txid) const
 
const transaction_receiptget_transaction_receipt (const transaction_id_type &txid) const
 
asset get_currency_balance (const account_name &contract, const symbol &asset_symbol, const account_name &account) const
 
vector< char > get_row_by_account (name code, name scope, name table, const account_name &act) const
 
map< account_name, block_id_typeget_last_produced_block_map () const
 
void set_last_produced_block_map (const map< account_name, block_id_type > &lpb)
 
auto get_resolver ()
 
void sync_with (base_tester &other)
 
const table_id_objectfind_table (name code, name scope, name table)
 
template<typename Object >
bool get_table_entry (Object &obj, account_name code, account_name scope, account_name table, uint64_t key, bool require=true)
 
const controller::configget_config () const
 
void schedule_protocol_features_wo_preactivation (const vector< digest_type > feature_digests)
 
void preactivate_protocol_features (const vector< digest_type > feature_digests)
 
void preactivate_builtin_protocol_features (const std::vector< builtin_protocol_feature_t > &features)
 
void preactivate_all_builtin_protocol_features ()
 

Additional Inherited Members

- Public Types inherited from sysio::testing::base_tester
typedef string action_result
 
- Static Public Member Functions inherited from sysio::testing::base_tester
template<typename KeyType = fc::ecc::private_key_shim>
static auto get_private_key (name keyname, string role="owner")
 
template<typename KeyType = fc::ecc::private_key_shim>
static auto get_public_key (name keyname, string role="owner")
 
static vector< uint8_tto_uint8_vector (const string &s)
 
static vector< uint8_tto_uint8_vector (uint64_t x)
 
static uint64_t to_uint64 (fc::variant x)
 
static string to_string (fc::variant x)
 
static action_result success ()
 
static action_result error (const string &msg)
 
static action_result wasm_assert_msg (const string &msg)
 
static action_result wasm_assert_code (uint64_t error_code)
 
static genesis_state default_genesis ()
 
static std::pair< controller::config, genesis_statedefault_config (const fc::temp_directory &tempdir, std::optional< uint32_t > genesis_max_inline_action_size=std::optional< uint32_t >{}, std::optional< uint32_t > config_max_nonprivileged_inline_action_size=std::optional< uint32_t >{})
 
- Public Attributes inherited from sysio::testing::base_tester
unique_ptr< controllercontrol
 
std::map< chain::public_key_type, chain::private_key_typeblock_signing_private_keys
 
vector< digest_typeprotocol_features_to_be_activated_wo_preactivation
 
- Static Public Attributes inherited from sysio::testing::base_tester
static const uint32_t DEFAULT_EXPIRATION_DELTA = 6
 
static const uint32_t DEFAULT_BILLED_CPU_TIME_US = 2000
 
static const fc::microseconds abi_serializer_max_time {1000*1000}
 
- Protected Member Functions inherited from sysio::testing::base_tester
signed_block_ptr _produce_block (fc::microseconds skip_time, bool skip_pending_trxs)
 
signed_block_ptr _produce_block (fc::microseconds skip_time, bool skip_pending_trxs, bool no_throw, std::vector< transaction_trace_ptr > &traces)
 
void _start_block (fc::time_point block_time)
 
signed_block_ptr _finish_block ()
 
- Protected Attributes inherited from sysio::testing::base_tester
fc::temp_directory tempdir
 
controller::config cfg
 
map< transaction_id_type, transaction_receiptchain_transactions
 
map< account_name, block_id_typelast_produced_block
 
unapplied_transaction_queue unapplied_transactions
 

Detailed Description

Definition at line 448 of file tester.hpp.

Constructor & Destructor Documentation

◆ tester() [1/6]

sysio::testing::tester::tester ( setup_policy policy = setup_policy::full,
db_read_mode read_mode = db_read_mode::SPECULATIVE,
std::optional< uint32_t > genesis_max_inline_action_size = std::optional<uint32_t>{},
std::optional< uint32_t > config_max_nonprivileged_inline_action_size = std::optional<uint32_t>{} )
inline

Definition at line 450 of file tester.hpp.

450 {}, std::optional<uint32_t> config_max_nonprivileged_inline_action_size = std::optional<uint32_t>{}) {
451 init(policy, read_mode, genesis_max_inline_action_size, config_max_nonprivileged_inline_action_size);
452 }
void init()
Definition lib_test.cpp:3

◆ tester() [2/6]

sysio::testing::tester::tester ( controller::config config,
const genesis_state & genesis )
inline

Definition at line 454 of file tester.hpp.

454 {
455 init(config, genesis);
456 }
Here is the call graph for this function:

◆ tester() [3/6]

sysio::testing::tester::tester ( controller::config config)
inline

Definition at line 458 of file tester.hpp.

458 {
459 init(config);
460 }
Here is the call graph for this function:

◆ tester() [4/6]

sysio::testing::tester::tester ( controller::config config,
protocol_feature_set && pfs,
const genesis_state & genesis )
inline

Definition at line 462 of file tester.hpp.

462 {
463 init(config, std::move(pfs), genesis);
464 }
Here is the call graph for this function:

◆ tester() [5/6]

sysio::testing::tester::tester ( const fc::temp_directory & tempdir,
bool use_genesis )
inline

Definition at line 466 of file tester.hpp.

466 {
467 auto def_conf = default_config(tempdir);
468 cfg = def_conf.first;
469
470 if (use_genesis) {
471 init(cfg, def_conf.second);
472 }
473 else {
474 init(cfg);
475 }
476 }
static std::pair< controller::config, genesis_state > default_config(const fc::temp_directory &tempdir, std::optional< uint32_t > genesis_max_inline_action_size=std::optional< uint32_t >{}, std::optional< uint32_t > config_max_nonprivileged_inline_action_size=std::optional< uint32_t >{})
Definition tester.hpp:396
controller::config cfg
Definition tester.hpp:439
fc::temp_directory tempdir
Definition tester.hpp:434
Here is the call graph for this function:

◆ tester() [6/6]

template<typename Lambda >
sysio::testing::tester::tester ( const fc::temp_directory & tempdir,
Lambda conf_edit,
bool use_genesis )
inline

Definition at line 479 of file tester.hpp.

479 {
480 auto def_conf = default_config(tempdir);
481 cfg = def_conf.first;
482 conf_edit(cfg);
483
484 if (use_genesis) {
485 init(cfg, def_conf.second);
486 }
487 else {
488 init(cfg);
489 }
490 }
Here is the call graph for this function:

Member Function Documentation

◆ finish_block()

signed_block_ptr sysio::testing::tester::finish_block ( )
inlineoverridevirtual

Implements sysio::testing::base_tester.

Definition at line 503 of file tester.hpp.

503 {
504 return _finish_block();
505 }
signed_block_ptr _finish_block()
Definition tester.cpp:416
Here is the call graph for this function:

◆ produce_block() [1/2]

signed_block_ptr sysio::testing::tester::produce_block ( fc::microseconds skip_time = fc::milliseconds(config::block_interval_ms))
inlineoverridevirtual

Implements sysio::testing::base_tester.

Definition at line 494 of file tester.hpp.

494 {
495 return _produce_block(skip_time, false);
496 }
signed_block_ptr _produce_block(fc::microseconds skip_time, bool skip_pending_trxs)
Definition tester.cpp:338
Here is the call graph for this function:
Here is the caller graph for this function:

◆ produce_block() [2/2]

signed_block_ptr sysio::testing::base_tester::produce_block ( std::vector< transaction_trace_ptr > & traces)

Definition at line 181 of file tester.cpp.

447 {
448 return _produce_block( fc::milliseconds(config::block_interval_ms), false, true, traces );
449 }
constexpr microseconds milliseconds(int64_t s)
Definition time.hpp:33

◆ produce_empty_block()

signed_block_ptr sysio::testing::tester::produce_empty_block ( fc::microseconds skip_time = fc::milliseconds(config::block_interval_ms))
inlineoverridevirtual

Implements sysio::testing::base_tester.

Definition at line 498 of file tester.hpp.

498 {
500 return _produce_block(skip_time, true);
501 }
void add_aborted(std::vector< transaction_metadata_ptr > aborted_trxs)
unapplied_transaction_queue unapplied_transactions
Definition tester.hpp:442
unique_ptr< controller > control
Definition tester.hpp:436
Here is the call graph for this function:

◆ validate()

bool sysio::testing::tester::validate ( )
inline

Definition at line 507 of file tester.hpp.

507{ return true; }

The documentation for this class was generated from the following file: