Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

factory contract integration testcases #75

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/liquidity/factory/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ pub fn execute_swap_request(

ensure!(
first_swap.token_in == asset_in.token,
ContractError::new("Amount in doesn't match swap route")
ContractError::new("Token in doesn't match swap route")
);

let last_swap = swaps.last().ok_or(ContractError::Generic {
Expand All @@ -561,7 +561,7 @@ pub fn execute_swap_request(

ensure!(
last_swap.token_out == asset_out,
ContractError::new("Amount out doesn't match swap route")
ContractError::new("Token out doesn't match swap route")
);

let channel = if !state.is_native {
Expand Down
58 changes: 42 additions & 16 deletions tests-integration/src/helpers/factory.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#![cfg(not(target_arch = "wasm32"))]

use cosmwasm_std::coin;
use cosmwasm_std::{coin, Uint128};
use cw20::Cw20Contract;
use cw_orch::mock::MockBase;
use cw_orch::prelude::*;

use cw_orch_interchain::IbcQueryHandler;
use euclid::chain::CrossChainUserWithLimit;
use euclid::fee::PartnerFee;
use euclid::msgs::cw20::ExecuteMsgFns;
use euclid::msgs::factory::{
ExecuteMsgFns as FactoryExecuteMsgFns, QueryMsgFns as FactoryQueryMsgFns,
};

use cw_orch_interchain::InterchainEnv;
use cw_orch_interchain::MockInterchainEnv;
use euclid::token::PairWithDenomAndAmount;
use euclid::swap::NextSwapPair;
use euclid::token::TokenType;
use euclid::token::TokenWithDenom;
use euclid::token::{PairWithDenomAndAmount, Token};
use factory::FactoryContract;

pub fn register_token(
Expand Down Expand Up @@ -114,26 +117,49 @@ pub fn add_liquidity(
factory: &FactoryContract<MockBase>,
pair_with_denom: PairWithDenomAndAmount,
slippage_tolerance_bps: u64,
timeout: Option<u64>,
funds: Vec<Coin>,
) {
let chain = interchain
.get_chain(factory.environment().chain_id().as_str())
.unwrap();
let mut funds = vec![];
for token in pair_with_denom.get_vec_token_info() {
faucet(
&chain,
chain.sender.as_str(),
token.amount.u128(),
token.token_type.clone(),
&mut funds,
);
}
let tx_response = factory
.execute(
&euclid::msgs::factory::ExecuteMsg::AddLiquidityRequest {
pair_info: pair_with_denom.clone(),
slippage_tolerance_bps,
timeout: None,
timeout,
},
Some(&funds),
)
.unwrap();

let _ = interchain
.await_packets(factory.environment().chain_id().as_str(), tx_response)
.unwrap();
}

pub fn swap_request(
interchain: &MockInterchainEnv,
factory: &FactoryContract<MockBase>,
asset_in: TokenWithDenom,
amount_in: Uint128,
asset_out: Token,
min_amount_out: Uint128,
timeout: Option<u64>,
swaps: Vec<NextSwapPair>,
cross_chain_addresses: Vec<CrossChainUserWithLimit>,
partner_fee: Option<PartnerFee>,
funds: Vec<Coin>,
) {
let tx_response = factory
.execute(
&euclid::msgs::factory::ExecuteMsg::ExecuteSwapRequest {
asset_in,
amount_in,
asset_out,
min_amount_out,
timeout,
swaps,
cross_chain_addresses,
partner_fee,
},
Some(&funds),
)
Expand Down
Loading
Loading