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

#include <tester.hpp>

Inheritance diagram for sysio::testing::validating_tester:
Collaboration diagram for sysio::testing::validating_tester:

Public Member Functions

virtual ~validating_tester ()
 
 validating_tester (const flat_set< account_name > &trusted_producers=flat_set< account_name >(), deep_mind_handler *dmlog=nullptr)
 
 validating_tester (const fc::temp_directory &tempdir, bool use_genesis)
 
template<typename Lambda >
 validating_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_block_no_validation (fc::microseconds skip_time=fc::milliseconds(config::block_interval_ms))
 
void validate_push_block (const signed_block_ptr &sb)
 
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 ()
 
- 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 ()
 

Static Public Member Functions

static void config_validator (controller::config &vcfg)
 
static unique_ptr< controllercreate_validating_node (controller::config vcfg, const genesis_state &genesis, bool use_genesis, deep_mind_handler *dmlog=nullptr)
 
- 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

controller::config vcfg
 
unique_ptr< controllervalidating_node
 
uint32_t num_blocks_to_producer_before_shutdown = 0
 
bool skip_validate = false
 
- 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
 

Additional Inherited Members

- Public Types inherited from sysio::testing::base_tester
typedef string action_result
 
- 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 510 of file tester.hpp.

Constructor & Destructor Documentation

◆ ~validating_tester()

virtual sysio::testing::validating_tester::~validating_tester ( )
inlinevirtual

Definition at line 512 of file tester.hpp.

512 {
513 if( !validating_node ) {
514 elog( "~validating_tester() called with empty validating_node; likely in the middle of failure" );
515 return;
516 }
517 try {
520 if (!skip_validate)
521 BOOST_REQUIRE_EQUAL( validate(), true );
522 } catch( const fc::exception& e ) {
523 wdump((e.to_detail_string()));
524 }
525 }
Used to generate a useful error report when an exception is thrown.
Definition exception.hpp:58
std::string to_detail_string(log_level ll=log_level::all) const
void produce_blocks(uint32_t n=1, bool empty=false)
Definition tester.cpp:451
unique_ptr< controller > validating_node
Definition tester.hpp:647
uint32_t num_blocks_to_producer_before_shutdown
Definition tester.hpp:648
#define wdump(SEQ)
Definition logger.hpp:160
#define elog(FORMAT,...)
Definition logger.hpp:130
Here is the call graph for this function:

◆ validating_tester() [1/3]

sysio::testing::validating_tester::validating_tester ( const flat_set< account_name > & trusted_producers = flat_set<account_name>(),
deep_mind_handler * dmlog = nullptr )
inline

Definition at line 528 of file tester.hpp.

528 {
529 auto def_conf = default_config(tempdir);
530
531 vcfg = def_conf.first;
533 vcfg.trusted_producers = trusted_producers;
534
535 validating_node = create_validating_node(vcfg, def_conf.second, true, dmlog);
536
537 init(def_conf.first, def_conf.second);
539 }
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
void execute_setup_policy(const setup_policy policy)
Definition tester.cpp:192
fc::temp_directory tempdir
Definition tester.hpp:434
static unique_ptr< controller > create_validating_node(controller::config vcfg, const genesis_state &genesis, bool use_genesis, deep_mind_handler *dmlog=nullptr)
Definition tester.hpp:551
static void config_validator(controller::config &vcfg)
Definition tester.hpp:541
void init()
Definition lib_test.cpp:3
flat_set< account_name > trusted_producers
Here is the call graph for this function:

◆ validating_tester() [2/3]

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

Definition at line 567 of file tester.hpp.

567 {
568 auto def_conf = default_config(tempdir);
569 vcfg = def_conf.first;
571 validating_node = create_validating_node(vcfg, def_conf.second, use_genesis);
572
573 if (use_genesis) {
574 init(def_conf.first, def_conf.second);
575 }
576 else {
577 init(def_conf.first);
578 }
579 }
Here is the call graph for this function:

◆ validating_tester() [3/3]

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

Definition at line 582 of file tester.hpp.

582 {
583 auto def_conf = default_config(tempdir);
584 conf_edit(def_conf.first);
585 vcfg = def_conf.first;
587 validating_node = create_validating_node(vcfg, def_conf.second, use_genesis);
588
589 if (use_genesis) {
590 init(def_conf.first, def_conf.second);
591 }
592 else {
593 init(def_conf.first);
594 }
595 }
Here is the call graph for this function:

Member Function Documentation

◆ config_validator()

static void sysio::testing::validating_tester::config_validator ( controller::config & vcfg)
inlinestatic

Definition at line 541 of file tester.hpp.

