11use std:: { cell:: RefCell , fmt:: Debug , io:: Read , rc:: Rc } ;
22
3+ use clone_cw_multi_test:: tokenfactory:: TokenFactoryStargate ;
4+ use clone_cw_multi_test:: wasm_emulation:: query:: ContainsRemote ;
35use clone_cw_multi_test:: {
4- addons:: { MockAddressGenerator , MockApiBech32 } ,
56 wasm_emulation:: { channel:: RemoteChannel , storage:: analyzer:: StorageAnalyzer } ,
67 App , AppBuilder , BankKeeper , Contract , Executor , WasmKeeper ,
78} ;
9+ use clone_cw_multi_test:: {
10+ DistributionKeeper , FailingModule , GovFailingModule , IbcFailingModule , MockApiBech32 ,
11+ StakeKeeper ,
12+ } ;
13+ use cosmwasm_std:: testing:: MockStorage ;
814use cosmwasm_std:: {
915 to_json_binary, Addr , BankMsg , Binary , Coin , CosmosMsg , Empty , Event , StdError , StdResult ,
1016 Uint128 , WasmMsg ,
@@ -26,7 +32,18 @@ use crate::{contract::CloneTestingContract, queriers::bank::CloneBankQuerier};
2632
2733use super :: state:: MockState ;
2834
29- pub type CloneTestingApp = App < BankKeeper , MockApiBech32 > ;
35+ pub type CloneTestingApp = App <
36+ BankKeeper ,
37+ MockApiBech32 ,
38+ MockStorage ,
39+ FailingModule < Empty , Empty , Empty > ,
40+ WasmKeeper < Empty , Empty > ,
41+ StakeKeeper ,
42+ DistributionKeeper ,
43+ IbcFailingModule ,
44+ GovFailingModule ,
45+ TokenFactoryStargate ,
46+ > ;
3047
3148/// Wrapper around a cw-multi-test [`App`](cw_multi_test::App) backend.
3249///
@@ -77,9 +94,20 @@ pub struct CloneTesting<S: StateInterface = MockState> {
7794}
7895
7996impl CloneTesting {
80- /// Ceates a new valid account
81- pub fn init_account ( & self ) -> Addr {
82- self . app . borrow_mut ( ) . next_address ( )
97+ /// Creates a new valid account
98+ pub fn addr_make ( & self , account_name : impl Into < String > ) -> Addr {
99+ self . app . borrow ( ) . api ( ) . addr_make ( & account_name. into ( ) )
100+ }
101+
102+ pub fn addr_make_with_balance (
103+ & self ,
104+ account_name : impl Into < String > ,
105+ balance : Vec < Coin > ,
106+ ) -> Result < Addr , CwEnvError > {
107+ let addr = self . app . borrow ( ) . api ( ) . addr_make ( & account_name. into ( ) ) ;
108+ self . set_balance ( & addr, balance) ?;
109+
110+ Ok ( addr)
83111 }
84112
85113 /// Set the bank balance of an address.
@@ -154,6 +182,7 @@ impl CloneTesting {
154182 let code_id = self . app . borrow_mut ( ) . store_wasm_code ( wasm) ;
155183
156184 contract. set_code_id ( code_id) ;
185+ println ! ( "{code_id}" ) ;
157186
158187 // add contract code_id to events manually
159188 let mut event = Event :: new ( "store_code" ) ;
@@ -229,9 +258,7 @@ impl<S: StateInterface> CloneTesting<S> {
229258 )
230259 . unwrap ( ) ;
231260
232- let wasm = WasmKeeper :: < Empty , Empty > :: new ( )
233- . with_remote ( remote_channel. clone ( ) )
234- . with_address_generator ( MockAddressGenerator ) ;
261+ let wasm = WasmKeeper :: < Empty , Empty > :: new ( ) . with_remote ( remote_channel. clone ( ) ) ;
235262
236263 let bank = BankKeeper :: new ( ) . with_remote ( remote_channel. clone ( ) ) ;
237264
@@ -247,10 +274,11 @@ impl<S: StateInterface> CloneTesting<S> {
247274 . with_bank ( bank)
248275 . with_api ( MockApiBech32 :: new ( & pub_address_prefix) )
249276 . with_block ( block_info)
250- . with_remote ( remote_channel. clone ( ) ) ;
277+ . with_remote ( remote_channel. clone ( ) )
278+ . with_stargate ( TokenFactoryStargate ) ;
251279
252- let app = Rc :: new ( RefCell :: new ( app. build ( |_, _, _| { } ) ? ) ) ;
253- let sender = app. borrow_mut ( ) . next_address ( ) ;
280+ let app = Rc :: new ( RefCell :: new ( app. build ( |_, _, _| { } ) ) ) ;
281+ let sender = app. borrow ( ) . api ( ) . addr_make ( "sender" ) ;
254282
255283 Ok ( Self {
256284 chain,
@@ -573,7 +601,7 @@ mod test {
573601 let chain = CloneTesting :: new ( chain_info) ?;
574602
575603 let sender = chain. sender_addr ( ) ;
576- let recipient = & chain. init_account ( ) ;
604+ let recipient = & chain. addr_make ( "recipient" ) ;
577605
578606 chain
579607 . set_balance ( recipient, vec ! [ Coin :: new( amount, denom) ] )
@@ -657,7 +685,7 @@ mod test {
657685 let mock_state = MockState :: new ( JUNO_1 . into ( ) , "default_id" ) ;
658686
659687 let chain: CloneTesting = CloneTesting :: < _ > :: new_custom ( & rt, chain, mock_state) ?;
660- let recipient = chain. init_account ( ) ;
688+ let recipient = chain. addr_make ( "recipient" ) ;
661689
662690 chain
663691 . set_balances ( & [ ( & recipient, & [ Coin :: new ( amount, denom) ] ) ] )
@@ -705,7 +733,7 @@ mod test {
705733 let chain_info = JUNO_1 ;
706734
707735 let chain = CloneTesting :: new ( chain_info) ?;
708- let recipient = & chain. init_account ( ) ;
736+ let recipient = & chain. addr_make ( "recipient" ) ;
709737
710738 chain
711739 . add_balance ( recipient, vec ! [ Coin :: new( amount, denom_1) ] )
0 commit comments