Trait TestingContract

Source
pub trait TestingContract<IM, EM, QM, MM = Empty>
where IM: Serialize, EM: Serialize + Debug, QM: Serialize, MM: Serialize,
{ // Required methods fn wrapper() -> Box<dyn Contract<Empty>>; fn default_init(app: &mut App, env: &Env) -> IM; fn new(app: &mut App, env: &Env, msg: Option<IM>) -> Self; fn addr(&self) -> &Addr; // Provided methods fn store_code(app: &mut App) -> u64 { ... } fn instantiate(app: &mut App, code_id: u64, label: &str, msg: &IM) -> Addr { ... } fn set_contract_addr(app: &mut App, label: &str, addr: &Addr) { ... } fn get_contract_addr(app: &App, label: &str) -> Addr { ... } fn execute( &self, app: &mut App, sender: &Addr, msg: &EM, ) -> AnyResult<AppResponse> { ... } fn execute_with_funds( &self, app: &mut App, sender: &Addr, msg: &EM, funds: Vec<Coin>, ) -> AnyResult<AppResponse> { ... } fn query<T: DeserializeOwned>(&self, app: &App, msg: &QM) -> StdResult<T> { ... } fn migrate( &self, app: &mut App, sender: &Addr, msg: &MM, ) -> AnyResult<AppResponse> { ... } }
Expand description

TestingContract is a trait that provides a common interface for setting up testing contracts.

Required Methods§

Source

fn wrapper() -> Box<dyn Contract<Empty>>

Source

fn default_init(app: &mut App, env: &Env) -> IM

Source

fn new(app: &mut App, env: &Env, msg: Option<IM>) -> Self

Source

fn addr(&self) -> &Addr

Provided Methods§

Source

fn store_code(app: &mut App) -> u64

Source

fn instantiate(app: &mut App, code_id: u64, label: &str, msg: &IM) -> Addr

Source

fn set_contract_addr(app: &mut App, label: &str, addr: &Addr)

Set the contract address in the storage for the given label. Using the storage system for easy orchestration of contract addresses for testing.

Source

fn get_contract_addr(app: &App, label: &str) -> Addr

Get the contract address in the storage for the given label.

Source

fn execute( &self, app: &mut App, sender: &Addr, msg: &EM, ) -> AnyResult<AppResponse>

Source

fn execute_with_funds( &self, app: &mut App, sender: &Addr, msg: &EM, funds: Vec<Coin>, ) -> AnyResult<AppResponse>

Source

fn query<T: DeserializeOwned>(&self, app: &App, msg: &QM) -> StdResult<T>

Source

fn migrate( &self, app: &mut App, sender: &Addr, msg: &MM, ) -> AnyResult<AppResponse>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§