541 {
543 && vcfg.state_dir.filename().generic_string() != ".", "invalid path names in controller::config" );
544
545 vcfg.blocks_dir = vcfg.blocks_dir.parent_path() / std::string("v_").append( vcfg.blocks_dir.filename().generic_string() );
546 vcfg.state_dir = vcfg.state_dir.parent_path() / std::string("v_").append( vcfg.state_dir.filename().generic_string() );
547
548 vcfg.contracts_console = false;
549 }
fc::path parent_path() const
fc::path filename() const
std::string generic_string() const
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_validating_node()

static unique_ptr< controller > sysio::testing::validating_tester::create_validating_node ( controller::config vcfg,
const genesis_state & genesis,
bool use_genesis,
deep_mind_handler * dmlog = nullptr )
inlinestatic

Definition at line 551 of file tester.hpp.

551 {
552 unique_ptr<controller> validating_node = std::make_unique<controller>(vcfg, make_protocol_feature_set(), genesis.compute_chain_id());
553 validating_node->add_indices();
554 if(dmlog)
555 {
556 validating_node->enable_deep_mind(dmlog);
557 }
558 if (use_genesis) {
559 validating_node->startup( [](){}, []() { return false; }, genesis );
560 }
561 else {
562 validating_node->startup( [](){}, []() { return false; } );
563 }
564 return validating_node;
565 }
protocol_feature_set make_protocol_feature_set(const subjective_restriction_map &custom_subjective_restrictions={})
Definition tester.cpp:110
Here is the call graph for this function:
Here is the caller graph for this function:

◆ finish_block()

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

Implements sysio::testing::base_tester.

Definition at line 623 of file tester.hpp.

623 {
624 return _finish_block();
625 }
signed_block_ptr _finish_block()
Definition tester.cpp:416
Here is the call graph for this function:

◆ produce_block()

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

Implements sysio::testing::base_tester.

Definition at line 597 of file tester.hpp.

597 {
598 auto sb = _produce_block(skip_time, false);
599 auto bsf = validating_node->create_block_state_future( sb->calculate_id(), sb );
601
602 return sb;
603 }
signed_block_ptr _produce_block(fc::microseconds skip_time, bool skip_pending_trxs)
Definition tester.cpp:338
std::function< transaction_metadata_ptr(const transaction_id_type &)> trx_meta_cache_lookup
std::function< void(const branch_type &)> forked_branch_callback
void bsf(const Reg &reg, const Operand &op)
Here is the call graph for this function:

◆ produce_block_no_validation()

signed_block_ptr sysio::testing::validating_tester::produce_block_no_validation ( fc::microseconds skip_time = fc::milliseconds(config::block_interval_ms))
inline

Definition at line 605 of file tester.hpp.

605 {
606 return _produce_block(skip_time, false);
607 }
Here is the call graph for this function:

◆ produce_empty_block()

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

Implements sysio::testing::base_tester.

Definition at line 614 of file tester.hpp.

614 {
616 auto sb = _produce_block(skip_time, true);
617 auto bsf = validating_node->create_block_state_future( sb->calculate_id(), sb );
619
620 return sb;
621 }
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::validating_tester::validate ( )
inline

Definition at line 627 of file tester.hpp.

627 {
628
629
630 auto hbh = control->head_block_state()->header;
631 auto vn_hbh = validating_node->head_block_state()->header;
632 bool ok = control->head_block_id() == validating_node->head_block_id() &&
633 hbh.previous == vn_hbh.previous &&
634 hbh.timestamp == vn_hbh.timestamp &&
635 hbh.transaction_mroot == vn_hbh.transaction_mroot &&
636 hbh.action_mroot == vn_hbh.action_mroot &&
637 hbh.producer == vn_hbh.producer;
638
639 validating_node.reset();
640 validating_node = std::make_unique<controller>(vcfg, make_protocol_feature_set(), control->get_chain_id());
641 validating_node->add_indices();
642 validating_node->startup( [](){}, []() { return false; } );
643
644 return ok;
645 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_push_block()

void sysio::testing::validating_tester::validate_push_block ( const signed_block_ptr & sb)
inline

Definition at line 609 of file tester.hpp.

609 {
610 auto bsf = validating_node->create_block_state_future( sb->calculate_id(), sb );
612 }
Here is the call graph for this function:

Member Data Documentation

◆ num_blocks_to_producer_before_shutdown

uint32_t sysio::testing::validating_tester::num_blocks_to_producer_before_shutdown = 0

Definition at line 648 of file tester.hpp.

◆ skip_validate

bool sysio::testing::validating_tester::skip_validate = false

Definition at line 649 of file tester.hpp.

◆ validating_node

unique_ptr<controller> sysio::testing::validating_tester::validating_node

Definition at line 647 of file tester.hpp.

◆ vcfg

controller::config sysio::testing::validating_tester::vcfg

Definition at line 526 of file tester.hpp.


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