1
1
use std:: { cell:: RefCell , fmt:: Debug , io:: Read , rc:: Rc } ;
2
2
3
+ use clone_cw_multi_test:: tokenfactory:: TokenFactoryStargate ;
4
+ use clone_cw_multi_test:: wasm_emulation:: query:: ContainsRemote ;
3
5
use clone_cw_multi_test:: {
4
- addons:: { MockAddressGenerator , MockApiBech32 } ,
5
6
wasm_emulation:: { channel:: RemoteChannel , storage:: analyzer:: StorageAnalyzer } ,
6
7
App , AppBuilder , BankKeeper , Contract , Executor , WasmKeeper ,
7
8
} ;
9
+ use clone_cw_multi_test:: {
10
+ DistributionKeeper , FailingModule , GovFailingModule , IbcFailingModule , MockApiBech32 ,
11
+ StakeKeeper ,
12
+ } ;
13
+ use cosmwasm_std:: testing:: MockStorage ;
8
14
use cosmwasm_std:: {
9
15
to_json_binary, Addr , BankMsg , Binary , Coin , CosmosMsg , Empty , Event , StdError , StdResult ,
10
16
Uint128 , WasmMsg ,
@@ -26,7 +32,18 @@ use crate::{contract::CloneTestingContract, queriers::bank::CloneBankQuerier};
26
32
27
33
use super :: state:: MockState ;
28
34
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
+ > ;
30
47
31
48
/// Wrapper around a cw-multi-test [`App`](cw_multi_test::App) backend.
32
49
///
@@ -77,9 +94,20 @@ pub struct CloneTesting<S: StateInterface = MockState> {
77
94
}
78
95
79
96
impl 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)
83
111
}
84
112
85
113
/// Set the bank balance of an address.
@@ -154,6 +182,7 @@ impl CloneTesting {
154
182
let code_id = self . app . borrow_mut ( ) . store_wasm_code ( wasm) ;
155
183
156
184
contract. set_code_id ( code_id) ;
185
+ println ! ( "{code_id}" ) ;
157
186
158
187
// add contract code_id to events manually
159
188
let mut event = Event :: new ( "store_code" ) ;
@@ -229,9 +258,7 @@ impl<S: StateInterface> CloneTesting<S> {
229
258
)
230
259
. unwrap ( ) ;
231
260
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 ( ) ) ;
235
262
236
263
let bank = BankKeeper :: new ( ) . with_remote ( remote_channel. clone ( ) ) ;
237
264
@@ -247,10 +274,11 @@ impl<S: StateInterface> CloneTesting<S> {
247
274
. with_bank ( bank)
248
275
. with_api ( MockApiBech32 :: new ( & pub_address_prefix) )
249
276
. with_block ( block_info)
250
- . with_remote ( remote_channel. clone ( ) ) ;
277
+ . with_remote ( remote_channel. clone ( ) )
278
+ . with_stargate ( TokenFactoryStargate ) ;
251
279
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" ) ;
254
282
255
283
Ok ( Self {
256
284
chain,
@@ -573,7 +601,7 @@ mod test {
573
601
let chain = CloneTesting :: new ( chain_info) ?;
574
602
575
603
let sender = chain. sender_addr ( ) ;
576
- let recipient = & chain. init_account ( ) ;
604
+ let recipient = & chain. addr_make ( "recipient" ) ;
577
605
578
606
chain
579
607
. set_balance ( recipient, vec ! [ Coin :: new( amount, denom) ] )
@@ -657,7 +685,7 @@ mod test {
657
685
let mock_state = MockState :: new ( JUNO_1 . into ( ) , "default_id" ) ;
658
686
659
687
let chain: CloneTesting = CloneTesting :: < _ > :: new_custom ( & rt, chain, mock_state) ?;
660
- let recipient = chain. init_account ( ) ;
688
+ let recipient = chain. addr_make ( "recipient" ) ;
661
689
662
690
chain
663
691
. set_balances ( & [ ( & recipient, & [ Coin :: new ( amount, denom) ] ) ] )
@@ -705,7 +733,7 @@ mod test {
705
733
let chain_info = JUNO_1 ;
706
734
707
735
let chain = CloneTesting :: new ( chain_info) ?;
708
- let recipient = & chain. init_account ( ) ;
736
+ let recipient = & chain. addr_make ( "recipient" ) ;
709
737
710
738
chain
711
739
. add_balance ( recipient, vec ! [ Coin :: new( amount, denom_1) ] )
0 commit comments