Skip to content

Commit

Permalink
fix: bump astroport pairtype
Browse files Browse the repository at this point in the history
  • Loading branch information
ApolloGie committed Jul 1, 2024
1 parent 647bb22 commit f15b1bc
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:

env:
RUSTFLAGS: -D warnings
TEST_RUNNER: osmosis-test-tube

jobs:
test:
Expand All @@ -15,16 +14,13 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v3

- name: Set up Go 1.21.6
uses: actions/setup-go@v5
with:
go-version: "1.21.6"

- name: Install cargo make
uses: davidB/rust-cargo-make@v1

- name: Install stable toolchain
run: cargo make install-stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.79.0
target: wasm32-unknown-unknown
override: true

- name: Run unit tests
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -54,22 +50,23 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --locked --test osmosis_tests --all-features
args: --locked --test osmosis_tests
env:
RUST_BACKTRACE: 1

- name: Run astroport integration tests
uses: actions-rs/cargo@v1
with:
command: test
args: --locked --test astroport_tests --all-features
args: --locked --test astroport_tests -- --test-threads=1
env:
RUST_BACKTRACE: 1

- name: Run osmosis property tests
uses: actions-rs/cargo@v1
with:
command: test
args: --locked --test osmosis_proptests --all-features
args: --locked --test osmosis_proptests -- --test-threads=1
env:
RUST_BACKTRACE: 1

1 change: 1 addition & 0 deletions Cargo.lock

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

16 changes: 14 additions & 2 deletions cw-dex-astroport/tests/astroport_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ mod tests {
use astroport::factory::PairType;
use astroport_v5::asset::Asset as AstroportAsset;
use cosmwasm_std::{assert_approx_eq, coin, coins, Addr, Coin, SubMsgResponse, Uint128};

use cw_it::cw_multi_test::{StargateKeeper, StargateMessageHandler};
use cw_dex_test_contract::msg::{AstroportExecuteMsg, ExecuteMsg, QueryMsg};
use cw_dex_test_helpers::astroport::setup_pool_and_test_contract;
use cw_dex_test_helpers::{cw20_balance_query, cw20_transfer, query_asset_balance};
use cw_it::astroport::utils::AstroportContracts;
use cw_it::helpers::Unwrap;
use cw_it::multi_test::modules::TokenFactory;
use cw_it::multi_test::MultiTestRunner;
use cw_it::test_tube::cosmrs::proto::cosmwasm::wasm::v1::MsgExecuteContractResponse;
use cw_it::test_tube::{
Expand All @@ -26,9 +27,19 @@ mod tests {
#[cfg(feature = "osmosis-test-tube")]
use cw_it::osmosis_test_tube::OsmosisTestApp;

pub const DENOM_CREATION_FEE: &str = "0uosmo";
const TOKEN_FACTORY: &TokenFactory =
&TokenFactory::new("factory", 32, 16, 59 + 16, DENOM_CREATION_FEE);
pub fn get_test_runner<'a>() -> OwnedTestRunner<'a> {
match option_env!("TEST_RUNNER").unwrap_or("multi-test") {
"multi-test" => OwnedTestRunner::MultiTest(MultiTestRunner::new("osmo")),
"multi-test" => {
let mut stargate_keeper = StargateKeeper::new();
TOKEN_FACTORY.register_msgs(&mut stargate_keeper);
OwnedTestRunner::MultiTest(MultiTestRunner::new_with_stargate(
"osmo",
stargate_keeper,
))
}
#[cfg(feature = "osmosis-test-tube")]
"osmosis-test-tube" => OwnedTestRunner::OsmosisTestApp(OsmosisTestApp::new()),
_ => panic!("Unsupported test runner type"),
Expand Down Expand Up @@ -660,3 +671,4 @@ mod tests {
);
}
}

2 changes: 2 additions & 0 deletions test-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ cw-dex-test-contract = { workspace = true }
astroport-test-contract = { workspace = true, optional = true }
cw-it = { workspace = true }
astroport = { workspace = true }
astroport_v5 = { workspace = true }
cw20 = { workspace = true }
cw20-base = { workspace = true }

15 changes: 11 additions & 4 deletions test-helpers/src/astroport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use apollo_utils::assets::separate_natives_and_cw20s;
use astroport::asset::{Asset as AstroAsset, AssetInfo as AstroAssetInfo};
use astroport::factory::PairType;
use astroport::pair::{ExecuteMsg as PairExecuteMsg, StablePoolParams};
use astroport_v5::factory::PairType as AstroportV5PairType;
use cosmwasm_std::{to_json_binary, Addr, Coin, Decimal, Uint128};
use cw20::{Cw20ExecuteMsg, MinterResponse};
use cw20_base::msg::InstantiateMsg as Cw20InstantiateMsg;
Expand Down Expand Up @@ -211,10 +212,16 @@ pub fn setup_pool_and_test_contract<'a>(
},
_ => None,
};
let (pair_addr, lp_token_addr) = create_astroport_pair(
let astroport_v5_pair_type = match &pool_type {
PairType::Xyk {} => AstroportV5PairType::Xyk {},
PairType::Stable {} => AstroportV5PairType::Stable {},
PairType::Custom(t) => AstroportV5PairType::Custom(t.to_string()),
};

let (pair_addr, lp_token_addr, lp_token_denom) = create_astroport_pair(
runner,
&astroport_contracts.factory.address,
pool_type,
astroport_v5_pair_type,
[astro_asset_infos[0].clone(), astro_asset_infos[1].clone()],
init_params,
admin,
Expand Down Expand Up @@ -274,13 +281,13 @@ pub fn setup_pool_and_test_contract<'a>(
AssetInfo::cw20(Addr::unchecked(
astroport_contracts.astro_token.address.clone(),
)),
lp_token_addr.clone(),
lp_token_denom.clone(),
&accs[0],
)?;

Ok((
accs,
lp_token_addr,
lp_token_denom,
pair_addr,
contract_addr,
asset_list,
Expand Down

0 comments on commit f15b1bc

Please sign in to comment.