pub struct WasmTestBuilder<S> { /* private fields */ }
Expand description

Builder for simple WASM test

Implementations§

source§

impl WasmTestBuilder<InMemoryGlobalState>

source

pub fn new_with_config(engine_config: EngineConfig) -> Self

Returns an InMemoryWasmTestBuilder initialized with an engine config instance.

source

pub fn new( global_state: InMemoryGlobalState, engine_config: EngineConfig, maybe_post_state_hash: Option<Digest> ) -> Self

source

pub fn new_with_chainspec<P: AsRef<Path>>( chainspec_path: P, post_state_hash: Option<Digest> ) -> Self

Returns an InMemoryWasmTestBuilder instantiated using values from a given chainspec.

source§

impl WasmTestBuilder<LmdbGlobalState>

source

pub fn upgrade_with_upgrade_request_using_scratch( &mut self, engine_config: EngineConfig, upgrade_config: &mut UpgradeConfig ) -> &mut Self

Upgrades the execution engine using the scratch trie.

source

pub fn new_with_config<T: AsRef<OsStr> + ?Sized>( data_dir: &T, engine_config: EngineConfig ) -> Self

Returns an LmdbWasmTestBuilder with configuration.

source

pub fn new_with_chainspec<T: AsRef<OsStr> + ?Sized, P: AsRef<Path>>( data_dir: &T, chainspec_path: P ) -> Self

Returns an LmdbWasmTestBuilder with configuration and values from a given chainspec.

source

pub fn new_with_production_chainspec<T: AsRef<OsStr> + ?Sized>( data_dir: &T ) -> Self

Returns an LmdbWasmTestBuilder with configuration and values from the production chainspec.

source

pub fn flush_environment(&self)

Flushes the LMDB environment to disk.

source

pub fn new<T: AsRef<OsStr> + ?Sized>(data_dir: &T) -> Self

Returns a new LmdbWasmTestBuilder.

source

pub fn open<T: AsRef<OsStr> + ?Sized>( data_dir: &T, engine_config: EngineConfig, post_state_hash: Digest ) -> Self

Creates a new instance of builder using the supplied configurations, opening wrapped LMDBs (e.g. in the Trie and Data stores) rather than creating them.

source

pub fn open_raw<T: AsRef<Path>>( global_state_dir: T, engine_config: EngineConfig, post_state_hash: Digest ) -> Self

Creates a new instance of builder using the supplied configurations, opening wrapped LMDBs (e.g. in the Trie and Data stores) rather than creating them. Differs from open in that it doesn’t append GLOBAL_STATE_DIR to the supplied path.

source

pub fn lmdb_on_disk_size(&self) -> Option<u64>

Returns the file size on disk of the backing lmdb file behind LmdbGlobalState.

source

pub fn scratch_exec_and_commit( &mut self, exec_request: ExecuteRequest ) -> &mut Self

Execute and commit transforms from an ExecuteRequest into a scratch global state. You MUST call write_scratch_to_lmdb to flush these changes to LmdbGlobalState.

source

pub fn write_scratch_to_db(&mut self) -> &mut Self

Commit scratch to global state, and reset the scratch cache.

source

pub fn step_with_scratch(&mut self, step_request: StepRequest) -> &mut Self

run step against scratch global state.

source§

impl<S> WasmTestBuilder<S>

source

pub fn run_genesis( &mut self, run_genesis_request: &RunGenesisRequest ) -> &mut Self

Takes a RunGenesisRequest, executes the request and returns Self.

source

pub fn query( &self, maybe_post_state: Option<Digest>, base_key: Key, path: &[String] ) -> Result<StoredValue, String>

Queries state for a StoredValue.

source

pub fn query_dictionary_item( &self, maybe_post_state: Option<Digest>, dictionary_seed_uref: URef, dictionary_item_key: &str ) -> Result<StoredValue, String>

Queries state for a dictionary item.

source

pub fn query_with_proof( &self, maybe_post_state: Option<Digest>, base_key: Key, path: &[String] ) -> Result<(StoredValue, Vec<TrieMerkleProof<Key, StoredValue>>), String>

Queries for a StoredValue and returns the StoredValue and a Merkle proof.

source

pub fn total_supply(&self, maybe_post_state: Option<Digest>) -> U512

Queries for the total supply of token.

§Panics

Panics if the total supply can’t be found.

source

pub fn base_round_reward(&mut self, maybe_post_state: Option<Digest>) -> U512

Queries for the base round reward.

§Panics

Panics if the total supply or seigniorage rate can’t be found.

source

pub fn exec(&mut self, exec_request: ExecuteRequest) -> &mut Self

Runs an ExecuteRequest.

source

pub fn try_exec( &mut self, exec_request: ExecuteRequest ) -> Result<&mut Self, Error>

Tries to run an ExecuteRequest.

source

pub fn commit(&mut self) -> &mut Self

Commit effects of previous exec call on the latest post-state hash.

source

pub fn commit_transforms( &mut self, pre_state_hash: Digest, effects: AdditiveMap<Key, Transform> ) -> &mut Self

Runs a commit request, expects a successful response, and overwrites existing cached post state hash with a new one.

