Struct CyberApp

Source
pub struct CyberApp(/* private fields */);

Implementations§

Source§

impl CyberApp

Source

pub fn new() -> Self

Source

pub fn block_info(&self) -> BlockInfo

Source

pub fn advance_blocks(&mut self, blocks: u64)

Source

pub fn advance_seconds(&mut self, seconds: u64)

Source

pub fn next_block(&mut self)

Methods from Deref<Target = CyberAppWrapped>§

Source

pub fn router( &self, ) -> &Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>

Returns a shared reference to application’s router.

Source

pub fn api(&self) -> &ApiT

Returns a shared reference to application’s api.

Source

pub fn storage(&self) -> &StorageT

Returns a shared reference to application’s storage.

Source

pub fn storage_mut(&mut self) -> &mut StorageT

Returns a mutable reference to application’s storage.

Source

pub fn init_modules<F, T>(&mut self, init_fn: F) -> T
where F: FnOnce(&mut Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>, &dyn Api, &mut dyn Storage) -> T,

Source

pub fn read_module<F, T>(&self, query_fn: F) -> T
where F: FnOnce(&Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT, StargateT>, &dyn Api, &dyn Storage) -> T,

Source

pub fn store_code( &mut self, code: Box<dyn Contract<<CustomT as Module>::ExecT, <CustomT as Module>::QueryT>>, ) -> u64

Registers contract code (like uploading wasm bytecode on a chain), so it can later be used to instantiate a contract.

Source

pub fn store_code_with_creator( &mut self, creator: Addr, code: Box<dyn Contract<<CustomT as Module>::ExecT, <CustomT as Module>::QueryT>>, ) -> u64

Registers contract code (like store_code), but takes the address of the code creator as an additional argument.

Source

pub fn duplicate_code(&mut self, code_id: u64) -> Result<u64, Error>

Duplicates the contract code identified by code_id and returns the identifier of the newly created copy of the contract code.

§Examples
use cosmwasm_std::Addr;
use cw_multi_test::App;

// contract implementation
mod echo {
  // contract entry points not shown here
  pub fn contract() -> Box<dyn Contract<Empty>> {
    // should return the contract
  }
}

let mut app = App::default();

// store a new contract, save the code id
let code_id = app.store_code(echo::contract());

// duplicate the existing contract, duplicated contract has different code id
assert_ne!(code_id, app.duplicate_code(code_id).unwrap());

// zero is an invalid identifier for contract code, returns an error
assert_eq!("code id: invalid", app.duplicate_code(0).unwrap_err().to_string());

// there is no contract code with identifier 100 stored yet, returns an error
assert_eq!("code id 100: no such code", app.duplicate_code(100).unwrap_err().to_string());
Source

pub fn contract_data(&self, address: &Addr) -> Result<ContractData, Error>

Returns ContractData for the contract with specified address.

Source

pub fn dump_wasm_raw(&self, address: &Addr) -> Vec<(Vec<u8>, Vec<u8>)>

Returns a raw state dump of all key-values held by a contract with specified address.

Source

pub fn set_block(&mut self, block: BlockInfo)

Source

pub fn update_block<F>(&mut self, action: F)
where F: Fn(&mut BlockInfo),

Source

pub fn block_info(&self) -> BlockInfo

Returns a copy of the current block_info

Source

pub fn wrap(&self) -> QuerierWrapper<'_, <CustomT as Module>::QueryT>

Simple helper so we get access to all the QuerierWrapper helpers, eg. wrap().query_wasm_smart, query_all_balances, …

Source

pub fn execute_multi( &mut self, sender: Addr, msgs: Vec<CosmosMsg<<CustomT as Module>::ExecT>>, ) -> Result<Vec<AppResponse>, Error>

Runs multiple CosmosMsg in one atomic operation. This will create a cache before the execution, so no state changes are persisted if any of them return an error. But all writes are persisted on success.

Source

pub fn wasm_sudo<T, U>( &mut self, contract_addr: U, msg: &T, ) -> Result<AppResponse, Error>
where T: Serialize, U: Into<Addr>,

Call a smart contract in “sudo” mode. This will create a cache before the execution, so no state changes are persisted if this returns an error, but all are persisted on success.

Source

pub fn sudo(&mut self, msg: SudoMsg) -> Result<AppResponse, Error>

Runs arbitrary SudoMsg. This will create a cache before the execution, so no state changes are persisted if this returns an error, but all are persisted on success.

Trait Implementations§

Source§

impl Default for CyberApp

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for CyberApp

Source§

type Target = App<BankKeeper, MockApi, MemoryStorage, CyberModule, WasmKeeper<CyberMsg, CyberQuery>>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for CyberApp

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Querier for CyberApp

Source§

fn raw_query(&self, bin_request: &[u8]) -> QuerierResult

raw_query is all that must be implemented for the Querier. This allows us to pass through binary queries from one level to another without knowing the custom format, or we can decode it, with the knowledge of the allowed types. People using the querier probably want one of the simpler auto-generated helper methods

Auto Trait Implementations§

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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. 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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.