diff --git a/Cargo.toml b/Cargo.toml index 20d608dd7..474d8d998 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,8 @@ cosmwasm-std = { version = "2.1" } cw-storage-plus = { version = "2.0.0" } cw-utils = { version = "2.0.0" } -cw-multi-test = { package = "abstract-cw-multi-test", version = "2.0.2", features = ["cosmwasm_1_2"] } +# cw-multi-test = { package = "abstract-cw-multi-test", version = "2.0.2", features = ["cosmwasm_1_2"] } +cw-multi-test = { package = "abstract-cw-multi-test", git = "https://github.com/abstractsdk/cw-multi-test-fork", branch = "token-factory-integration", version = "2.0.2", features = ["cosmwasm_1_2", "tokenfactory"] } cw20 = { version = "2.0.0" } cw20-base = { version = "2.0.0" } diff --git a/packages/clone-testing/Cargo.toml b/packages/clone-testing/Cargo.toml index e2bc6fafd..192477749 100644 --- a/packages/clone-testing/Cargo.toml +++ b/packages/clone-testing/Cargo.toml @@ -5,7 +5,7 @@ edition.workspace = true license.workspace = true name = "cw-orch-clone-testing" repository.workspace = true -version = "0.9.2" +version = "0.10.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,7 +16,9 @@ cw-orch-core = { workspace = true } cw-orch-daemon = { workspace = true } cw-orch-mock = { workspace = true } -clone-cw-multi-test = { version = "0.6.1" } +# clone-cw-multi-test = { version = "0.7.0" } +# clone-cw-multi-test = { path = "../../../cw-multi-test-fork", features = ["cosmwasm_1_2", "tokenfactory", "staking"] } +clone-cw-multi-test = { git = "https://github.com/abstractsdk/cw-multi-test-fork", branch = "adapt_for_local_execution", features = ["cosmwasm_1_2", "stargate", "tokenfactory", "staking"] } anyhow = { workspace = true } cw-utils = { workspace = true } diff --git a/packages/clone-testing/src/core.rs b/packages/clone-testing/src/core.rs index fb4e43bb0..758070912 100644 --- a/packages/clone-testing/src/core.rs +++ b/packages/clone-testing/src/core.rs @@ -1,10 +1,16 @@ use std::{cell::RefCell, fmt::Debug, io::Read, rc::Rc}; +use clone_cw_multi_test::tokenfactory::TokenFactoryStargate; +use clone_cw_multi_test::wasm_emulation::query::ContainsRemote; use clone_cw_multi_test::{ - addons::{MockAddressGenerator, MockApiBech32}, wasm_emulation::{channel::RemoteChannel, storage::analyzer::StorageAnalyzer}, App, AppBuilder, BankKeeper, Contract, Executor, WasmKeeper, }; +use clone_cw_multi_test::{ + DistributionKeeper, FailingModule, GovFailingModule, IbcFailingModule, MockApiBech32, + StakeKeeper, +}; +use cosmwasm_std::testing::MockStorage; use cosmwasm_std::{ to_json_binary, Addr, BankMsg, Binary, Coin, CosmosMsg, Empty, Event, StdError, StdResult, Uint128, WasmMsg, @@ -26,7 +32,18 @@ use crate::{contract::CloneTestingContract, queriers::bank::CloneBankQuerier}; use super::state::MockState; -pub type CloneTestingApp = App; +pub type CloneTestingApp = App< + BankKeeper, + MockApiBech32, + MockStorage, + FailingModule, + WasmKeeper, + StakeKeeper, + DistributionKeeper, + IbcFailingModule, + GovFailingModule, + TokenFactoryStargate, +>; /// Wrapper around a cw-multi-test [`App`](cw_multi_test::App) backend. /// @@ -77,9 +94,20 @@ pub struct CloneTesting { } impl CloneTesting { - /// Ceates a new valid account - pub fn init_account(&self) -> Addr { - self.app.borrow_mut().next_address() + /// Creates a new valid account + pub fn addr_make(&self, account_name: impl Into) -> Addr { + self.app.borrow().api().addr_make(&account_name.into()) + } + + pub fn addr_make_with_balance( + &self, + account_name: impl Into, + balance: Vec, + ) -> Result { + let addr = self.app.borrow().api().addr_make(&account_name.into()); + self.set_balance(&addr, balance)?; + + Ok(addr) } /// Set the bank balance of an address. @@ -154,6 +182,7 @@ impl CloneTesting { let code_id = self.app.borrow_mut().store_wasm_code(wasm); contract.set_code_id(code_id); + println!("{code_id}"); // add contract code_id to events manually let mut event = Event::new("store_code"); @@ -229,9 +258,7 @@ impl CloneTesting { ) .unwrap(); - let wasm = WasmKeeper::::new() - .with_remote(remote_channel.clone()) - .with_address_generator(MockAddressGenerator); + let wasm = WasmKeeper::::new().with_remote(remote_channel.clone()); let bank = BankKeeper::new().with_remote(remote_channel.clone()); @@ -247,10 +274,11 @@ impl CloneTesting { .with_bank(bank) .with_api(MockApiBech32::new(&pub_address_prefix)) .with_block(block_info) - .with_remote(remote_channel.clone()); + .with_remote(remote_channel.clone()) + .with_stargate(TokenFactoryStargate); - let app = Rc::new(RefCell::new(app.build(|_, _, _| {})?)); - let sender = app.borrow_mut().next_address(); + let app = Rc::new(RefCell::new(app.build(|_, _, _| {}))); + let sender = app.borrow().api().addr_make("sender"); Ok(Self { chain, @@ -573,7 +601,7 @@ mod test { let chain = CloneTesting::new(chain_info)?; let sender = chain.sender_addr(); - let recipient = &chain.init_account(); + let recipient = &chain.addr_make("recipient"); chain .set_balance(recipient, vec![Coin::new(amount, denom)]) @@ -657,7 +685,7 @@ mod test { let mock_state = MockState::new(JUNO_1.into(), "default_id"); let chain: CloneTesting = CloneTesting::<_>::new_custom(&rt, chain, mock_state)?; - let recipient = chain.init_account(); + let recipient = chain.addr_make("recipient"); chain .set_balances(&[(&recipient, &[Coin::new(amount, denom)])]) @@ -705,7 +733,7 @@ mod test { let chain_info = JUNO_1; let chain = CloneTesting::new(chain_info)?; - let recipient = &chain.init_account(); + let recipient = &chain.addr_make("recipient"); chain .add_balance(recipient, vec![Coin::new(amount, denom_1)]) diff --git a/packages/clone-testing/tests/wasm-upload.rs b/packages/clone-testing/tests/wasm-upload.rs index a48e0a8cb..06af7e059 100644 --- a/packages/clone-testing/tests/wasm-upload.rs +++ b/packages/clone-testing/tests/wasm-upload.rs @@ -2,11 +2,13 @@ use counter_contract::CounterContract; use cw_orch::prelude::*; use cw_orch_clone_testing::CloneTesting; use cw_orch_daemon::networks::JUNO_1; +use networks::OSMOSIS_1; #[test] fn multiple_upload() -> anyhow::Result<()> { + let mut chain = OSMOSIS_1; // ANCHOR: clone_testing_setup - let chain = CloneTesting::new(JUNO_1)?; + let chain = CloneTesting::new(chain)?; // ANCHOR_END: clone_testing_setup // ANCHOR: counter_contract_setup let contract = CounterContract::new(chain.clone()); diff --git a/packages/cw-orch-mock/src/bech32.rs b/packages/cw-orch-mock/src/bech32.rs index 4759ea0ee..48f9708f3 100644 --- a/packages/cw-orch-mock/src/bech32.rs +++ b/packages/cw-orch-mock/src/bech32.rs @@ -1,7 +1,7 @@ use std::{cell::RefCell, rc::Rc}; use cosmwasm_std::{testing::MockApi, Addr, Coin, Uint128}; -use cw_multi_test::{AppBuilder, MockApiBech32}; +use cw_multi_test::{AppBuilder, MockApiBech32, TokenFactoryStargate}; use cw_orch_core::{ environment::{BankQuerier, BankSetter, DefaultQueriers, StateInterface, TxHandler}, CwEnvError, @@ -74,6 +74,7 @@ impl MockBase { let app = Rc::new(RefCell::new( AppBuilder::new_custom() .with_api(MockApiBech32::new(prefix)) + .with_stargate(TokenFactoryStargate) .build(|_, _, _| {}), )); diff --git a/packages/cw-orch-mock/src/core.rs b/packages/cw-orch-mock/src/core.rs index 9345de531..c131e5faa 100644 --- a/packages/cw-orch-mock/src/core.rs +++ b/packages/cw-orch-mock/src/core.rs @@ -6,7 +6,7 @@ use cosmwasm_std::{ }; use cw_multi_test::{ ibc::IbcSimpleModule, App, AppResponse, BankKeeper, Contract, DistributionKeeper, Executor, - FailingModule, GovFailingModule, MockApiBech32, StakeKeeper, StargateFailing, WasmKeeper, + FailingModule, GovFailingModule, MockApiBech32, StakeKeeper, TokenFactoryStargate, WasmKeeper, }; use serde::Serialize; @@ -27,7 +27,7 @@ pub type MockApp = App< DistributionKeeper, IbcSimpleModule, GovFailingModule, - StargateFailing, + TokenFactoryStargate, >; /// Wrapper around a cw-multi-test [`App`](cw_multi_test::App) backend. diff --git a/packages/cw-orch-mock/src/simple.rs b/packages/cw-orch-mock/src/simple.rs index fc51f5132..ad8838111 100644 --- a/packages/cw-orch-mock/src/simple.rs +++ b/packages/cw-orch-mock/src/simple.rs @@ -3,7 +3,7 @@ use std::rc::Rc; use cosmwasm_std::testing::MockApi; use cosmwasm_std::{Addr, Coin, Uint128}; -use cw_multi_test::AppBuilder; +use cw_multi_test::{AppBuilder, TokenFactoryStargate}; use cw_orch_core::environment::{BankQuerier, BankSetter, TxHandler}; use cw_orch_core::{ environment::{DefaultQueriers, StateInterface}, @@ -105,7 +105,9 @@ impl Mock { /// The state is customizable by implementing the `StateInterface` trait on a custom struct and providing it on the custom constructor. pub fn new_custom(sender: impl Into, custom_state: S) -> Self { let state = Rc::new(RefCell::new(custom_state)); - let app = AppBuilder::new_custom().build(|_, _, _| {}); + let app = AppBuilder::new_custom() + .with_stargate(TokenFactoryStargate) + .build(|_, _, _| {}); let sender: String = sender.into(); let sender = app.api().addr_make(&sender); let app = Rc::new(RefCell::new(app));