source

pub fn upgrade_with_upgrade_request( &mut self, engine_config: EngineConfig, upgrade_config: &mut UpgradeConfig ) -> &mut Self

Upgrades the execution engine. Deprecated - this path does not use the scratch trie and generates many interstitial commits on upgrade.

source

pub fn upgrade_with_upgrade_request_and_config( &mut self, engine_config: Option<EngineConfig>, upgrade_config: &mut UpgradeConfig ) -> &mut Self

Upgrades the execution engine.

If engine_config is set to None, then it is defaulted to the current one.

source

pub fn run_auction( &mut self, era_end_timestamp_millis: u64, evicted_validators: Vec<PublicKey> ) -> &mut Self

Executes a request to call the system auction contract.

source

pub fn step( &mut self, step_request: StepRequest ) -> Result<StepSuccess, StepError>

Increments engine state.

source

pub fn expect_success(&mut self) -> &mut Self

Expects a successful run

source

pub fn expect_failure(&mut self) -> &mut Self

Expects a failed run

source

pub fn is_error(&self) -> bool

Returns true if the las exec had an error, otherwise returns false.

source

pub fn get_error(&self) -> Option<Error>

Returns an Option<engine_state::Error> if the last exec had an error.

source

pub fn get_execution_journals(&self) -> Vec<ExecutionJournal>

Gets ExecutionJournals of all passed runs.

source

pub fn get_genesis_account(&self) -> &Account

Gets genesis account (if present)

source

pub fn get_mint_contract_hash(&self) -> ContractHash

Returns the ContractHash of the mint, panics if it can’t be found.

source

pub fn get_handle_payment_contract_hash(&self) -> ContractHash

Returns the ContractHash of the “handle payment” contract, panics if it can’t be found.

source

pub fn get_standard_payment_contract_hash(&self) -> ContractHash

Returns the ContractHash of the “standard payment” contract, panics if it can’t be found.

source

pub fn get_auction_contract_hash(&self) -> ContractHash

Returns the ContractHash of the “auction” contract, panics if it can’t be found.

source

pub fn get_genesis_transforms(&self) -> &AdditiveMap<Key, Transform>

Returns genesis transforms, panics if there aren’t any.

source

pub fn get_genesis_hash(&self) -> Digest

Returns the genesis hash, panics if it can’t be found.

source

pub fn get_post_state_hash(&self) -> Digest

Returns the post state hash, panics if it can’t be found.

source

pub fn get_engine_state(&self) -> &EngineState<S>

Returns the engine state.

source

pub fn get_last_exec_results(&self) -> Option<Vec<Rc<ExecutionResult>>>

Returns the last results execs.

source

pub fn get_exec_result_owned( &self, index: usize ) -> Option<Vec<Rc<ExecutionResult>>>

Returns the owned results of a specific exec.

source

pub fn get_exec_results_count(&self) -> usize

Returns a count of exec results.

source

pub fn get_upgrade_result( &self, index: usize ) -> Option<&Result<UpgradeSuccess, Error>>

Returns a Result containing an UpgradeSuccess.

source

pub fn expect_upgrade_success(&mut self) -> &mut Self

Expects upgrade success.

source

pub fn get_handle_payment_contract(&self) -> Contract

Returns the “handle payment” contract, panics if it can’t be found.

source

pub fn get_purse_balance(&self, purse: URef) -> U512

Returns the balance of a purse, panics if the balance can’t be parsed into a U512.

source

pub fn get_purse_balance_result(&self, purse: URef) -> BalanceResult

Returns a BalanceResult for a purse, panics if the balance can’t be found.

source

pub fn get_public_key_balance_result( &self, public_key: PublicKey ) -> BalanceResult

Returns a BalanceResult for a purse using a PublicKey.

source

pub fn get_proposer_purse_balance(&self) -> U512

Gets the purse balance of a proposer.

source

pub fn get_account(&self, account_hash: AccountHash) -> Option<Account>

Queries for an Account.

source

pub fn get_expected_account(&self, account_hash: AccountHash) -> Account

Queries for an Account and panics if it can’t be found.

source

pub fn get_contract(&self, contract_hash: ContractHash) -> Option<Contract>

Queries for a contract by ContractHash.

source

pub fn get_contract_wasm( &self, contract_hash: ContractHash ) -> Option<ContractWasm>

Queries for a contract by ContractHash and returns an Option<ContractWasm>.

source

pub fn get_contract_package( &self, contract_package_hash: ContractPackageHash ) -> Option<ContractPackage>

Queries for a contract package by ContractPackageHash.

source

pub fn get_transfer(&self, transfer: TransferAddr) -> Option<Transfer>

Queries for a transfer by TransferAddr.

source

pub fn get_deploy_info(&self, deploy_hash: DeployHash) -> Option<DeployInfo>

Queries for deploy info by DeployHash.

source

pub fn exec_costs(&self, index: usize) -> Vec<Gas>

Returns a Vec<Gas> representing execution consts.

source

pub fn last_exec_gas_cost(&self) -> Gas

Returns the Gas cost of the last exec.

source

