pub trait TestingContract<IM, EM, QM, MM = Empty>{
// 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§
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
Sourcefn set_contract_addr(app: &mut App, label: &str, addr: &Addr)
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.
Sourcefn get_contract_addr(app: &App, label: &str) -> Addr
fn get_contract_addr(app: &App, label: &str) -> Addr
Get the contract address in the storage for the given label.
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>
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.