Skip to content

Commit

Permalink
Fix or adapt tests to new version of comswam-std and cw-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
ueco-jb committed Oct 13, 2021
1 parent b655b99 commit 69d5882
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
5 changes: 5 additions & 0 deletions contracts/dso-token/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ mod tests {
use cw20_base::state::TokenInfo;
use cw_storage_plus::Map;

use std::marker::PhantomData;

const MEMBERS: Map<&Addr, u64> = Map::new(cw4::MEMBERS_KEY);

struct GroupQuerier {
Expand Down Expand Up @@ -500,6 +502,7 @@ mod tests {
storage,
api,
querier,
custom_query_type: PhantomData,
};

BALANCES
Expand Down Expand Up @@ -552,6 +555,7 @@ mod tests {
storage,
api,
querier,
custom_query_type: PhantomData,
};

TOKEN_INFO
Expand Down Expand Up @@ -600,6 +604,7 @@ mod tests {
storage,
api,
querier,
custom_query_type: PhantomData,
};

BALANCES
Expand Down
10 changes: 2 additions & 8 deletions contracts/dso-token/src/multitest/suite.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use cw20_base::msg::InstantiateMarketingInfo;

use cosmwasm_std::testing::{mock_env, MockApi, MockStorage};
use cosmwasm_std::{to_binary, Addr, Binary, Empty, Response, StdError, Uint128};
use cw20::{Cw20Coin, Cw20Contract, Cw20ReceiveMsg, MinterResponse, TokenInfoResponse};
use cw4::{Cw4Contract, Member};
use cw4_group::msg::ExecuteMsg as Cw4ExecuteMsg;
use cw_multi_test::{App, AppResponse, BankKeeper, Contract, ContractWrapper, Executor};
use cw_multi_test::{App, AppResponse, Contract, ContractWrapper, Executor};

use crate::msg::{ExecuteMsg, InstantiateMsg};

Expand Down Expand Up @@ -107,12 +106,7 @@ impl ReceiverContract {
}

fn mock_app() -> App {
let env = mock_env();
let api = MockApi::default();
let bank = BankKeeper::new();
let storage = MockStorage::new();

App::new(api, env.block, bank, storage)
App::default()
}

fn contract_group() -> Box<dyn Contract<Empty>> {
Expand Down
3 changes: 2 additions & 1 deletion contracts/tfi-factory/src/mock_querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cosmwasm_std::{
from_slice, to_binary, Coin, ContractResult, Empty, OwnedDeps, Querier, QuerierResult,
QueryRequest, SystemError, SystemResult, WasmQuery,
};
use std::collections::HashMap;
use std::{collections::HashMap, marker::PhantomData};
use tfi::asset::{AssetInfo, PairInfo};

/// mock_dependencies is a drop-in replacement for cosmwasm_std::testing::mock_dependencies
Expand All @@ -18,6 +18,7 @@ pub fn mock_dependencies(
api: MockApi::default(),
storage: MockStorage::default(),
querier: custom_querier,
custom_query_type: PhantomData,
}
}

Expand Down
21 changes: 12 additions & 9 deletions contracts/tfi-factory/src/multitest/suite.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
use anyhow::{anyhow, Result};
use cosmwasm_std::testing::{mock_env, MockApi, MockStorage};
use cosmwasm_std::{coins, to_binary, Addr, Decimal, Empty, Uint128};
use cosmwasm_std::{coins, to_binary, Addr, BankMsg, Decimal, Empty, Uint128};
use cw20::{Cw20Coin, Cw20Contract, Cw20ExecuteMsg};
use cw4::{Cw4Contract, Member};
use cw4_group::msg::ExecuteMsg as Cw4ExecuteMsg;
use cw_multi_test::{App, BankKeeper, Contract, ContractWrapper, Executor};
use cw_multi_test::{App, Contract, ContractWrapper, Executor};
use derivative::Derivative;
use tfi::asset::{Asset, AssetInfo, PairInfo};
use tfi::factory::{ExecuteMsg, InstantiateMsg, QueryMsg};
use tfi::pair::{Cw20HookMsg, ExecuteMsg as PairExecuteMsg};

fn mock_app() -> App {
let env = mock_env();
let api = MockApi::default();
let bank = BankKeeper::new();
let storage = MockStorage::new();

App::new(api, env.block, bank, storage)
App::default()
}

fn contract_factory() -> Box<dyn Contract<Empty>> {
Expand Down Expand Up @@ -338,6 +332,15 @@ impl Config {
.into_iter()
.map(|actor| -> Result<_> {
let addr = Addr::unchecked(&actor.addr);
// app.execute(
// Addr::unchecked("reserve"),
// BankMsg::Send {
// to_address: addr.to_string(),
// amount: coins(actor.btc, "btc"),
// }
// .into(),
// )
// .unwrap();
app.init_bank_balance(&addr, coins(actor.btc, "btc"))
.map_err(|err| anyhow!(err))?;

Expand Down
10 changes: 2 additions & 8 deletions contracts/tfi-pair/src/multitest.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use anyhow::{anyhow, Result};
use cosmwasm_std::testing::{mock_env, MockApi, MockStorage};
use cosmwasm_std::{coin, coins, to_binary, Addr, Decimal, Empty, StdError, Uint128};
use cw20::{Cw20Coin, Cw20ExecuteMsg};
use cw_multi_test::{App, BankKeeper, Contract, ContractWrapper, Executor};
use cw_multi_test::{App, Contract, ContractWrapper, Executor};
use derivative::Derivative;

use crate::error::ContractError;
Expand All @@ -13,12 +12,7 @@ use tfi::pair::{
};

fn mock_app() -> App {
let env = mock_env();
let api = MockApi::default();
let bank = BankKeeper::new();
let storage = MockStorage::new();

App::new(api, env.block, bank, storage)
App::default()
}

pub fn contract_pair() -> Box<dyn Contract<Empty>> {
Expand Down
2 changes: 1 addition & 1 deletion packages/mocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn mock_dependencies(
storage: MockStorage::default(),
api: MockApi::default(),
querier: custom_querier,
custom_query_type: PhantomData
custom_query_type: PhantomData,
}
}

Expand Down

0 comments on commit 69d5882

Please sign in to comment.