pub fn last_exec_result(&self) -> &ExecutionResult

Returns the result of the last exec.

source

pub fn assert_error(&self, expected_error: Error)

Assert that last error is the expected one.

NOTE: we’re using string-based representation for checking equality as the Error type does not implement Eq (many of its subvariants don’t).

source

pub fn exec_error_message(&self, index: usize) -> Option<String>

Returns the error message of the last exec.

source

pub fn get_era_validators(&mut self) -> EraValidators

source

pub fn get_validator_weights( &mut self, era_id: EraId ) -> Option<ValidatorWeights>

Gets ValidatorWeights for a given EraId.

source

pub fn get_bids(&mut self) -> Bids

Gets Bids.

source

pub fn get_unbonds(&mut self) -> UnbondingPurses

source

pub fn get_withdraw_purses(&mut self) -> WithdrawPurses

source

pub fn get_balance_keys(&self) -> Vec<Key>

Gets all [Key::Balance]s in global state.

source

pub fn get_keys(&self, tag: KeyTag) -> Result<Vec<Key>, S::Error>

Gets all keys in global state by a prefix.

source

pub fn get_value<T>(&mut self, contract_hash: ContractHash, name: &str) -> T
where T: FromBytes + CLTyped,

Gets a stored value from a contract’s named keys.

source

pub fn get_era(&mut self) -> EraId

Gets an EraId.

source

pub fn get_auction_delay(&mut self) -> u64

Gets the auction delay.

source

pub fn get_unbonding_delay(&mut self) -> u64

Gets the unbonding delay

source

pub fn get_system_auction_hash(&self) -> ContractHash

Gets the ContractHash of the system auction contract, panics if it can’t be found.

source

pub fn get_system_mint_hash(&self) -> ContractHash

Gets the ContractHash of the system mint contract, panics if it can’t be found.

source

pub fn get_system_handle_payment_hash(&self) -> ContractHash

Gets the ContractHash of the system handle payment contract, panics if it can’t be found.

source

pub fn get_system_standard_payment_hash(&self) -> ContractHash

Returns the ContractHash of the system standard payment contract, panics if it can’t be found.

source

pub fn clear_results(&mut self) -> &mut Self

Resets the exec_results, upgrade_results and transform fields.

source

pub fn advance_eras_by( &mut self, num_eras: u64, reward_items: impl IntoIterator<Item = RewardItem>, evict_items: impl IntoIterator<Item = EvictItem> )

Advances eras by num_eras

source

pub fn advance_eras_by_default_auction_delay( &mut self, reward_items: impl IntoIterator<Item = RewardItem>, evict_items: impl IntoIterator<Item = EvictItem> )

Advances eras by configured amount

source

pub fn advance_era( &mut self, reward_items: impl IntoIterator<Item = RewardItem>, evict_items: impl IntoIterator<Item = EvictItem> )

Advances by a single era.

source

pub fn get_trie(&mut self, state_hash: Digest) -> Option<Trie<Key, StoredValue>>

Returns a trie by hash.

source

pub fn get_auction_costs(&self) -> AuctionCosts

Returns the costs related to interacting with the auction system contract.

source

pub fn get_mint_costs(&self) -> MintCosts

Returns the costs related to interacting with the mint system contract.

source

pub fn get_handle_payment_costs(&self) -> HandlePaymentCosts

Returns the costs related to interacting with the handle payment system contract.

source

pub fn commit_prune(&mut self, prune_config: PruneConfig) -> &mut Self

Commits a prune of leaf nodes from the tip of the merkle trie.

source

pub fn get_prune_result( &self, index: usize ) -> Option<&Result<PruneResult, Error>>

Returns a Result containing a PruneResult.

source

pub fn expect_prune_success(&mut self) -> &mut Self

Expects a prune success.

source

pub fn get_transforms(&self) -> Vec<AdditiveMap<Key, Transform>>

👎Deprecated since 2.1.0: Use get_execution_journals that returns transforms in the order they were created.

Gets the transform map that’s cached between runs

source

pub fn get_exec_results(&self) -> &Vec<Vec<Rc<ExecutionResult>>>

👎Deprecated since 2.3.0: use get_last_exec_results or get_exec_result_owned instead

Returns the results of all execs.

source

pub fn get_exec_result(&self, index: usize) -> Option<&Vec<Rc<ExecutionResult>>>

👎Deprecated since 2.3.0: use get_exec_result_owned instead

Returns the results of a specific exec.

source

pub fn get_withdraws(&mut self) -> UnbondingPurses

👎Deprecated since 2.3.0: use get_withdraw_purses instead
source

pub fn calculate_refund_amount(&self, payment_amount: U512) -> U512

Calculates refunded amount from a last execution request.

Trait Implementations§

source§

impl<S> Clone for WasmTestBuilder<S>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for WasmTestBuilder<S>
where S: RefUnwindSafe,

§

impl<S> !Send for WasmTestBuilder<S>

§

impl<S> !Sync for WasmTestBuilder<S>

§

impl<S> Unpin for WasmTestBuilder<S>

§

impl<S> UnwindSafe for WasmTestBuilder<S>
where S: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more