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, ) -> Result<AppResponse, Error> { ... } fn execute_with_funds( &self, app: &mut App, sender: &Addr, msg: &EM, funds: Vec<Coin>, ) -> Result<AppResponse, Error> { ... } fn query<T>(&self, app: &App, msg: &QM) -> Result<T, StdError> where T: DeserializeOwned { ... } fn migrate( &self, app: &mut App, sender: &Addr, msg: &MM, ) -> Result<AppResponse, Error> { ... } }
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, ) -> Result<AppResponse, Error>

Source

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

Source

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

Source

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

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.

Implementations on Foreign Types§

Source§

impl TestingContract<InstantiateMsg, ExecuteMsg, QueryMsg> for GuardrailContract

Source§

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

Source§

fn default_init(app: &mut App, _env: &Env) -> InstantiateMsg

Source§

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

Source§

fn addr(&self) -> &Addr

Implementors§