pub struct CloneTesting<S: StateInterface = MockState> {
pub chain: ChainInfoOwned,
pub sender: Addr,
pub state: Rc<RefCell<S>>,
pub app: Rc<RefCell<App<BankKeeper, MockApiBech32>>>,
}Expand description
Wrapper around a cw-multi-test App backend.
Stores a local state with a mapping of contract_id -> code_id/address
The state is customizable by implementing the StateInterface trait on a custom struct and providing it on the custom constructor.
§Example
use cw_orch_clone_testing::CloneTesting;
use cw_orch_core::environment::TxHandler;
let chain = cw_orch_daemon::networks::JUNO_1;
let mock: CloneTesting = CloneTesting::new(chain.clone()).unwrap();
let sender = mock.sender();
// set a balance
mock.set_balance(&sender, vec![coin(100u128, "token")]).unwrap();
// query the balance
let balance: Uint128 = mock.query_balance(&sender, "token").unwrap();
assert_eq!(balance.u128(), 100u128);§Example with custom state
use cw_orch_clone_testing::CloneTesting;
use cw_orch_core::environment::StateInterface;
// We just use the MockState as an example here, but you can implement your own state struct.
use cw_orch_clone_testing::MockState as CustomState;
let rt = tokio::runtime::Runtime::new().unwrap();
let chain = cw_orch_daemon::networks::JUNO_1;
let mock: CloneTesting = CloneTesting::new_custom(&rt, chain.clone(), CustomState::new(chain.clone().into(), "mock")).unwrap();Fields§
§chain: ChainInfoOwnedChain data of the chain you want to fork
sender: AddrAddress used for the operations.
state: Rc<RefCell<S>>Inner mutable state storage for contract addresses and code-ids
app: Rc<RefCell<App<BankKeeper, MockApiBech32>>>Inner mutable cw-multi-test app backend
Implementations§
Source§impl CloneTesting
impl CloneTesting
Sourcepub fn init_account(&self) -> Addr
pub fn init_account(&self) -> Addr
Ceates a new valid account
Sourcepub fn set_balance(
&self,
address: &Addr,
amount: Vec<Coin>,
) -> Result<(), CwEnvError>
pub fn set_balance( &self, address: &Addr, amount: Vec<Coin>, ) -> Result<(), CwEnvError>
Set the bank balance of an address.
Sourcepub fn add_balance(
&self,
address: &Addr,
amount: Vec<Coin>,
) -> Result<(), CwEnvError>
pub fn add_balance( &self, address: &Addr, amount: Vec<Coin>, ) -> Result<(), CwEnvError>
Adds the bank balance of an address.
Sourcepub fn set_balances(
&self,
balances: &[(&Addr, &[Coin])],
) -> Result<(), CwEnvError>
pub fn set_balances( &self, balances: &[(&Addr, &[Coin])], ) -> Result<(), CwEnvError>
Set the balance for multiple coins at once.
Sourcepub fn query_balance(
&self,
address: &Addr,
denom: &str,
) -> Result<Uint128, CwEnvError>
pub fn query_balance( &self, address: &Addr, denom: &str, ) -> Result<Uint128, CwEnvError>
Query the (bank) balance of a native token for and address. Returns the amount of the native token.
Sourcepub fn query_all_balances(
&self,
address: &Addr,
) -> Result<Vec<Coin>, CwEnvError>
pub fn query_all_balances( &self, address: &Addr, ) -> Result<Vec<Coin>, CwEnvError>
Fetch all the balances of an address.
pub fn upload_wasm<T: Uploadable + ContractInstance<CloneTesting>>( &self, contract: &T, ) -> Result<<Self as TxHandler>::Response, CwEnvError>
Source§impl CloneTesting<MockState>
impl CloneTesting<MockState>
Sourcepub fn new(chain: impl Into<ChainInfoOwned>) -> Result<Self, CwEnvError>
pub fn new(chain: impl Into<ChainInfoOwned>) -> Result<Self, CwEnvError>
Create a mock environment with the default mock state.
Sourcepub fn new_with_runtime(
rt: &Runtime,
chain: impl Into<ChainInfoOwned>,
) -> Result<Self, CwEnvError>
pub fn new_with_runtime( rt: &Runtime, chain: impl Into<ChainInfoOwned>, ) -> Result<Self, CwEnvError>
Create a mock environment with the default mock state. It uses a custom runtime object to control async requests
pub fn new_with_deployment_id( rt: &Runtime, chain: impl Into<ChainInfoOwned>, deployment_id: &str, ) -> Result<Self, CwEnvError>
Source§impl<S: StateInterface> CloneTesting<S>
impl<S: StateInterface> CloneTesting<S>
Sourcepub fn new_custom(
rt: &Runtime,
chain: impl Into<ChainInfoOwned>,
custom_state: S,
) -> Result<Self, CwEnvError>
pub fn new_custom( rt: &Runtime, chain: impl Into<ChainInfoOwned>, custom_state: S, ) -> Result<Self, CwEnvError>
Create a mock environment with a custom mock state.
The state is customizable by implementing the StateInterface trait on a custom struct and providing it on the custom constructor.
pub fn storage_analysis(&self) -> StorageAnalyzer
Trait Implementations§
Source§impl BankSetter for CloneTesting
impl BankSetter for CloneTesting
Source§impl<S: StateInterface> ChainState for CloneTesting<S>
impl<S: StateInterface> ChainState for CloneTesting<S>
Source§impl<S: Clone + StateInterface> Clone for CloneTesting<S>
impl<S: Clone + StateInterface> Clone for CloneTesting<S>
Source§fn clone(&self) -> CloneTesting<S>
fn clone(&self) -> CloneTesting<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl DefaultQueriers for CloneTesting
impl DefaultQueriers for CloneTesting
type Bank = CloneBankQuerier
type Wasm = CloneWasmQuerier<MockState>
type Node = CloneNodeQuerier
fn bank_querier(&self) -> Self::Bank
fn wasm_querier(&self) -> Self::Wasm
fn node_querier(&self) -> Self::Node
Source§impl EnvironmentQuerier for CloneTesting
impl EnvironmentQuerier for CloneTesting
Source§fn env_info(&self) -> EnvironmentInfo
fn env_info(&self) -> EnvironmentInfo
Source§impl<S: StateInterface> QuerierGetter<CloneBankQuerier> for CloneTesting<S>
impl<S: StateInterface> QuerierGetter<CloneBankQuerier> for CloneTesting<S>
fn querier(&self) -> CloneBankQuerier
Source§impl<S: StateInterface> QuerierGetter<CloneNodeQuerier> for CloneTesting<S>
impl<S: StateInterface> QuerierGetter<CloneNodeQuerier> for CloneTesting<S>
fn querier(&self) -> CloneNodeQuerier
Source§impl<S: StateInterface> QuerierGetter<CloneWasmQuerier<S>> for CloneTesting<S>
impl<S: StateInterface> QuerierGetter<CloneWasmQuerier<S>> for CloneTesting<S>
fn querier(&self) -> CloneWasmQuerier<S>
Source§impl QueryHandler for CloneTesting
impl QueryHandler for CloneTesting
type Error = CwEnvError
Source§fn wait_blocks(&self, amount: u64) -> Result<(), CwEnvError>
fn wait_blocks(&self, amount: u64) -> Result<(), CwEnvError>
Source§fn wait_seconds(&self, secs: u64) -> Result<(), CwEnvError>
fn wait_seconds(&self, secs: u64) -> Result<(), CwEnvError>
Source§fn next_block(&self) -> Result<(), CwEnvError>
fn next_block(&self) -> Result<(), CwEnvError>
Source§fn block_info(&self) -> Result<BlockInfo, <Self::Node as Querier>::Error>
fn block_info(&self) -> Result<BlockInfo, <Self::Node as Querier>::Error>
BlockInfo.fn balance( &self, address: &Addr, denom: Option<String>, ) -> Result<Vec<Coin>, <Self::Bank as Querier>::Error>
Source§impl<S: StateInterface> TxHandler for CloneTesting<S>
impl<S: StateInterface> TxHandler for CloneTesting<S>
Source§type Error = CwEnvError
type Error = CwEnvError
type Sender = Addr
Source§fn sender_addr(&self) -> Addr
fn sender_addr(&self) -> Addr
Source§fn set_sender(&mut self, sender: Self::Sender)
fn set_sender(&mut self, sender: Self::Sender)
Source§fn upload<T: Uploadable>(
&self,
_contract: &T,
) -> Result<Self::Response, CwEnvError>
fn upload<T: Uploadable>( &self, _contract: &T, ) -> Result<Self::Response, CwEnvError>
Source§fn upload_with_access_config<T: Uploadable>(
&self,
contract_source: &T,
_access_config: Option<AccessConfig>,
) -> Result<Self::Response, Self::Error>
fn upload_with_access_config<T: Uploadable>( &self, contract_source: &T, _access_config: Option<AccessConfig>, ) -> Result<Self::Response, Self::Error>
Source§fn execute<E: Serialize + Debug>(
&self,
exec_msg: &E,
coins: &[Coin],
contract_address: &Addr,
) -> Result<Self::Response, CwEnvError>
fn execute<E: Serialize + Debug>( &self, exec_msg: &E, coins: &[Coin], contract_address: &Addr, ) -> Result<Self::Response, CwEnvError>
Source§fn instantiate<I: Serialize + Debug>(
&self,
code_id: u64,
init_msg: &I,
label: Option<&str>,
admin: Option<&Addr>,
coins: &[Coin],
) -> Result<Self::Response, CwEnvError>
fn instantiate<I: Serialize + Debug>( &self, code_id: u64, init_msg: &I, label: Option<&str>, admin: Option<&Addr>, coins: &[Coin], ) -> Result<Self::Response, CwEnvError>
Source§fn migrate<M: Serialize + Debug>(
&self,
migrate_msg: &M,
new_code_id: u64,
contract_address: &Addr,
) -> Result<Self::Response, CwEnvError>
fn migrate<M: Serialize + Debug>( &self, migrate_msg: &M, new_code_id: u64, contract_address: &Addr, ) -> Result<Self::Response, CwEnvError>
Source§fn instantiate2<I: Serialize + Debug>(
&self,
code_id: u64,
init_msg: &I,
label: Option<&str>,
admin: Option<&Addr>,
coins: &[Coin],
salt: Binary,
) -> Result<Self::Response, Self::Error>
fn instantiate2<I: Serialize + Debug>( &self, code_id: u64, init_msg: &I, label: Option<&str>, admin: Option<&Addr>, coins: &[Coin], salt: Binary, ) -> Result<Self::Response, Self::Error>
fn bank_send( &self, receiver: &Addr, amount: &[Coin], ) -> Result<Self::Response, Self::Error>
Source§impl<T> WasmUpload<CloneTesting> for T
impl<T> WasmUpload<CloneTesting> for T
fn upload_wasm( &self, ) -> Result<<CloneTesting as TxHandler>::Response, CwEnvError>
Auto Trait Implementations§
impl<S> Freeze for CloneTesting<S>
impl<S = MockState> !RefUnwindSafe for CloneTesting<S>
impl<S = MockState> !Send for CloneTesting<S>
impl<S = MockState> !Sync for CloneTesting<S>
impl<S> Unpin for CloneTesting<S>
impl<S = MockState> !UnwindSafe for CloneTesting<S>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request