Skip to content

Commit

Permalink
Merge pull request #36 from balancednetwork/feat/change-to-xcall-mock
Browse files Browse the repository at this point in the history
feat: change to xcall mock
  • Loading branch information
AntonAndell authored Sep 12, 2023
2 parents a7ddfcb + 505c755 commit 5f284e7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 66 deletions.
84 changes: 42 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/core-contracts/cw-asset-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cw20-base = "1.0.1"
cw-xcall-multi = {package="cw-xcall", git="https://github.com/icon-project/xcall-multi.git", branch="main", features=["library"]}
cw-xcall-lib={package="cw-xcall-lib", git="https://github.com/icon-project/xcall-multi.git", branch="main", features = ["library"]}
cw-common-ibc = { git = "https://github.com/icon-project/IBC-Integration.git", branch = "main", package = "cw-common"}
cw_xcall_ibc_connection = { git = "https://github.com/icon-project/IBC-Integration.git",branch = "main", package = "cw-xcall-ibc-connection"}
cw_mock_ibc_connection = { git = "https://github.com/icon-project/IBC-Integration.git",branch = "main", package = "cw-mock-ibc-connection"}
cw_mock_ibc_core = { git = "https://github.com/icon-project/IBC-Integration.git", branch="main", package="cw-mock-ibc-core" }

[profile.release]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ use cw_common::asset_manager_msg::ExecuteMsg;
use cw_multi_test::Executor;

use crate::setup::{
call_set_xcall_host, execute_config_x_call, instantiate_contracts, set_default_connection,
setup_context, TestContext,
execute_config_x_call, instantiate_contracts, set_default_connection, setup_context,
TestContext,
};
use cw20::{Cw20Contract, Cw20ExecuteMsg};

//test helper
fn deposit_cw20_token(mut ctx: TestContext, msg: ExecuteMsg) -> TestContext {
let relay = ctx.get_xcall_connection();
ctx = set_default_connection(ctx, relay);
call_set_xcall_host(&mut ctx);

let resp = ctx
.app
Expand All @@ -31,7 +30,6 @@ fn increase_allowance(mut ctx: TestContext, amount: Uint128) -> (TestContext, Ui
let token = Cw20Contract(ctx.get_cw20token_app());

ctx = set_default_connection(ctx, relay);
call_set_xcall_host(&mut ctx);

let allowance_msg = Cw20ExecuteMsg::IncreaseAllowance {
spender: am_addr.to_string(),
Expand Down Expand Up @@ -81,5 +79,6 @@ fn test_deposit_expected_for_revert() {
assert_eq!(allowance, Uint128::new(1000));
let ctx = deposit_cw20_token(ctx, deposit_msg);
//balance will be updated after transfer on manual sub msg execution check
let _bl = check_balance(&ctx, &spoke_addr, &ctx.sender);
let bl = check_balance(&ctx, &spoke_addr, &ctx.get_asset_manager_app());
assert_eq!(Uint128::new(100), bl);
}
23 changes: 5 additions & 18 deletions contracts/core-contracts/cw-asset-manager/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use cw_multi_test::{App, AppResponse};

use cw_asset_manager::contract::{execute, instantiate, query};
use cw_common::x_call_msg::XCallMsg;
use cw_multi_test::{Contract, ContractWrapper, Executor};
use cw_xcall_ibc_connection::{
use cw_mock_ibc_connection::{
execute as execute_conn, instantiate as instantiate_conn, query as query_conn,
reply as reply_conn,
};
use cw_multi_test::{Contract, ContractWrapper, Executor};
use cw_xcall_multi::msg::InstantiateMsg as XCallInstantiateMsg;
use cw_xcall_multi::{
execute as execute_xcall, instantiate as instantiate_xcall, query as query_xcall,
Expand Down Expand Up @@ -147,7 +147,7 @@ pub fn init_x_call(mut ctx: TestContext) -> TestContext {
ctx.sender.clone(),
&XCallInstantiateMsg {
network_id: "archway".to_string(),
denom: "xcallToken".to_string(),
denom: "uarch".to_string(),
},
&[],
"XCall",
Expand All @@ -165,7 +165,7 @@ pub fn init_xcall_connection_contract(mut ctx: TestContext) -> TestContext {
.instantiate_contract(
connection_contract_code_id,
ctx.sender.clone(),
&cw_xcall_ibc_connection::msg::InstantiateMsg {
&cw_mock_ibc_connection::msg::InstantiateMsg {
ibc_host: ctx.get_ibc_core(),
denom: "uarch".to_string(),
port_id: "mock".to_string(),
Expand Down Expand Up @@ -259,21 +259,8 @@ pub fn instantiate_contracts(mut ctx: TestContext) -> TestContext {
ctx
}

#[allow(warnings)]
//-------------------------execute function helpers--------------------------------------------
pub fn call_set_xcall_host(ctx: &mut TestContext) -> AppResponse {
ctx.app
.execute_contract(
ctx.sender.clone(),
ctx.get_xcall_connection(),
&cw_common_ibc::xcall_connection_msg::ExecuteMsg::SetXCallHost {
address: ctx.get_xcall_app().to_string(),
},
&[],
)
.unwrap()
}

#[allow(warnings)]
pub fn execute_config_x_call(mut ctx: TestContext, x_call: Addr) -> TestContext {
let _resp = ctx
.app
Expand Down

0 comments on commit 5f284e7

Please sign in to comment.