diff --git a/Cargo.lock b/Cargo.lock index 2932af2..1d0b5f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1317,6 +1317,8 @@ dependencies = [ [[package]] name = "ibcx-test-utils" version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "295c0a8d709f798fdc8abf60077079e1f57e1a90e60fb4c1dc3fd7b222c7fbe6" dependencies = [ "anyhow", "cosmwasm-std", @@ -1876,7 +1878,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.37", diff --git a/Cargo.toml b/Cargo.toml index 014f62c..0d6c239 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,13 +55,15 @@ semver = { version = "1.0.18" } anyhow = { version = "1.0.72" } thiserror = { version = "1.0.37" } +# families +ibcx-test-utils = { version = "0.1.1" } + # local dependencies ibcx-airdrop = { path = "contracts/airdrop" } ibcx-core = { path = "contracts/core" } ibcx-periphery = { path = "contracts/periphery" } ibcx-utils = { path = "packages/utils" } -ibcx-test-utils = { path = "packages/test-utils" } ibcx-math = { path = "packages/math" } ibcx-pool = { path = "packages/pool" } ibcx-interface = { path = "packages/interface" } diff --git a/packages/test-utils/Cargo.toml b/packages/test-utils/Cargo.toml deleted file mode 100644 index 319ce6d..0000000 --- a/packages/test-utils/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "ibcx-test-utils" -version.workspace = true -authors.workspace = true -edition.workspace = true - -[lib] -crate-type = ["cdylib", "rlib"] - -[features] -# for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] -# use library feature to disable all instantiate/execute/query exports -library = [] - - -[dependencies] -osmosis-std.workspace = true -osmosis-test-tube.workspace = true -cosmwasm-std.workspace = true - -serde_json.workspace = true -anyhow.workspace = true diff --git a/packages/test-utils/src/app.rs b/packages/test-utils/src/app.rs deleted file mode 100644 index 685b4f2..0000000 --- a/packages/test-utils/src/app.rs +++ /dev/null @@ -1,90 +0,0 @@ -use std::marker::PhantomData; - -use cosmwasm_std::{ - coin, - testing::{MockApi, MockStorage}, - Empty, OwnedDeps, -}; - -use osmosis_std::{shim::Any, types::osmosis::concentratedliquidity}; -use osmosis_test_tube::{cosmrs::proto::traits::Message, Module, OsmosisTestApp, Wasm}; - -use crate::QUERIER_BIN; - -pub struct App { - osmo_app: OsmosisTestApp, - wasm_querier: String, -} - -impl Default for App { - fn default() -> Self { - Self::new(OsmosisTestApp::new()) - } -} - -impl App { - pub fn new(osmo_app: OsmosisTestApp) -> Self { - let deployer = osmo_app - .init_account(&[coin(100_000_000_000, "uosmo")]) - .unwrap(); - - let wasm = Wasm::new(&osmo_app); - - let store_resp = wasm.store_code(QUERIER_BIN, None, &deployer).unwrap(); - - let init_resp = wasm - .instantiate( - store_resp.data.code_id, - &Empty {}, - None, - None, - &[], - &deployer, - ) - .unwrap(); - - Self { - osmo_app, - wasm_querier: init_resp.data.address, - } - } - - pub fn inner(&self) -> &OsmosisTestApp { - &self.osmo_app - } - - pub fn wasm_querier(&self) -> &str { - &self.wasm_querier - } - - pub fn unlock_cl_pool_creation(&self) -> anyhow::Result<()> { - // make CL pool creation premissionless - let cl_param: concentratedliquidity::Params = self.inner().get_param_set( - "concentratedliquidity", - concentratedliquidity::Params::TYPE_URL, - )?; - - self.inner().set_param_set( - "concentratedliquidity", - Any { - type_url: concentratedliquidity::Params::TYPE_URL.to_string(), - value: concentratedliquidity::Params { - is_permissionless_pool_creation_enabled: true, - ..cl_param - } - .encode_to_vec(), - }, - )?; - - Ok(()) - } - - pub fn deps(&self) -> OwnedDeps { - OwnedDeps { - storage: MockStorage::default(), - api: MockApi::default(), - querier: crate::Querier::new(self), - custom_query_type: PhantomData::, - } - } -} diff --git a/packages/test-utils/src/lib.rs b/packages/test-utils/src/lib.rs deleted file mode 100644 index 23ec4db..0000000 --- a/packages/test-utils/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod app; -mod querier; - -pub use app::App; -pub use querier::Querier; - -static QUERIER_BIN: &[u8] = include_bytes!("querier.wasm"); diff --git a/packages/test-utils/src/querier.rs b/packages/test-utils/src/querier.rs deleted file mode 100644 index 2efe2dd..0000000 --- a/packages/test-utils/src/querier.rs +++ /dev/null @@ -1,47 +0,0 @@ -use cosmwasm_std::{ - from_slice, to_binary, ContractResult, Empty, QueryRequest, SystemError, SystemResult, -}; -use osmosis_std::types::cosmwasm::wasm::v1::{ - QuerySmartContractStateRequest, QuerySmartContractStateResponse, -}; -use osmosis_test_tube::Runner; - -use crate::App; - -pub struct Querier<'a> { - app: &'a App, -} - -impl<'a> Querier<'a> { - pub fn new(app: &'a App) -> Self { - Self { app } - } -} - -impl cosmwasm_std::Querier for Querier<'_> { - fn raw_query(&self, bin_request: &[u8]) -> cosmwasm_std::QuerierResult { - let request: QueryRequest = match from_slice(bin_request) { - Ok(v) => v, - Err(e) => { - return SystemResult::Err(SystemError::InvalidRequest { - error: format!("Parsing query request: {e}"), - request: bin_request.into(), - }) - } - }; - - let res = self - .app - .inner() - .query::( - "/cosmwasm.wasm.v1.Query/SmartContractState", - &QuerySmartContractStateRequest { - address: self.app.wasm_querier().to_string(), - query_data: to_binary(&request).unwrap().to_vec(), - }, - ) - .unwrap(); - - SystemResult::Ok(ContractResult::Ok(res.data.into())) - } -} diff --git a/packages/test-utils/src/querier.wasm b/packages/test-utils/src/querier.wasm deleted file mode 100644 index 218395b..0000000 Binary files a/packages/test-utils/src/querier.wasm and /dev/null differ