From 53444534e97977cf4b9409bb3cd7cb94f4db975d Mon Sep 17 00:00:00 2001 From: Speed Demon <138406401+cowboy0015@users.noreply.github.com> Date: Wed, 20 Nov 2024 07:29:48 -0800 Subject: [PATCH] Feat/e2e refactor (#575) Co-authored-by: Connor Barr --- .cargo/{config => config.toml} | 0 Cargo.lock | 88 ++- Cargo.toml | 2 +- .../app/andromeda-app-contract/Cargo.toml | 3 +- .../andromeda-app-contract/src/interface.rs | 10 + .../data-storage/andromeda-counter/Cargo.toml | 2 +- .../ecosystem/andromeda-vault/Cargo.toml | 2 + .../andromeda-fixed-multisig/Cargo.toml | 2 +- .../andromeda-validator-staking/Cargo.toml | 1 + .../src/interface.rs | 10 + .../fungible-tokens/andromeda-cw20/Cargo.toml | 1 + .../andromeda-cw20/src/interface.rs | 13 + .../andromeda-ics20/Cargo.toml | 4 +- .../andromeda-crowdfund/Cargo.toml | 1 + .../andromeda-crowdfund/src/interface.rs | 14 +- .../andromeda-cw721/Cargo.toml | 1 + .../andromeda-cw721/src/contract.rs | 10 +- .../andromeda-cw721/src/interface.rs | 13 + .../andromeda-marketplace/Cargo.toml | 3 +- .../andromeda-marketplace/src/contract.rs | 1 + .../andromeda-marketplace/src/mock.rs | 23 +- .../os/andromeda-ibc-registry/Cargo.toml | 5 +- contracts/os/andromeda-kernel/Cargo.toml | 1 - contracts/os/andromeda-kernel/src/contract.rs | 2 +- contracts/os/andromeda-kernel/src/execute.rs | 3 +- ibc-tests/Cargo.toml | 26 +- ibc-tests/README.md | 44 +- ibc-tests/src/constants.rs | 46 ++ ibc-tests/src/interface_macro.rs | 2 +- ibc-tests/src/lib.rs | 1 + ibc-tests/src/main.rs | 72 +-- ibc-tests/tests/crowdfund.rs | 524 ++++++++++++++++++ ibc-tests/tests/validator_staking.rs | 103 +--- packages/andromeda-app/Cargo.toml | 7 +- packages/andromeda-finance/Cargo.toml | 5 + .../src/validator_staking.rs | 2 + packages/andromeda-fungible-tokens/Cargo.toml | 5 + .../andromeda-fungible-tokens/src/cw20.rs | 1 + .../andromeda-non-fungible-tokens/Cargo.toml | 5 + .../src/auction.rs | 4 +- .../src/crowdfund.rs | 2 + .../src/marketplace.rs | 4 +- packages/andromeda-testing-e2e/src/adodb.rs | 39 -- .../andromeda-testing-e2e/src/economics.rs | 25 - .../src/interface_macro.rs | 26 - packages/andromeda-testing-e2e/src/kernel.rs | 31 -- packages/andromeda-testing-e2e/src/lib.rs | 15 - packages/andromeda-testing-e2e/src/mock.rs | 129 +++-- packages/andromeda-testing-e2e/src/vfs.rs | 19 - packages/std/Cargo.toml | 6 +- packages/std/src/os/adodb.rs | 5 +- packages/std/src/os/ibc_registry.rs | 3 +- packages/std/src/os/kernel.rs | 5 +- packages/std/src/os/vfs.rs | 2 +- scripts/build.sh | 13 +- tests-integration/Cargo.toml | 12 +- tests-integration/tests/app.rs | 2 - tests-integration/tests/auction_app.rs | 2 - tests-integration/tests/cw20_app.rs | 1 - tests-integration/tests/kernel_orch.rs | 1 - tests-integration/tests/marketplace_app.rs | 158 ++---- tests-integration/tests/mod.rs | 6 + tests-integration/tests/primitive.rs | 2 - ...unt-splitter.rs => set_amount_splitter.rs} | 0 tests-integration/tests/validator_staking.rs | 2 - 65 files changed, 1069 insertions(+), 503 deletions(-) rename .cargo/{config => config.toml} (100%) create mode 100644 ibc-tests/src/constants.rs create mode 100644 ibc-tests/tests/crowdfund.rs delete mode 100644 packages/andromeda-testing-e2e/src/adodb.rs delete mode 100644 packages/andromeda-testing-e2e/src/economics.rs delete mode 100644 packages/andromeda-testing-e2e/src/interface_macro.rs delete mode 100644 packages/andromeda-testing-e2e/src/kernel.rs delete mode 100644 packages/andromeda-testing-e2e/src/vfs.rs rename tests-integration/tests/{set-amount-splitter.rs => set_amount_splitter.rs} (100%) diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/Cargo.lock b/Cargo.lock index 62a26fa04..8b8e74495 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,6 +133,7 @@ dependencies = [ "cosmwasm-schema 1.5.8", "cosmwasm-std 1.5.8", "cw-multi-test", + "cw-orch", "serde", ] @@ -147,6 +148,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "enum-repr", ] @@ -246,6 +248,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "cw-utils 1.0.3", "cw20 1.1.2", @@ -281,6 +284,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "cw-utils 1.0.3", "cw20 1.1.2", @@ -334,6 +338,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "cw721 0.18.0", "cw721-base 0.18.0", @@ -471,6 +476,8 @@ dependencies = [ "andromeda-std", "cosmwasm-schema 1.5.8", "cosmwasm-std 1.5.8", + "cw-multi-test", + "cw-orch", "cw-utils 1.0.3", "cw3 1.1.2", "cw4", @@ -509,6 +516,8 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-asset", "cw-controllers", + "cw-multi-test", + "cw-orch", "cw-utils 1.0.3", "cw20 1.1.2", "cw20-base", @@ -588,7 +597,6 @@ dependencies = [ "serde", "serde-cw-value", "serde-json-wasm 1.0.1", - "sha256", ] [[package]] @@ -677,6 +685,8 @@ dependencies = [ "andromeda-std", "cosmwasm-schema 1.5.8", "cosmwasm-std 1.5.8", + "cw-multi-test", + "cw-orch", "cw-utils 1.0.3", "cw20 1.1.2", "cw721 0.18.0", @@ -926,6 +936,7 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-multi-test", "cw-orch", + "cw-orch-daemon", "cw-storage-plus 1.2.0", "cw2 1.1.2", "enum-repr", @@ -3304,9 +3315,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", @@ -3344,7 +3355,7 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "rustls 0.23.17", "rustls-pki-types", @@ -3386,7 +3397,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "native-tls", "tokio", @@ -3405,7 +3416,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.5.1", "pin-project-lite", "socket2", "tokio", @@ -3488,7 +3499,13 @@ version = "0.1.0" dependencies = [ "andromeda-app", "andromeda-app-contract", + "andromeda-crowdfund", + "andromeda-cw20", + "andromeda-cw721", "andromeda-finance", + "andromeda-fungible-tokens", + "andromeda-non-fungible-tokens", + "andromeda-splitter", "andromeda-std", "andromeda-testing-e2e", "andromeda-validator-staking", @@ -3496,7 +3513,10 @@ dependencies = [ "cosmwasm-std 1.5.8", "cw-orch", "cw-orch-daemon", + "cw20 1.1.2", + "cw721 0.18.0", "prost-types 0.13.3", + "rstest 0.19.0", "serde", "tokio", ] @@ -4589,7 +4609,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-rustls 0.27.3", "hyper-tls 0.6.0", "hyper-util", @@ -4651,6 +4671,18 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "rstest" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5316d2a1479eeef1ea21e7f9ddc67c191d497abc8fc3ba2467857abbb68330" +dependencies = [ + "futures", + "futures-timer", + "rstest_macros 0.19.0", + "rustc_version", +] + [[package]] name = "rstest" version = "0.23.0" @@ -4659,8 +4691,25 @@ checksum = "0a2c585be59b6b5dd66a9d2084aa1d8bd52fbdb806eafdeffb52791147862035" dependencies = [ "futures", "futures-timer", - "rstest_macros", + "rstest_macros 0.23.0", + "rustc_version", +] + +[[package]] +name = "rstest_macros" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04a9df72cc1f67020b0d63ad9bfe4a323e459ea7eb68e03bd9824db49f9a4c25" +dependencies = [ + "cfg-if", + "glob", + "proc-macro2", + "quote", + "regex", + "relative-path", "rustc_version", + "syn 2.0.87", + "unicode-ident", ] [[package]] @@ -4698,9 +4747,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.40" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags 2.6.0", "errno", @@ -4814,9 +4863,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -5078,19 +5127,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha256" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0" -dependencies = [ - "async-trait", - "bytes", - "hex", - "sha2 0.10.8", - "tokio", -] - [[package]] name = "sha3" version = "0.10.8" @@ -5634,7 +5670,7 @@ dependencies = [ "cw721 0.18.0", "cw721-base 0.18.0", "ibc-relayer-types", - "rstest", + "rstest 0.23.0", "toml 0.8.19", ] diff --git a/Cargo.toml b/Cargo.toml index 132aa9a3f..891054ba5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ resolver = "2" [profile.release] debug = false debug-assertions = false -opt-level = 'z' +opt-level = 's' codegen-units = 1 rpath = false lto = true diff --git a/contracts/app/andromeda-app-contract/Cargo.toml b/contracts/app/andromeda-app-contract/Cargo.toml index b4eeaa325..ed75a5048 100644 --- a/contracts/app/andromeda-app-contract/Cargo.toml +++ b/contracts/app/andromeda-app-contract/Cargo.toml @@ -21,7 +21,8 @@ enum-repr = { workspace = true } cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true, optional = true } cw-orch = { workspace = true } - +cw-orch-daemon = "0.24.2" [features] testing = ["cw-multi-test", "andromeda-testing"] +library = [] diff --git a/contracts/app/andromeda-app-contract/src/interface.rs b/contracts/app/andromeda-app-contract/src/interface.rs index 7947678f4..9b34e7513 100644 --- a/contracts/app/andromeda-app-contract/src/interface.rs +++ b/contracts/app/andromeda-app-contract/src/interface.rs @@ -1,6 +1,16 @@ use andromeda_app::app::{ExecuteMsg, InstantiateMsg, QueryMsg}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "app-contract"; contract_interface!(AppContract, CONTRACT_ID, "andromeda_app_contract.wasm"); + +type Chain = DaemonBase; + +impl AppContract { + pub fn get_address(&self, name: impl Into) -> String { + let query_msg = QueryMsg::GetAddress { name: name.into() }; + self.query(&query_msg).unwrap() + } +} diff --git a/contracts/data-storage/andromeda-counter/Cargo.toml b/contracts/data-storage/andromeda-counter/Cargo.toml index 6f596806d..b61d99b2c 100644 --- a/contracts/data-storage/andromeda-counter/Cargo.toml +++ b/contracts/data-storage/andromeda-counter/Cargo.toml @@ -29,12 +29,12 @@ cosmwasm-schema = { workspace = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } cw20 = { workspace = true } -cw-orch = { workspace = true } andromeda-std = { workspace = true, features = ["rates"] } andromeda-data-storage = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cw-orch = { workspace = true } cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true, optional = true } diff --git a/contracts/ecosystem/andromeda-vault/Cargo.toml b/contracts/ecosystem/andromeda-vault/Cargo.toml index 6e45df035..e62dfee0f 100644 --- a/contracts/ecosystem/andromeda-vault/Cargo.toml +++ b/contracts/ecosystem/andromeda-vault/Cargo.toml @@ -9,6 +9,7 @@ rust-version = "1.75.0" [lib] crate-type = ["cdylib", "rlib"] + [dependencies] cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } @@ -24,3 +25,4 @@ cw-multi-test = { workspace = true, optional = true } [features] testing = ["cw-multi-test"] +library = [] diff --git a/contracts/finance/andromeda-fixed-multisig/Cargo.toml b/contracts/finance/andromeda-fixed-multisig/Cargo.toml index 8540c3572..b0fbbb103 100644 --- a/contracts/finance/andromeda-fixed-multisig/Cargo.toml +++ b/contracts/finance/andromeda-fixed-multisig/Cargo.toml @@ -20,7 +20,6 @@ cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } -cw-orch = { workspace = true } cw2 = { workspace = true } cw3 = { workspace = true } cw4 = { workspace = true } @@ -30,6 +29,7 @@ andromeda-std = { workspace = true } andromeda-finance = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cw-orch = { workspace = true } cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true, optional = true } diff --git a/contracts/finance/andromeda-validator-staking/Cargo.toml b/contracts/finance/andromeda-validator-staking/Cargo.toml index 240461e82..7688331a7 100644 --- a/contracts/finance/andromeda-validator-staking/Cargo.toml +++ b/contracts/finance/andromeda-validator-staking/Cargo.toml @@ -30,3 +30,4 @@ chrono = "0.3" cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true } cw-orch = { workspace = true } +cw-orch-daemon = "0.24.2" \ No newline at end of file diff --git a/contracts/finance/andromeda-validator-staking/src/interface.rs b/contracts/finance/andromeda-validator-staking/src/interface.rs index 8fb3c29fa..97d664768 100644 --- a/contracts/finance/andromeda-validator-staking/src/interface.rs +++ b/contracts/finance/andromeda-validator-staking/src/interface.rs @@ -1,5 +1,6 @@ use andromeda_finance::validator_staking::{ExecuteMsg, InstantiateMsg, QueryMsg}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "validator-staking"; @@ -8,3 +9,12 @@ contract_interface!( CONTRACT_ID, "andromeda_validator_staking.wasm" ); + +type Chain = DaemonBase; + +impl ValidatorStakingContract { + pub fn staked_tokens(&self, validator: Option) -> Option<::cosmwasm_std::FullDelegation> { + let query_msg = QueryMsg::StakedTokens { validator }; + self.query(&query_msg).unwrap() + } +} diff --git a/contracts/fungible-tokens/andromeda-cw20/Cargo.toml b/contracts/fungible-tokens/andromeda-cw20/Cargo.toml index ff4d08cca..354833d8c 100644 --- a/contracts/fungible-tokens/andromeda-cw20/Cargo.toml +++ b/contracts/fungible-tokens/andromeda-cw20/Cargo.toml @@ -30,6 +30,7 @@ andromeda-fungible-tokens = { workspace = true } cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true, optional = true } cw-orch = { workspace = true } +cw-orch-daemon = "0.24.2" [dev-dependencies] andromeda-app = { workspace = true } diff --git a/contracts/fungible-tokens/andromeda-cw20/src/interface.rs b/contracts/fungible-tokens/andromeda-cw20/src/interface.rs index 49633dcab..61399024c 100644 --- a/contracts/fungible-tokens/andromeda-cw20/src/interface.rs +++ b/contracts/fungible-tokens/andromeda-cw20/src/interface.rs @@ -1,6 +1,19 @@ use andromeda_fungible_tokens::cw20::{ExecuteMsg, InstantiateMsg, QueryMsg}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw20::BalanceResponse; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "cw20"; contract_interface!(CW20Contract, CONTRACT_ID, "andromeda_cw20.wasm"); + +type Chain = DaemonBase; + +impl CW20Contract { + pub fn balance(&self, address: impl Into) -> BalanceResponse { + let query_msg = QueryMsg::Balance { + address: address.into(), + }; + self.query(&query_msg).unwrap() + } +} diff --git a/contracts/fungible-tokens/andromeda-ics20/Cargo.toml b/contracts/fungible-tokens/andromeda-ics20/Cargo.toml index 04efea57d..e1e0fce73 100644 --- a/contracts/fungible-tokens/andromeda-ics20/Cargo.toml +++ b/contracts/fungible-tokens/andromeda-ics20/Cargo.toml @@ -28,12 +28,12 @@ cw-controllers = "=1.1.2" schemars = "0.8.21" serde = "1.0.215" thiserror = "2.0.3" -cw-orch = { workspace = true } -andromeda-std = { workspace = true, features = ["rates"]} +andromeda-std = { workspace = true } andromeda-fungible-tokens = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cw-orch = { workspace = true } cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true, optional = true } diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/Cargo.toml b/contracts/non-fungible-tokens/andromeda-crowdfund/Cargo.toml index 7e98a51aa..e33bac69a 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/Cargo.toml +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/Cargo.toml @@ -30,6 +30,7 @@ andromeda-non-fungible-tokens = { workspace = true } cw-multi-test = { workspace = true, optional = true } andromeda-testing = { workspace = true, optional = true } cw-orch = { workspace = true } +cw-orch-daemon = "0.24.2" [dev-dependencies] andromeda-app = { workspace = true } diff --git a/contracts/non-fungible-tokens/andromeda-crowdfund/src/interface.rs b/contracts/non-fungible-tokens/andromeda-crowdfund/src/interface.rs index 498bced4b..06df9f467 100644 --- a/contracts/non-fungible-tokens/andromeda-crowdfund/src/interface.rs +++ b/contracts/non-fungible-tokens/andromeda-crowdfund/src/interface.rs @@ -1,6 +1,18 @@ -use andromeda_non_fungible_tokens::crowdfund::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use andromeda_non_fungible_tokens::crowdfund::{ + CampaignSummaryResponse, ExecuteMsg, InstantiateMsg, QueryMsg, +}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "crowdfund"; contract_interface!(CrowdfundContract, CONTRACT_ID, "andromeda_crowdfund.wasm"); + +type Chain = DaemonBase; + +impl CrowdfundContract { + pub fn campaign_summary(&self) -> CampaignSummaryResponse { + let query_msg = QueryMsg::CampaignSummary {}; + self.query(&query_msg).unwrap() + } +} diff --git a/contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml b/contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml index 3459072f5..f47166e3c 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml +++ b/contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml @@ -38,3 +38,4 @@ andromeda-std = { workspace = true, features = ["rates"] } cw-multi-test = { workspace = true, optional = true } cw-orch = { workspace = true } andromeda-testing = { workspace = true, optional = true } +cw-orch-daemon = "0.24.2" diff --git a/contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs b/contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs index efe2cffad..4db47bfa1 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs @@ -1,4 +1,4 @@ -#[cfg(not(feature = "imported"))] +#[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ attr, ensure, from_json, has_coins, to_json_binary, Addr, Api, BankMsg, Binary, Coin, @@ -30,7 +30,7 @@ pub type AndrCW721Contract<'a> = Cw721Contract<'a, TokenExtension, Empty, Execut const CONTRACT_NAME: &str = "crates.io:andromeda-cw721"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[cfg_attr(not(feature = "imported"), entry_point)] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, env: Env, @@ -68,7 +68,7 @@ pub fn instantiate( Ok(resp.add_attributes(vec![attr("minter", msg.minter)])) } -#[cfg_attr(not(feature = "imported"), entry_point)] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, env: Env, @@ -473,7 +473,7 @@ fn execute_send_nft( Ok(contract.send_nft(deps, env, info, contract_addr, token_id, msg)?) } -#[cfg_attr(not(feature = "imported"), entry_point)] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result { match msg { QueryMsg::IsArchived { token_id } => { @@ -505,7 +505,7 @@ pub fn query_minter(deps: Deps) -> Result { minter.get_raw_address(&deps) } -#[cfg_attr(not(feature = "imported"), entry_point)] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { ADOContract::default().migrate(deps, CONTRACT_NAME, CONTRACT_VERSION) } diff --git a/contracts/non-fungible-tokens/andromeda-cw721/src/interface.rs b/contracts/non-fungible-tokens/andromeda-cw721/src/interface.rs index 70d63c9e7..9f65cf2a5 100644 --- a/contracts/non-fungible-tokens/andromeda-cw721/src/interface.rs +++ b/contracts/non-fungible-tokens/andromeda-cw721/src/interface.rs @@ -1,6 +1,19 @@ use andromeda_non_fungible_tokens::cw721::{ExecuteMsg, InstantiateMsg, QueryMsg}; use andromeda_std::{ado_base::MigrateMsg, contract_interface, deploy::ADOMetadata}; +use cw_orch_daemon::{DaemonBase, Wallet}; pub const CONTRACT_ID: &str = "cw721"; contract_interface!(CW721Contract, CONTRACT_ID, "andromeda_cw721.wasm"); + +type Chain = DaemonBase; + +impl CW721Contract { + pub fn owner_of(&self, token_id: impl Into) -> cw721::OwnerOfResponse { + let query_msg = QueryMsg::OwnerOf { + token_id: token_id.into(), + include_expired: None, + }; + self.query(&query_msg).unwrap() + } +} diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/Cargo.toml b/contracts/non-fungible-tokens/andromeda-marketplace/Cargo.toml index fb05c1acb..75067139a 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/Cargo.toml +++ b/contracts/non-fungible-tokens/andromeda-marketplace/Cargo.toml @@ -11,10 +11,9 @@ crate-type = ["cdylib", "rlib"] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports -library = [] testing = ["cw-multi-test", "andromeda-testing"] - +library = [] [dependencies] cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs b/contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs index 1b6a17d26..11d8fa5fd 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs +++ b/contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs @@ -102,6 +102,7 @@ pub fn handle_execute(mut ctx: ExecuteContext, msg: ExecuteMsg) -> Result handle_receive_cw721(ctx, msg), ExecuteMsg::Receive(msg) => handle_receive_cw20(ctx, msg), diff --git a/contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs b/contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs index 02601e7f5..fe3995281 100644 --- a/contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs +++ b/contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs @@ -1,4 +1,4 @@ -#![cfg(all(not(target_arch = "wasm32"), feature = "testing", feature = "rates"))] +#![cfg(not(target_arch = "wasm32"))] use crate::contract::{execute, instantiate, query}; use andromeda_non_fungible_tokens::marketplace::{ @@ -6,9 +6,9 @@ use andromeda_non_fungible_tokens::marketplace::{ }; use andromeda_std::ado_base::permissioning::Permission; use andromeda_std::ado_base::permissioning::PermissioningMessage; +use andromeda_std::ado_base::rates::AllRatesResponse; use andromeda_std::ado_base::rates::Rate; use andromeda_std::ado_base::rates::RatesMessage; -use andromeda_std::ado_base::rates::RatesQueryMessage; use andromeda_std::ado_base::version::VersionResponse; use andromeda_std::amp::messages::AMPPkt; @@ -33,13 +33,13 @@ impl MockMarketplace { app: &mut MockApp, kernel_address: impl Into, owner: Option, - authorized_cw20_address: Option, + authorized_cw20_addresses: Option>, authorized_token_addresses: Option>, ) -> MockMarketplace { let msg = mock_marketplace_instantiate_msg( kernel_address.into(), owner, - authorized_cw20_address, + authorized_cw20_addresses, authorized_token_addresses, ); let addr = app @@ -109,6 +109,11 @@ impl MockMarketplace { let msg = mock_get_version(); self.query(app, msg) } + + pub fn query_all_rates(&self, app: &mut MockApp) -> AllRatesResponse { + let msg = mock_get_all_rates(); + self.query(app, msg) + } } pub fn mock_andromeda_marketplace() -> Box> { @@ -119,12 +124,14 @@ pub fn mock_andromeda_marketplace() -> Box> { pub fn mock_marketplace_instantiate_msg( kernel_address: String, owner: Option, - authorized_cw20_address: Option, + authorized_cw20_addresses: Option>, + authorized_token_addresses: Option>, ) -> InstantiateMsg { InstantiateMsg { kernel_address, owner, - authorized_cw20_address, + authorized_cw20_addresses, + authorized_token_addresses, } } @@ -175,12 +182,12 @@ pub fn mock_set_rates(action: impl Into, rate: Rate) -> ExecuteMsg { } pub fn mock_set_permissions( - actor: AndrAddr, + actors: Vec, action: impl Into, permission: Permission, ) -> ExecuteMsg { ExecuteMsg::Permissioning(PermissioningMessage::SetPermission { - actor, + actors, action: action.into(), permission, }) diff --git a/contracts/os/andromeda-ibc-registry/Cargo.toml b/contracts/os/andromeda-ibc-registry/Cargo.toml index eab40d060..af272ec95 100644 --- a/contracts/os/andromeda-ibc-registry/Cargo.toml +++ b/contracts/os/andromeda-ibc-registry/Cargo.toml @@ -29,10 +29,9 @@ cw-storage-plus = { workspace = true } cw-utils = { workspace = true } cw20 = { workspace = true } - -andromeda-std = { workspace = true, features = ["rates"] } +andromeda-std = { workspace = true } andromeda-data-storage = { workspace = true } -cw-orch = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cw-orch = { workspace = true } cw-multi-test = { workspace = true, optional = true } diff --git a/contracts/os/andromeda-kernel/Cargo.toml b/contracts/os/andromeda-kernel/Cargo.toml index 021eb50de..838c35239 100644 --- a/contracts/os/andromeda-kernel/Cargo.toml +++ b/contracts/os/andromeda-kernel/Cargo.toml @@ -28,7 +28,6 @@ cw-storage-plus = { workspace = true } serde-json-wasm = "1.0.1" serde-cw-value = "0.7.0" -sha256 = "=1.5.0" osmosis-std-derive = "0.15.3" osmosis-std = "0.1.4" prost = { version = "0.11.2", default-features = false, features = [ diff --git a/contracts/os/andromeda-kernel/src/contract.rs b/contracts/os/andromeda-kernel/src/contract.rs index ad6f77f25..873a470a0 100644 --- a/contracts/os/andromeda-kernel/src/contract.rs +++ b/contracts/os/andromeda-kernel/src/contract.rs @@ -137,7 +137,7 @@ pub fn execute( } } -#[cfg_attr(not(feature = "imported"), entry_point)] +#[cfg_attr(not(feature = "library"), entry_point)] pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> Result { match msg { SudoMsg::IBCLifecycleComplete(IBCLifecycleComplete::IBCAck { diff --git a/contracts/os/andromeda-kernel/src/execute.rs b/contracts/os/andromeda-kernel/src/execute.rs index b249adac6..dedaebcec 100644 --- a/contracts/os/andromeda-kernel/src/execute.rs +++ b/contracts/os/andromeda-kernel/src/execute.rs @@ -8,6 +8,7 @@ use andromeda_std::common::has_coins_merged; use andromeda_std::common::reply::ReplyId; use andromeda_std::error::ContractError; use andromeda_std::os::aos_querier::AOSQuerier; +#[cfg(not(target_arch = "wasm32"))] use andromeda_std::os::ibc_registry::path_to_hops; use andromeda_std::os::kernel::{ AcknowledgementMsg, ChannelInfo, IbcExecuteMsg, Ics20PacketInfo, InternalMsg, @@ -119,7 +120,7 @@ fn handle_ibc_transfer_funds_reply( &ics20_packet_info.funds.denom, &ics20_packet_info.channel, )?; - #[allow(unused_assignments)] + #[allow(unused_assignments, unused_mut)] let mut adjusted_funds = Coin::new( ics20_packet_info.funds.amount.u128(), counterparty_denom.clone(), diff --git a/ibc-tests/Cargo.toml b/ibc-tests/Cargo.toml index 55e874a6b..0df3aa3eb 100644 --- a/ibc-tests/Cargo.toml +++ b/ibc-tests/Cargo.toml @@ -5,14 +5,18 @@ edition = "2021" rust-version = "1.75.0" publish = false +# [[test]] +# name = "validator_staking" + [[test]] -name = "validator_staking" +name = "crowdfund" [dependencies] serde.workspace = true tokio = "1.39.3" cw-orch = { workspace = true } cw-orch-daemon = "0.24.2" +rstest = "0.19.0" andromeda-testing-e2e = { workspace = true } @@ -20,6 +24,22 @@ andromeda-app-contract = { path = "../contracts/app/andromeda-app-contract", fea "testing", ] } +andromeda-cw20 = { path = "../contracts/fungible-tokens/andromeda-cw20", features = [ + "testing", +] } + +andromeda-cw721 = { path = "../contracts/non-fungible-tokens/andromeda-cw721", features = [ + "testing", +] } + +andromeda-crowdfund = { path = "../contracts/non-fungible-tokens/andromeda-crowdfund", features = [ + "testing", +] } + +andromeda-splitter = { path = "../contracts/finance/andromeda-splitter", features = [ + "testing", +] } + andromeda-validator-staking = { path = "../contracts/finance/andromeda-validator-staking", features = [ "testing", ] } @@ -27,7 +47,11 @@ andromeda-validator-staking = { path = "../contracts/finance/andromeda-validator andromeda-finance = { workspace = true } andromeda-std = { workspace = true } andromeda-app = { workspace = true } +andromeda-fungible-tokens = { workspace = true } +andromeda-non-fungible-tokens = { workspace = true } cosmwasm-std = { workspace = true, features = ["staking"] } cosmrs = "0.19.0" prost-types = "0.13.1" +cw20.workspace = true +cw721.workspace = true diff --git a/ibc-tests/README.md b/ibc-tests/README.md index f1288204d..e4142fda6 100644 --- a/ibc-tests/README.md +++ b/ibc-tests/README.md @@ -1,12 +1,38 @@ # Summary -This package is intended for e2e testing of ADOs. +This package is designed for end-to-end (e2e) testing of ADOs. It supports deployment and testing across various blockchain networks. -# Prerequest -1. You need to run the local network for e2e test. Currently this package is using `develop` branch of [localrelayer](https://github.com/andromedaprotocol/localrelayer/). -***Do not forget to switch to `develop` branch. Otherwise, it won't work.*** -2. Copy necessary artifacts to `ibc-tests/artifacts` and `packages/andromeda-testing-e2e/artifacts`. +# Prerequisites +1. Ensure that the necessary artifacts are available in the following directories: + - `ibc-tests/artifacts` + - `packages/andromeda-testing-e2e/artifacts` -# Workflow -To run e2e tests, follow the following steps -1. Run the main function to setup aOS and necesary environment for each testing. -2. Run the test \ No newline at end of file + The `build.sh` script has been updated to automatically copy artifacts to the required locations in building process. + +2. To test ADOs in a local environment, you must run a local network. This package currently relies on the `develop` branch of [localrelayer](https://github.com/andromedaprotocol/localrelayer/). + +***Important:*** Switch to the `develop` branch before proceeding. + +# How to start +You can begin testing by simply executing the required test cases. + +# How to write custom test +The file `crowdfund.rs` fully leverages the functionality of the e2e test framework. +## `setup` function +The `setup` function is responsible for creating the necessary testing environment and injecting parameters into the test cases. You can define the parameters and implementation of the `setup` function based on your specific requirements. + +***Warning*** Remember to annotate the `setup` function with `#[fixture]`. + +## Injecting environment into test cases +To inject the test environment into each test, the function signature should follow this format: + +```rust +#[rstest] +fn (#[with()] setup: TestCase) +``` +In the `setup_params`, you can specify parameters that will be passed to the setup function. For the `crowdfund` test cases, you can include parameters such as `use_native_token`, `chain_info`, and `purchaser_balance`. If any parameters are omitted, they will default to predefined values. + +## Custom chain informations +Chain configurations are defined in `ibc-tests/src/constants.rs`. You can add or customize new chain information as needed. + +## Custom Interfaces +To test ADOs, their uploadable interfaces should be defined within `ibc-tests/src/interfaces`. \ No newline at end of file diff --git a/ibc-tests/src/constants.rs b/ibc-tests/src/constants.rs new file mode 100644 index 000000000..5ac6a401b --- /dev/null +++ b/ibc-tests/src/constants.rs @@ -0,0 +1,46 @@ +use cw_orch::{ + environment::{ChainKind, NetworkInfo}, + prelude::ChainInfo, +}; + +pub const USER_MNEMONIC: &str = "across left ignore gold echo argue track joy hire release captain enforce hotel wide flash hotel brisk joke midnight duck spare drop chronic stool"; + +pub const RECIPIENT_MNEMONIC_1: &str = "anger couple segment silk office amazing fat fortune arrow course love fabric pitch parade stone deliver answer mule text social truth gravity patch safe"; + +pub const RECIPIENT_MNEMONIC_2: &str = "envelope loyal junk top magic fun face gorilla large clay blur explain narrow intact fortune charge measure modify embrace there spare wood drip dignity"; + +pub const PURCHASER_MNEMONIC_1: &str = "drift taxi hip erosion trade army illegal party eager deliver season nature section brick twin gallery rate visual wood knee veteran regret steel okay"; + +pub const TERRA_NETWORK: NetworkInfo = NetworkInfo { + chain_name: "terra", + pub_address_prefix: "terra", + coin_type: 330u32, +}; + +pub const LOCAL_TERRA: ChainInfo = ChainInfo { + kind: ChainKind::Local, + chain_id: "localterraa-1", + gas_denom: "uluna", + gas_price: 0.15, + grpc_urls: &["http://localhost:20331"], + network_info: TERRA_NETWORK, + lcd_url: None, + fcd_url: None, +}; + +pub const WASM_NETWORK: NetworkInfo = NetworkInfo { + chain_name: "wasm", + pub_address_prefix: "wasm", + coin_type: 118u32, +}; + +pub const LOCAL_WASM: ChainInfo = ChainInfo { + kind: ChainKind::Local, + chain_id: "localwasma-1", + gas_denom: "ubindo", + gas_price: 0.15, + grpc_urls: &["http://localhost:20341"], + network_info: WASM_NETWORK, + lcd_url: None, + fcd_url: None, +}; diff --git a/ibc-tests/src/interface_macro.rs b/ibc-tests/src/interface_macro.rs index 462e40112..e4352ae27 100644 --- a/ibc-tests/src/interface_macro.rs +++ b/ibc-tests/src/interface_macro.rs @@ -18,7 +18,7 @@ macro_rules! contract_interface { fn wasm(_chain: &ChainInfoOwned) -> WasmPath { artifacts_dir_from_workspace!() - .find_wasm_path($wasm_path) + .find_wasm_path(&format!("andromeda_{}@", $wasm_path)) .unwrap() } } diff --git a/ibc-tests/src/lib.rs b/ibc-tests/src/lib.rs index 6c841d694..a4447cafb 100644 --- a/ibc-tests/src/lib.rs +++ b/ibc-tests/src/lib.rs @@ -1 +1,2 @@ +pub mod constants; pub mod interface_macro; diff --git a/ibc-tests/src/main.rs b/ibc-tests/src/main.rs index 40f249434..1e93effd6 100644 --- a/ibc-tests/src/main.rs +++ b/ibc-tests/src/main.rs @@ -1,9 +1,10 @@ use std::cmp; -use andromeda_std::ado_base::MigrateMsg; +use andromeda_app_contract::AppContract; +use andromeda_std::os::adodb::ExecuteMsgFns as AdodbExecuteMsgFns; use andromeda_testing_e2e::mock::{mock_app, MockAndromeda}; +use andromeda_validator_staking::ValidatorStakingContract; use cosmwasm_std::{coin, to_json_binary, Uint128}; -use cw_orch::interface; use cw_orch::prelude::*; use cw_orch::{ environment::{ChainKind, NetworkInfo}, @@ -13,10 +14,9 @@ use cw_orch_daemon::{ queriers::{Staking, StakingBondStatus}, DaemonBase, Wallet, }; -use ibc_tests::contract_interface; use andromeda_app::app::{self, AppComponent}; -use andromeda_finance::validator_staking; +use andromeda_finance::validator_staking::{self, ExecuteMsgFns as ValidatorStakingExecuteMsgFns}; const TESTNET_MNEMONIC: &str = "across left ignore gold echo argue track joy hire release captain enforce hotel wide flash hotel brisk joke midnight duck spare drop chronic stool"; pub const TERRA_NETWORK: NetworkInfo = NetworkInfo { @@ -36,14 +36,6 @@ pub const LOCAL_TERRA: ChainInfo = ChainInfo { fcd_url: None, }; -contract_interface!( - AppContract, - andromeda_app_contract, - app, - "andromeda_app_contract", - "app_contract" -); - fn main() { println!("//=============================Prereparing test environment===================================//"); @@ -75,25 +67,22 @@ fn main() { let app_contract = AppContract::new(daemon.clone()); app_contract.upload().unwrap(); - adodb_contract.clone().execute_publish( - app_contract.code_id().unwrap(), - "app-contract".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "app-contract".to_string(), + app_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); println!("app_contract->code_id: {:?}", app_contract.code_id()); println!("//==============================Base Test Environment Ready=================================//"); prepare_validator_staking(&daemon, &mock_andromeda, &app_contract); } -contract_interface!( - ValidatorStakingContract, - andromeda_validator_staking, - validator_staking, - "validator_staking_contract", - "validator_staking" -); - fn prepare_validator_staking( daemon: &DaemonBase, mock_andromeda: &MockAndromeda, @@ -110,11 +99,16 @@ fn prepare_validator_staking( adodb_contract, .. } = mock_andromeda; - adodb_contract.clone().execute_publish( - validator_staking_contract.code_id().unwrap(), - "validator-staking".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "validator-staking".to_string(), + validator_staking_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); println!("//================================Validator Staking Prepared-=================================//"); println!( @@ -158,14 +152,7 @@ fn prepare_validator_staking( app_contract.instantiate(&app_init_msg, None, None).unwrap(); - let get_addr_message = app::QueryMsg::GetAddress { - name: validator_staking_component.name, - }; - - let validator_staking_addr: String = daemon - .wasm_querier() - .smart_query(app_contract.addr_str().unwrap(), &get_addr_message) - .unwrap(); + let validator_staking_addr = app_contract.get_address(validator_staking_component.name); validator_staking_contract.set_address(&Addr::unchecked(validator_staking_addr)); @@ -184,16 +171,17 @@ fn prepare_validator_staking( println!("//===============================Processing Stake For testing=================================//"); validators.into_iter().for_each(|validator| { - let stake_msg = validator_staking::ExecuteMsg::Stake { - validator: Some(Addr::unchecked(validator.address.to_string())), - }; let balance = daemon .balance(daemon.sender_addr(), Some(denom.to_string())) .unwrap(); let amount_to_send = cmp::min(balance[0].amount, Uint128::new(10000000000)); validator_staking_contract - .execute(&stake_msg, Some(&[coin(amount_to_send.u128(), denom)])) + .stake( + Some(Addr::unchecked(validator.address.to_string())), + &[coin(amount_to_send.u128(), denom)], + ) .unwrap(); + println!( "validator: {:?}, delegator: {:?}", validator.address, diff --git a/ibc-tests/tests/crowdfund.rs b/ibc-tests/tests/crowdfund.rs new file mode 100644 index 000000000..aab75f930 --- /dev/null +++ b/ibc-tests/tests/crowdfund.rs @@ -0,0 +1,524 @@ +use std::str::FromStr; + +use andromeda_app::app::AppComponent; +use andromeda_app_contract::AppContract; +use andromeda_finance::splitter::{self, AddressPercent}; +use andromeda_fungible_tokens::cw20::{self as andr_cw20, ExecuteMsgFns as Cw20ExecuteMsgFns}; +use andromeda_non_fungible_tokens::{ + crowdfund::{ + self, CampaignConfig, CampaignStage, Cw20HookMsg, ExecuteMsgFns as CrowdfundExecuteMsgFns, + PresaleTierOrder, SimpleTierOrder, Tier, TierMetaData, + }, + cw721::{self, TokenExtension}, +}; +use andromeda_std::{ + amp::{AndrAddr, Recipient}, + common::{denom::Asset, expiration::Expiry, Milliseconds}, + os::adodb::ExecuteMsgFns as AdodbExecuteMsgFns, +}; +use andromeda_testing_e2e::{ + faucet::fund, + mock::{mock_app, MockAndromeda}, +}; +use cosmwasm_std::{coin, to_json_binary, Decimal, Uint128, Uint64}; +use cw20::{Cw20Coin, MinterResponse}; +use cw_orch::prelude::*; +use cw_orch_daemon::{DaemonBase, TxSender, Wallet}; +use ibc_tests::constants::{ + LOCAL_TERRA, LOCAL_WASM, PURCHASER_MNEMONIC_1, RECIPIENT_MNEMONIC_1, RECIPIENT_MNEMONIC_2, + USER_MNEMONIC, +}; + +use andromeda_crowdfund::CrowdfundContract; +use andromeda_cw20::CW20Contract; +use andromeda_cw721::CW721Contract; +use andromeda_splitter::SplitterContract; + +use andromeda_app::app; + +use rstest::{fixture, rstest}; + +struct TestCase { + daemon: DaemonBase, + crowdfund_contract: CrowdfundContract>, + cw20_contract: CW20Contract>, + cw721_contract: CW721Contract>, + splitter_contract: SplitterContract>, + presale: Vec, +} + +#[fixture] +fn setup( + #[default(true)] use_native_token: bool, + #[default(LOCAL_TERRA)] chain_info: ChainInfo, + #[default(100000000u128)] purchaser_balance: u128, +) -> TestCase { + let daemon = mock_app(chain_info.clone(), USER_MNEMONIC); + let mock_andromeda = MockAndromeda::new(&daemon); + + // Preparing contracts + let app_contract = AppContract::new(daemon.clone()); + app_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "app-contract".to_string(), + app_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + + let cw20_contract = CW20Contract::new(daemon.clone()); + cw20_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "cw20".to_string(), + cw20_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + + let cw721_contract = CW721Contract::new(daemon.clone()); + cw721_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "cw721".to_string(), + cw721_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + + let crowdfund_contract = CrowdfundContract::new(daemon.clone()); + crowdfund_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "crowdfund".to_string(), + crowdfund_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + + let splitter_contract = SplitterContract::new(daemon.clone()); + splitter_contract.upload().unwrap(); + mock_andromeda + .adodb_contract + .clone() + .publish( + "splitter".to_string(), + splitter_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); + + // Prepare App Components + let recipient_1_daemon = daemon + .rebuild() + .mnemonic(RECIPIENT_MNEMONIC_1) + .build() + .unwrap(); + let recipient_2_daemon = daemon + .rebuild() + .mnemonic(RECIPIENT_MNEMONIC_2) + .build() + .unwrap(); + + let purchaser_1_daemon = daemon + .rebuild() + .mnemonic(PURCHASER_MNEMONIC_1) + .build() + .unwrap(); + fund(&purchaser_1_daemon, &chain_info, purchaser_balance); + + let recipients = vec![ + AddressPercent { + recipient: Recipient::from_string(recipient_1_daemon.sender().address().to_string()), + percent: Decimal::from_str("0.2").unwrap(), + }, + AddressPercent { + recipient: Recipient::from_string(recipient_2_daemon.sender().address().to_string()), + percent: Decimal::from_str("0.8").unwrap(), + }, + ]; + + let kernel_address = mock_andromeda.kernel_contract.addr_str().unwrap(); + let splitter_init_msg = splitter::InstantiateMsg { + recipients, + lock_time: None, + kernel_address: kernel_address.clone(), + owner: None, + }; + + let splitter_component = AppComponent::new( + "splitter".to_string(), + "splitter".to_string(), + to_json_binary(&splitter_init_msg).unwrap(), + ); + + let cw721_init_msg = cw721::InstantiateMsg { + name: "Campaign Tier".to_string(), + symbol: "CT".to_string(), + minter: AndrAddr::from_string("./crowdfund".to_string()), + kernel_address: kernel_address.clone(), + owner: None, + }; + let cw721_component = AppComponent::new( + "cw721".to_string(), + "cw721".to_string(), + to_json_binary(&cw721_init_msg).unwrap(), + ); + + let initial_balances = vec![Cw20Coin { + address: purchaser_1_daemon.sender().address().to_string(), + amount: Uint128::from(purchaser_balance), + }]; + + let mint = Some(MinterResponse { + minter: daemon.sender().address().to_string(), + cap: Some(Uint128::from(10000000000u128)), + }); + let mut app_components = vec![splitter_component.clone(), cw721_component.clone()]; + let cw20_component: Option = match use_native_token { + true => None, + false => { + let cw20_init_msg = andr_cw20::InstantiateMsg { + name: "Test Tokens".to_string(), + symbol: "TTT".to_string(), + decimals: 6, + marketing: None, + mint, + initial_balances, + kernel_address: kernel_address.clone(), + owner: None, + }; + let cw20_component = AppComponent::new( + "cw20".to_string(), + "cw20".to_string(), + to_json_binary(&cw20_init_msg).unwrap(), + ); + app_components.push(cw20_component.clone()); + Some(cw20_component) + } + }; + + let denom = match use_native_token { + true => Asset::NativeToken(chain_info.gas_denom.to_string()), + false => Asset::Cw20Token(AndrAddr::from_string(format!( + "./{}", + cw20_component.clone().unwrap().name + ))), + }; + + let withdrawal_recipient = Recipient::new( + format!("./{}", splitter_component.name), + Some(to_json_binary(&splitter::ExecuteMsg::Send {}).unwrap()), + ); + + let campaign_config = CampaignConfig { + title: Some("Demo Crowdfund".to_string()), + description: Some("Crowdfund For Internal Testing".to_string()), + banner: Some("http://".to_string()), + url: Some("http://".to_string()), + token_address: AndrAddr::from_string(format!("./{}", cw721_component.name)), + denom, + withdrawal_recipient, + soft_cap: Some(Uint128::new(100000)), + hard_cap: None, + }; + + let crowdfund_init_msg = crowdfund::InstantiateMsg { + campaign_config, + kernel_address: kernel_address.clone(), + owner: None, + tiers: vec![], + }; + + let crowdfund_component = AppComponent::new( + "crowdfund".to_string(), + "crowdfund".to_string(), + to_json_binary(&crowdfund_init_msg).unwrap(), + ); + app_components.push(crowdfund_component.clone()); + + app_contract + .instantiate( + &app::InstantiateMsg { + app_components, + name: "Crowdfund App".to_string(), + chain_info: None, + kernel_address: kernel_address.clone(), + owner: None, + }, + None, + None, + ) + .unwrap(); + + let crowdfund_addr = app_contract.get_address(crowdfund_component.name); + crowdfund_contract.set_address(&Addr::unchecked(crowdfund_addr)); + + let cw721_addr = app_contract.get_address(cw721_component.name); + cw721_contract.set_address(&Addr::unchecked(cw721_addr)); + + let splitter_addr = app_contract.get_address(splitter_component.name); + splitter_contract.set_address(&Addr::unchecked(splitter_addr)); + + if !use_native_token { + let cw20_addr = app_contract.get_address(cw20_component.unwrap().name); + cw20_contract.set_address(&Addr::unchecked(cw20_addr)); + } + + let meta_data = TierMetaData { + token_uri: None, + extension: TokenExtension { + ..Default::default() + }, + }; + crowdfund_contract + .add_tier(Tier { + label: "Tier 1".to_string(), + level: Uint64::one(), + price: Uint128::new(10000), + limit: None, + metadata: meta_data.clone(), + }) + .unwrap(); + + crowdfund_contract + .add_tier(Tier { + label: "Tier 2".to_string(), + level: Uint64::new(2u64), + price: Uint128::new(20000), + limit: Some(Uint128::new(100)), + metadata: meta_data, + }) + .unwrap(); + + let presale = vec![PresaleTierOrder { + level: Uint64::one(), + amount: Uint128::new(10u128), + orderer: Addr::unchecked(purchaser_1_daemon.sender().address()), + }]; + + TestCase { + daemon, + crowdfund_contract, + cw20_contract, + cw721_contract, + splitter_contract, + presale, + } +} + +#[rstest] +fn test_successful_crowdfund_app_native(#[with(true, LOCAL_WASM)] setup: TestCase) { + let TestCase { + daemon, + mut crowdfund_contract, + presale, + cw721_contract, + .. + } = setup; + let recipient_1_daemon = daemon + .rebuild() + .mnemonic(RECIPIENT_MNEMONIC_1) + .build() + .unwrap(); + let recipient_1_balance = daemon + .balance( + recipient_1_daemon.sender_addr(), + Some(LOCAL_WASM.gas_denom.to_string()), + ) + .unwrap()[0] + .amount; + + let recipient_2_daemon = daemon + .rebuild() + .mnemonic(RECIPIENT_MNEMONIC_2) + .build() + .unwrap(); + let recipient_2_balance = daemon + .balance( + recipient_2_daemon.sender_addr(), + Some(LOCAL_WASM.gas_denom.to_string()), + ) + .unwrap()[0] + .amount; + + let start_time = None; + let end_time = Milliseconds::from_nanos(daemon.block_info().unwrap().time.plus_days(1).nanos()); + let end_time = Expiry::AtTime(end_time); + + crowdfund_contract + .start_campaign(end_time, Some(presale), start_time) + .unwrap(); + + let summary = crowdfund_contract.campaign_summary(); + assert_eq!(summary.current_capital, 0); + assert_eq!(summary.current_stage, CampaignStage::ONGOING.to_string()); + + let orders = vec![ + SimpleTierOrder { + level: Uint64::one(), + amount: Uint128::new(10), + }, + SimpleTierOrder { + level: Uint64::new(2), + amount: Uint128::new(10), + }, + ]; + + let purchaser_1_daemon = daemon + .rebuild() + .mnemonic(PURCHASER_MNEMONIC_1) + .build() + .unwrap(); + crowdfund_contract.set_sender(purchaser_1_daemon.sender()); + let funds = vec![coin(500000, LOCAL_WASM.gas_denom)]; + crowdfund_contract.purchase_tiers(orders, &funds).unwrap(); + + crowdfund_contract.set_sender(daemon.sender()); + crowdfund_contract.end_campaign().unwrap(); + + let summary = crowdfund_contract.campaign_summary(); + assert_eq!(summary.current_capital, 10 * 10000 + 20000 * 10); + assert_eq!(summary.current_stage, CampaignStage::SUCCESS.to_string()); + + let recipient_1_change = daemon + .balance( + recipient_1_daemon.sender_addr(), + Some(LOCAL_WASM.gas_denom.to_string()), + ) + .unwrap()[0] + .amount + - recipient_1_balance; + + let recipient_2_change = daemon + .balance( + recipient_2_daemon.sender_addr(), + Some(LOCAL_WASM.gas_denom.to_string()), + ) + .unwrap()[0] + .amount + - recipient_2_balance; + + assert_eq!(recipient_1_change.u128(), summary.current_capital / 5); + assert_eq!(recipient_2_change.u128(), summary.current_capital * 4 / 5); + + crowdfund_contract.set_sender(purchaser_1_daemon.sender()); + crowdfund_contract.claim().unwrap(); + + let owner_resp = cw721_contract.owner_of("0".to_string()).owner; + assert_eq!(owner_resp, purchaser_1_daemon.sender_addr().into_string()); + + let owner_resp = cw721_contract.owner_of("29".to_string()).owner; + assert_eq!(owner_resp, purchaser_1_daemon.sender_addr().into_string()); +} + +#[rstest] +fn test_successful_crowdfund_app_cw20(#[with(false)] setup: TestCase) { + let TestCase { + daemon, + mut crowdfund_contract, + presale, + mut cw20_contract, + cw721_contract, + splitter_contract, + .. + } = setup; + + let start_time = None; + let end_time = Milliseconds::from_nanos(daemon.block_info().unwrap().time.plus_days(1).nanos()); + let end_time = Expiry::AtTime(end_time); + + crowdfund_contract + .start_campaign(end_time, Some(presale), start_time) + .unwrap(); + + let summary = crowdfund_contract.campaign_summary(); + assert_eq!(summary.current_capital, 0); + assert_eq!(summary.current_stage, CampaignStage::ONGOING.to_string()); + + let recipient_balance = cw20_contract + .balance(splitter_contract.addr_str().unwrap()) + .balance; + + let orders = vec![ + SimpleTierOrder { + level: Uint64::one(), + amount: Uint128::new(10), + }, + SimpleTierOrder { + level: Uint64::new(2), + amount: Uint128::new(10), + }, + ]; + + let hook_msg = to_json_binary(&Cw20HookMsg::PurchaseTiers { orders }).unwrap(); + + let purchaser_1_daemon = daemon + .rebuild() + .mnemonic(PURCHASER_MNEMONIC_1) + .build() + .unwrap(); + + let purchaser_1_balance = cw20_contract + .balance(purchaser_1_daemon.sender_addr()) + .balance; + + cw20_contract.set_sender(purchaser_1_daemon.sender()); + cw20_contract + .send( + Uint128::new(500000), + AndrAddr::from_string(crowdfund_contract.addr_str().unwrap()), + hook_msg, + ) + .unwrap(); + cw20_contract.set_sender(daemon.sender()); + + let purchaser_1_change = purchaser_1_balance + - cw20_contract + .balance(purchaser_1_daemon.sender_addr()) + .balance; + + assert_eq!(purchaser_1_change, Uint128::new(10 * 10000 + 20000 * 10)); + + crowdfund_contract.end_campaign().unwrap(); + + let summary = crowdfund_contract.campaign_summary(); + assert_eq!(summary.current_capital, 10 * 10000 + 20000 * 10); + assert_eq!(summary.current_stage, CampaignStage::SUCCESS.to_string()); + + // Splitter is only working for native token, not for cw20 token + let recipient_change = cw20_contract + .balance(splitter_contract.addr_str().unwrap()) + .balance + - recipient_balance; + + assert_eq!(recipient_change.u128(), summary.current_capital); + + crowdfund_contract.set_sender(purchaser_1_daemon.sender()); + crowdfund_contract.claim().unwrap(); + + let owner_resp = cw721_contract.owner_of("0".to_string()).owner; + assert_eq!(owner_resp, purchaser_1_daemon.sender_addr().into_string()); + + let owner_resp = cw721_contract.owner_of("29".to_string()).owner; + assert_eq!(owner_resp, purchaser_1_daemon.sender_addr().into_string()); +} diff --git a/ibc-tests/tests/validator_staking.rs b/ibc-tests/tests/validator_staking.rs index 5bb2361c9..42c7cd0e2 100644 --- a/ibc-tests/tests/validator_staking.rs +++ b/ibc-tests/tests/validator_staking.rs @@ -1,56 +1,16 @@ -use andromeda_std::ado_base::MigrateMsg; +use andromeda_finance::validator_staking::ExecuteMsgFns; +use andromeda_validator_staking::ValidatorStakingContract; use cosmwasm_std::Uint128; -use cw_orch::environment::ChainKind; -use cw_orch::environment::NetworkInfo; -use cw_orch::interface; use cw_orch::prelude::*; use cw_orch_daemon::queriers::Staking; use cw_orch_daemon::queriers::StakingBondStatus; use cw_orch_daemon::Daemon; -use ibc_tests::contract_interface; - -// import messages -use andromeda_app::app; -use andromeda_finance::validator_staking; +use ibc_tests::constants::LOCAL_TERRA; const TESTNET_MNEMONIC: &str = "across left ignore gold echo argue track joy hire release captain enforce hotel wide flash hotel brisk joke midnight duck spare drop chronic stool"; -// define app contract interface -contract_interface!( - AppContract, - andromeda_app_contract, - app, - "andromeda_app_contract", - "app_contract" -); - -// include ados be tested -contract_interface!( - ValidatorStakingContract, - andromeda_validator_staking, - validator_staking, - "validator_staking_contract", - "validator_staking" -); - -pub const TERRA_NETWORK: NetworkInfo = NetworkInfo { - chain_name: "terra", - pub_address_prefix: "terra", - coin_type: 330u32, -}; - -pub const LOCAL_TERRA: ChainInfo = ChainInfo { - kind: ChainKind::Local, - chain_id: "localterraa-1", - gas_denom: "uluna", - gas_price: 0.15, - grpc_urls: &["http://localhost:20331"], - network_info: TERRA_NETWORK, - lcd_url: None, - fcd_url: None, -}; - #[test] +#[ignore] fn test_validator_staking() { let local_terra = LOCAL_TERRA; let daemon = Daemon::builder(local_terra.clone()) // set the network to use @@ -82,37 +42,27 @@ fn test_validator_staking() { let default_validator = &validators[0]; - let staking_query_msg = validator_staking::QueryMsg::StakedTokens { - validator: Some(Addr::unchecked(default_validator.address.to_string())), - }; let _rewards_response: Option = validator_staking_contract - .query(&staking_query_msg) - .unwrap(); + .staked_tokens(Some(Addr::unchecked(default_validator.address.to_string()))); - let claim_msg = validator_staking::ExecuteMsg::Claim { - validator: Some(Addr::unchecked(default_validator.address.to_string())), - restake: None, - }; validator_staking_contract - .execute(&claim_msg, None) + .claim( + None, + Some(Addr::unchecked(default_validator.address.to_string())), + ) .unwrap(); - let unstake_msg = validator_staking::ExecuteMsg::Unstake { - validator: Some(Addr::unchecked(default_validator.address.to_string())), - amount: None, - }; validator_staking_contract - .execute(&unstake_msg, None) + .unstake( + None, + Some(Addr::unchecked(default_validator.address.to_string())), + ) .unwrap(); daemon.wait_seconds(61).unwrap(); - let withdraw_msg = validator_staking::ExecuteMsg::WithdrawFunds { - denom: Some(denom.to_string()), - recipient: None, - }; validator_staking_contract - .execute(&withdraw_msg, None) + .withdraw_funds(Some(denom.to_string()), None) .unwrap(); let contract_balance = daemon @@ -126,6 +76,7 @@ fn test_validator_staking() { } #[test] +#[ignore] fn test_kicked_validator() { // Pause validator before running this test let local_terra = LOCAL_TERRA; @@ -175,30 +126,24 @@ fn test_kicked_validator() { .amount; assert_eq!(contract_balance, Uint128::zero()); - let claim_msg = validator_staking::ExecuteMsg::Claim { - validator: Some(Addr::unchecked(kicked_validator.address.to_string())), - restake: None, - }; validator_staking_contract - .execute(&claim_msg, None) + .claim( + None, + Some(Addr::unchecked(kicked_validator.address.to_string())), + ) .unwrap(); - let unstake_msg = validator_staking::ExecuteMsg::Unstake { - validator: Some(Addr::unchecked(kicked_validator.address.to_string())), - amount: None, - }; validator_staking_contract - .execute(&unstake_msg, None) + .unstake( + None, + Some(Addr::unchecked(kicked_validator.address.to_string())), + ) .unwrap(); daemon.wait_seconds(61).unwrap(); - let withdraw_msg = validator_staking::ExecuteMsg::WithdrawFunds { - denom: Some(denom.to_string()), - recipient: None, - }; validator_staking_contract - .execute(&withdraw_msg, None) + .withdraw_funds(Some(denom.to_string()), None) .unwrap(); let contract_balance = daemon diff --git a/packages/andromeda-app/Cargo.toml b/packages/andromeda-app/Cargo.toml index bd45cc835..581c5adba 100644 --- a/packages/andromeda-app/Cargo.toml +++ b/packages/andromeda-app/Cargo.toml @@ -8,6 +8,8 @@ license = "MIT" [features] backtraces = ["cosmwasm-std/backtraces"] +testing = ["cw-multi-test"] +library = [] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] @@ -19,5 +21,6 @@ cosmwasm-schema = { workspace = true } serde = { workspace = true } andromeda-std = { workspace = true } -[dev-dependencies] -cw-multi-test = { version = "1.0.0" } +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cw-orch = { workspace = true } +cw-multi-test = { workspace = true, optional = true } diff --git a/packages/andromeda-finance/Cargo.toml b/packages/andromeda-finance/Cargo.toml index 43757aa94..b24996187 100644 --- a/packages/andromeda-finance/Cargo.toml +++ b/packages/andromeda-finance/Cargo.toml @@ -12,6 +12,7 @@ backtraces = ["cosmwasm-std/backtraces"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] crate-type = ["cdylib", "rlib"] +testing = ["cw-multi-test"] [dependencies] cosmwasm-std = { workspace = true, features = ["staking"] } @@ -25,3 +26,7 @@ cw721-base = { workspace = true } schemars = { version = "0.8.10" } andromeda-std = { workspace = true } + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cw-orch = { workspace = true } +cw-multi-test = { workspace = true, optional = true } diff --git a/packages/andromeda-finance/src/validator_staking.rs b/packages/andromeda-finance/src/validator_staking.rs index 1c1a0e4be..dbd79c2b9 100644 --- a/packages/andromeda-finance/src/validator_staking.rs +++ b/packages/andromeda-finance/src/validator_staking.rs @@ -14,7 +14,9 @@ pub struct InstantiateMsg { #[andr_exec] #[cw_serde] +#[cfg_attr(not(target_arch = "wasm32"), derive(cw_orch::ExecuteFns))] pub enum ExecuteMsg { + #[cfg_attr(not(target_arch = "wasm32"), cw_orch(payable))] Stake { validator: Option, }, diff --git a/packages/andromeda-fungible-tokens/Cargo.toml b/packages/andromeda-fungible-tokens/Cargo.toml index 51e023857..bd892e68c 100644 --- a/packages/andromeda-fungible-tokens/Cargo.toml +++ b/packages/andromeda-fungible-tokens/Cargo.toml @@ -12,6 +12,7 @@ backtraces = ["cosmwasm-std/backtraces"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] crate-type = ["cdylib", "rlib"] +testing = ["cw-multi-test"] [dependencies] cosmwasm-std = { workspace = true } @@ -24,3 +25,7 @@ cw-asset = { workspace = true } cw-controllers = "=1.1.2" andromeda-std = { workspace = true } + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cw-orch = { workspace = true } +cw-multi-test = { workspace = true, optional = true } diff --git a/packages/andromeda-fungible-tokens/src/cw20.rs b/packages/andromeda-fungible-tokens/src/cw20.rs index 9422fa6f6..5f9a4fe21 100644 --- a/packages/andromeda-fungible-tokens/src/cw20.rs +++ b/packages/andromeda-fungible-tokens/src/cw20.rs @@ -34,6 +34,7 @@ impl From for Cw20InstantiateMsg { #[andr_exec] #[cw_serde] +#[cfg_attr(not(target_arch = "wasm32"), derive(cw_orch::ExecuteFns))] pub enum ExecuteMsg { /// Transfer is a base message to move tokens to another account without triggering actions Transfer { diff --git a/packages/andromeda-non-fungible-tokens/Cargo.toml b/packages/andromeda-non-fungible-tokens/Cargo.toml index 63f638cd9..ddf767d70 100644 --- a/packages/andromeda-non-fungible-tokens/Cargo.toml +++ b/packages/andromeda-non-fungible-tokens/Cargo.toml @@ -8,6 +8,7 @@ license = "MIT" [features] backtraces = ["cosmwasm-std/backtraces"] +testing = ["cw-multi-test"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] @@ -23,3 +24,7 @@ cw721-base = { workspace = true } cw20 = { workspace = true } andromeda-std = { workspace = true } + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cw-orch = { workspace = true } +cw-multi-test = { workspace = true, optional = true } diff --git a/packages/andromeda-non-fungible-tokens/src/auction.rs b/packages/andromeda-non-fungible-tokens/src/auction.rs index 3fdec0bfa..5e8b800c5 100644 --- a/packages/andromeda-non-fungible-tokens/src/auction.rs +++ b/packages/andromeda-non-fungible-tokens/src/auction.rs @@ -1,5 +1,5 @@ use andromeda_std::amp::{AndrAddr, Recipient}; -use andromeda_std::common::denom::{Asset, AuthorizedAddressesResponse, PermissionAction}; +use andromeda_std::common::denom::{Asset, PermissionAction}; use andromeda_std::common::expiration::Expiry; use andromeda_std::common::{MillisecondsExpiration, OrderBy}; use andromeda_std::error::ContractError; @@ -123,7 +123,7 @@ pub enum QueryMsg { limit: Option, }, /// Gets all of the authorized addresses for the auction - #[returns(AuthorizedAddressesResponse)] + #[returns(::andromeda_std::common::denom::AuthorizedAddressesResponse)] AuthorizedAddresses { action: PermissionAction, start_after: Option, diff --git a/packages/andromeda-non-fungible-tokens/src/crowdfund.rs b/packages/andromeda-non-fungible-tokens/src/crowdfund.rs index abd70ec9c..e3783aeab 100644 --- a/packages/andromeda-non-fungible-tokens/src/crowdfund.rs +++ b/packages/andromeda-non-fungible-tokens/src/crowdfund.rs @@ -22,6 +22,7 @@ pub struct InstantiateMsg { #[andr_exec] #[cw_serde] +#[cfg_attr(not(target_arch = "wasm32"), derive(cw_orch::ExecuteFns))] pub enum ExecuteMsg { /// Add a tier AddTier { tier: Tier }, @@ -36,6 +37,7 @@ pub enum ExecuteMsg { presale: Option>, }, /// Purchase tiers + #[cfg_attr(not(target_arch = "wasm32"), cw_orch(payable))] PurchaseTiers { orders: Vec }, /// Purchase tiers with cw20 Receive(Cw20ReceiveMsg), diff --git a/packages/andromeda-non-fungible-tokens/src/marketplace.rs b/packages/andromeda-non-fungible-tokens/src/marketplace.rs index f5eb2fbc6..e188e0791 100644 --- a/packages/andromeda-non-fungible-tokens/src/marketplace.rs +++ b/packages/andromeda-non-fungible-tokens/src/marketplace.rs @@ -2,7 +2,7 @@ use andromeda_std::{ amp::{AndrAddr, Recipient}, andr_exec, andr_instantiate, andr_query, common::{ - denom::{Asset, AuthorizedAddressesResponse, PermissionAction}, + denom::{Asset, PermissionAction}, expiration::Expiry, MillisecondsDuration, OrderBy, }, @@ -129,7 +129,7 @@ pub enum QueryMsg { start_after: Option, limit: Option, }, - #[returns(AuthorizedAddressesResponse)] + #[returns(::andromeda_std::common::denom::AuthorizedAddressesResponse)] AuthorizedAddresses { action: PermissionAction, start_after: Option, diff --git a/packages/andromeda-testing-e2e/src/adodb.rs b/packages/andromeda-testing-e2e/src/adodb.rs deleted file mode 100644 index fba2b23bd..000000000 --- a/packages/andromeda-testing-e2e/src/adodb.rs +++ /dev/null @@ -1,39 +0,0 @@ -use crate::contract_interface; -use andromeda_std::ado_base::MigrateMsg; -use cw_orch::interface; -use cw_orch::prelude::*; - -use andromeda_std::os::adodb; -use cw_orch_daemon::DaemonBase; -use cw_orch_daemon::Wallet; - -contract_interface!( - AdodbContract, - andromeda_adodb, - adodb, - "adodb_contract", - "adodb" -); -impl AdodbContract> { - pub fn init(self, kernel_address: String) { - let msg = adodb::InstantiateMsg { - kernel_address, - owner: None, - }; - self.instantiate(&msg, None, None).unwrap(); - } - - pub fn execute_publish(self, code_id: u64, ado_type: String, version: String) { - self.execute( - &adodb::ExecuteMsg::Publish { - code_id, - ado_type, - action_fees: None, - version, - publisher: None, - }, - None, - ) - .unwrap(); - } -} diff --git a/packages/andromeda-testing-e2e/src/economics.rs b/packages/andromeda-testing-e2e/src/economics.rs deleted file mode 100644 index 58f45001f..000000000 --- a/packages/andromeda-testing-e2e/src/economics.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::contract_interface; -use andromeda_std::ado_base::MigrateMsg; -use cw_orch::interface; -use cw_orch::prelude::*; - -use andromeda_std::os::economics; -use cw_orch_daemon::DaemonBase; -use cw_orch_daemon::Wallet; - -contract_interface!( - EconomicsContract, - andromeda_economics, - economics, - "economics_contract", - "economics" -); -impl EconomicsContract> { - pub fn init(self, kernel_address: String) { - let msg = economics::InstantiateMsg { - kernel_address, - owner: None, - }; - self.instantiate(&msg, None, None).unwrap(); - } -} diff --git a/packages/andromeda-testing-e2e/src/interface_macro.rs b/packages/andromeda-testing-e2e/src/interface_macro.rs deleted file mode 100644 index 462e40112..000000000 --- a/packages/andromeda-testing-e2e/src/interface_macro.rs +++ /dev/null @@ -1,26 +0,0 @@ -#[macro_export] -macro_rules! contract_interface { - ($contract_name:ident, $module_path:ident, $package_path:ident, $contract_id:expr, $wasm_path:expr) => { - #[interface($package_path::InstantiateMsg, $package_path::ExecuteMsg, $package_path::QueryMsg, MigrateMsg, id = $contract_id)] - pub struct $contract_name; - - impl Uploadable for $contract_name { - fn wrapper() -> Box> { - Box::new( - ContractWrapper::new_with_empty( - $module_path::contract::execute, - $module_path::contract::instantiate, - $module_path::contract::query, - ) - .with_migrate($module_path::contract::migrate), - ) - } - - fn wasm(_chain: &ChainInfoOwned) -> WasmPath { - artifacts_dir_from_workspace!() - .find_wasm_path($wasm_path) - .unwrap() - } - } - }; -} diff --git a/packages/andromeda-testing-e2e/src/kernel.rs b/packages/andromeda-testing-e2e/src/kernel.rs deleted file mode 100644 index ebf375eaa..000000000 --- a/packages/andromeda-testing-e2e/src/kernel.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::contract_interface; -use andromeda_std::ado_base::MigrateMsg; -use cw_orch::interface; -use cw_orch::prelude::*; - -use andromeda_std::os::kernel; -use cw_orch_daemon::DaemonBase; -use cw_orch_daemon::Wallet; - -contract_interface!( - KernelContract, - andromeda_kernel, - kernel, - "kernel_contract", - "kernel" -); - -impl KernelContract> { - pub fn init(self, chain_name: String) { - let msg = kernel::InstantiateMsg { - chain_name, - owner: None, - }; - self.instantiate(&msg, None, None).unwrap(); - } - - pub fn execute_store_key_address(self, key: String, value: String) { - self.execute(&kernel::ExecuteMsg::UpsertKeyAddress { key, value }, None) - .unwrap(); - } -} diff --git a/packages/andromeda-testing-e2e/src/lib.rs b/packages/andromeda-testing-e2e/src/lib.rs index e96f910f9..fff67acab 100644 --- a/packages/andromeda-testing-e2e/src/lib.rs +++ b/packages/andromeda-testing-e2e/src/lib.rs @@ -1,20 +1,5 @@ #[cfg(not(target_arch = "wasm32"))] pub mod faucet; -#[cfg(not(target_arch = "wasm32"))] -pub mod interface_macro; - #[cfg(not(target_arch = "wasm32"))] pub mod mock; - -#[cfg(not(target_arch = "wasm32"))] -pub mod kernel; - -#[cfg(not(target_arch = "wasm32"))] -pub mod adodb; - -#[cfg(not(target_arch = "wasm32"))] -pub mod vfs; - -#[cfg(not(target_arch = "wasm32"))] -pub mod economics; diff --git a/packages/andromeda-testing-e2e/src/mock.rs b/packages/andromeda-testing-e2e/src/mock.rs index 1d6d68b9b..ae99de768 100644 --- a/packages/andromeda-testing-e2e/src/mock.rs +++ b/packages/andromeda-testing-e2e/src/mock.rs @@ -1,10 +1,17 @@ +use andromeda_adodb::ADODBContract; +use andromeda_economics::EconomicsContract; +use andromeda_kernel::KernelContract; +use andromeda_std::os::{ + adodb::{self, ExecuteMsgFns}, + economics, + kernel::{self, ExecuteMsgFns as KernelExecuteMsgFns}, + vfs, +}; +use andromeda_vfs::VFSContract; use cw_orch::prelude::*; use cw_orch_daemon::{Daemon, DaemonBase, Wallet}; -use crate::{ - adodb::AdodbContract, economics::EconomicsContract, faucet::fund, kernel::KernelContract, - vfs::VfsContract, -}; +use crate::faucet::fund; pub fn mock_app(chain: ChainInfo, mnemonic: &str) -> DaemonBase { let daemon = Daemon::builder(chain.clone()) // set the network to use @@ -19,8 +26,8 @@ pub fn mock_app(chain: ChainInfo, mnemonic: &str) -> DaemonBase { pub struct MockAndromeda { pub kernel_contract: KernelContract>, - pub adodb_contract: AdodbContract>, - pub vfs_contract: VfsContract>, + pub adodb_contract: ADODBContract>, + pub vfs_contract: VFSContract>, pub economics_contract: EconomicsContract>, } @@ -31,56 +38,110 @@ impl MockAndromeda { // Upload and instantiate os ADOs let kernel_contract = KernelContract::new(daemon.clone()); kernel_contract.upload().unwrap(); - kernel_contract.clone().init(chain_name); + kernel_contract + .clone() + .instantiate( + &kernel::InstantiateMsg { + chain_name, + owner: None, + }, + None, + None, + ) + .unwrap(); - let adodb_contract = AdodbContract::new(daemon.clone()); + let adodb_contract = ADODBContract::new(daemon.clone()); adodb_contract.upload().unwrap(); adodb_contract .clone() - .init(kernel_contract.addr_str().unwrap()); + .instantiate( + &adodb::InstantiateMsg { + kernel_address: kernel_contract.addr_str().unwrap(), + owner: None, + }, + None, + None, + ) + .unwrap(); - let vfs_contract = VfsContract::new(daemon.clone()); + let vfs_contract = VFSContract::new(daemon.clone()); vfs_contract.upload().unwrap(); vfs_contract .clone() - .init(kernel_contract.addr_str().unwrap()); + .instantiate( + &vfs::InstantiateMsg { + kernel_address: kernel_contract.addr_str().unwrap(), + owner: None, + }, + None, + None, + ) + .unwrap(); let economics_contract = EconomicsContract::new(daemon.clone()); economics_contract.upload().unwrap(); economics_contract .clone() - .init(kernel_contract.addr_str().unwrap()); + .instantiate( + &economics::InstantiateMsg { + kernel_address: kernel_contract.addr_str().unwrap(), + owner: None, + }, + None, + None, + ) + .unwrap(); - // register code ids in ado db - adodb_contract.clone().execute_publish( - adodb_contract.code_id().unwrap(), - "adodb".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "adodb".to_string(), + adodb_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); - adodb_contract.clone().execute_publish( - vfs_contract.code_id().unwrap(), - "vfs".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "vfs".to_string(), + vfs_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); - adodb_contract.clone().execute_publish( - kernel_contract.code_id().unwrap(), - "kernel".to_string(), - "0.1.0".to_string(), - ); + adodb_contract + .clone() + .publish( + "kernel".to_string(), + kernel_contract.code_id().unwrap(), + "0.1.0".to_string(), + None, + None, + ) + .unwrap(); // update kernel kernel_contract .clone() - .execute_store_key_address("adodb".to_string(), adodb_contract.addr_str().unwrap()); + .upsert_key_address("adodb".to_string(), adodb_contract.addr_str().unwrap()) + .unwrap(); + // .upsert_key_address("adodb".to_string(), adodb_contract.addr_str().unwrap()); + kernel_contract + .clone() + .upsert_key_address("vfs".to_string(), vfs_contract.addr_str().unwrap()) + .unwrap(); kernel_contract .clone() - .execute_store_key_address("vfs".to_string(), vfs_contract.addr_str().unwrap()); - kernel_contract.clone().execute_store_key_address( - "economics".to_string(), - economics_contract.addr_str().unwrap(), - ); + .upsert_key_address( + "economics".to_string(), + economics_contract.addr_str().unwrap(), + ) + .unwrap(); MockAndromeda { kernel_contract, diff --git a/packages/andromeda-testing-e2e/src/vfs.rs b/packages/andromeda-testing-e2e/src/vfs.rs deleted file mode 100644 index 6e29963fc..000000000 --- a/packages/andromeda-testing-e2e/src/vfs.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::contract_interface; -use andromeda_std::ado_base::MigrateMsg; -use cw_orch::interface; -use cw_orch::prelude::*; - -use andromeda_std::os::vfs; -use cw_orch_daemon::DaemonBase; -use cw_orch_daemon::Wallet; - -contract_interface!(VfsContract, andromeda_vfs, vfs, "vfs_contract", "vfs"); -impl VfsContract> { - pub fn init(self, kernel_address: String) { - let msg = vfs::InstantiateMsg { - kernel_address, - owner: None, - }; - self.instantiate(&msg, None, None).unwrap(); - } -} diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 818764f8f..7c0af0a64 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -40,11 +40,13 @@ cw721 = { workspace = true } serde-json-wasm = "1.0.1" enum-repr = { workspace = true } sha2 = "0.10.8" -cw-orch = { workspace = true } osmosis-std-derive = { version = "0.15.3", optional = true } prost = { version = "0.11.2", default-features = false, features = [ "prost-derive", ], optional = true } [dev-dependencies] -cw-multi-test = { version = "1.0.0" } +cw-multi-test = { workspace = true } + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cw-orch = { workspace = true } diff --git a/packages/std/src/os/adodb.rs b/packages/std/src/os/adodb.rs index 42e12f2f9..7ad7da9b2 100644 --- a/packages/std/src/os/adodb.rs +++ b/packages/std/src/os/adodb.rs @@ -15,7 +15,7 @@ pub struct InstantiateMsg { } #[cw_serde] -#[derive(cw_orch::ExecuteFns)] +#[cfg_attr(not(target_arch = "wasm32"), derive(cw_orch::ExecuteFns))] pub enum ExecuteMsg { Publish { code_id: u64, @@ -126,7 +126,8 @@ pub struct ADOMetadata { } #[cw_serde] -#[derive(cw_orch::QueryFns, QueryResponses)] +#[cfg_attr(not(target_arch = "wasm32"), derive(cw_orch::QueryFns))] +#[derive(QueryResponses)] pub enum QueryMsg { #[returns(u64)] CodeId { key: String }, diff --git a/packages/std/src/os/ibc_registry.rs b/packages/std/src/os/ibc_registry.rs index 02e30c3ca..9c41732fb 100644 --- a/packages/std/src/os/ibc_registry.rs +++ b/packages/std/src/os/ibc_registry.rs @@ -40,7 +40,8 @@ pub struct IBCDenomInfo { } #[cw_serde] -#[derive(AsRefStr, cw_orch::ExecuteFns)] +#[derive(AsRefStr)] +#[cfg_attr(not(target_arch = "wasm32"), derive(cw_orch::ExecuteFns))] pub enum ExecuteMsg { /// Receives an AMP Packet for relaying #[serde(rename = "amp_receive")] diff --git a/packages/std/src/os/kernel.rs b/packages/std/src/os/kernel.rs index 8f610484e..706e5eaeb 100644 --- a/packages/std/src/os/kernel.rs +++ b/packages/std/src/os/kernel.rs @@ -35,7 +35,7 @@ pub struct InstantiateMsg { } #[cw_serde] -#[derive(cw_orch::ExecuteFns)] +#[cfg_attr(not(target_arch = "wasm32"), derive(cw_orch::ExecuteFns))] pub enum ExecuteMsg { /// Receives an AMP Packet for relaying #[serde(rename = "amp_receive")] @@ -103,7 +103,8 @@ pub struct ChainNameResponse { } #[cw_serde] -#[derive(cw_orch::QueryFns, QueryResponses)] +#[cfg_attr(not(target_arch = "wasm32"), derive(cw_orch::QueryFns))] +#[derive(QueryResponses)] pub enum QueryMsg { #[returns(cosmwasm_std::Addr)] KeyAddress { key: String }, diff --git a/packages/std/src/os/vfs.rs b/packages/std/src/os/vfs.rs index 74240dc59..58cdad62d 100644 --- a/packages/std/src/os/vfs.rs +++ b/packages/std/src/os/vfs.rs @@ -149,7 +149,7 @@ impl PathDetails { } #[cw_serde] -#[derive(cw_orch::ExecuteFns)] +#[cfg_attr(not(target_arch = "wasm32"), derive(cw_orch::ExecuteFns))] pub enum ExecuteMsg { AddPath { #[schemars(regex = "COMPONENT_NAME_REGEX")] diff --git a/scripts/build.sh b/scripts/build.sh index 493442b34..4977df088 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -26,11 +26,16 @@ build_contract () { fi local BUILD_TARGET=${CONTRACT//-/_} - local VERSION_FILENAME=$(get_version_filename $CONTRACT); + # local VERSION_FILENAME=$(get_version_filename $CONTRACT); local IN_FILE="./target/wasm32-unknown-unknown/release/$BUILD_TARGET.wasm" - local OUT_FILE="./artifacts/$VERSION_FILENAME.wasm" + local OUT_FILE="./artifacts/$BUILD_TARGET.wasm" + local OUT_FILE_IBC_TEST="./ibc-tests/artifacts/$BUILD_TARGET.wasm" + local OUT_FILE_PACKAGE="./packages/andromeda-testing-e2e/artifacts/$BUILD_TARGET.wasm" + wasm-opt -Os $IN_FILE -o $OUT_FILE + cp $IN_FILE $OUT_FILE_IBC_TEST + cp $IN_FILE $OUT_FILE_PACKAGE # NOT SO IMPORTANT STEPS # Log wasm file sizes at the end of build process @@ -84,7 +89,11 @@ export RUSTFLAGS="-C link-arg=-s" #Clear current builds rm -rf ./target rm -rf ./artifacts +rm -rf ./packages/andromeda-testing-e2e/artifacts +rm -rf ./ibc-tests/artifacts mkdir artifacts +mkdir packages/andromeda-testing-e2e/artifacts +mkdir ibc-tests/artifacts set -e for target in "$@"; do diff --git a/tests-integration/Cargo.toml b/tests-integration/Cargo.toml index 64fe4a2d7..96302c2cf 100644 --- a/tests-integration/Cargo.toml +++ b/tests-integration/Cargo.toml @@ -5,9 +5,6 @@ edition = "2021" rust-version = "1.75.0" publish = false -[features] -modules = [] - [dev-dependencies] #App andromeda-app = { workspace = true } @@ -176,3 +173,12 @@ rstest = "0.23.0" # [[test]] # name = "kernel" + +[[test]] +name = "set_amount_splitter" + +[[test]] +name = "cw20_staking" + +[[test]] +name = "ibc_registry" diff --git a/tests-integration/tests/app.rs b/tests-integration/tests/app.rs index be5e8052a..cece7328f 100644 --- a/tests-integration/tests/app.rs +++ b/tests-integration/tests/app.rs @@ -1,5 +1,3 @@ -#![cfg(not(target_arch = "wasm32"))] - use andromeda_app::app::AppComponent; use andromeda_app_contract::mock::{mock_andromeda_app, MockAppContract}; use andromeda_cw721::mock::{mock_andromeda_cw721, mock_cw721_instantiate_msg}; diff --git a/tests-integration/tests/auction_app.rs b/tests-integration/tests/auction_app.rs index 1cc85f6e0..b6e76e29f 100644 --- a/tests-integration/tests/auction_app.rs +++ b/tests-integration/tests/auction_app.rs @@ -1,5 +1,3 @@ -#![cfg(not(target_arch = "wasm32"))] - use andromeda_app::app::AppComponent; use andromeda_app_contract::mock::{mock_andromeda_app, mock_claim_ownership_msg, MockAppContract}; use andromeda_auction::mock::{ diff --git a/tests-integration/tests/cw20_app.rs b/tests-integration/tests/cw20_app.rs index bfea341b8..9fe6fb8e7 100644 --- a/tests-integration/tests/cw20_app.rs +++ b/tests-integration/tests/cw20_app.rs @@ -1,4 +1,3 @@ -#![cfg(not(target_arch = "wasm32"))] use andromeda_app::app::AppComponent; use andromeda_app_contract::mock::{mock_andromeda_app, mock_claim_ownership_msg, MockAppContract}; use andromeda_cw20::mock::{mock_andromeda_cw20, mock_cw20_instantiate_msg, mock_minter, MockCW20}; diff --git a/tests-integration/tests/kernel_orch.rs b/tests-integration/tests/kernel_orch.rs index b4e339789..6a35c0be6 100644 --- a/tests-integration/tests/kernel_orch.rs +++ b/tests-integration/tests/kernel_orch.rs @@ -1,4 +1,3 @@ -#![cfg(not(target_arch = "wasm32"))] use andromeda_adodb::ADODBContract; use andromeda_counter::CounterContract; use andromeda_data_storage::counter::{ diff --git a/tests-integration/tests/marketplace_app.rs b/tests-integration/tests/marketplace_app.rs index d406b8813..e6dec7b6f 100644 --- a/tests-integration/tests/marketplace_app.rs +++ b/tests-integration/tests/marketplace_app.rs @@ -1,4 +1,3 @@ -#![cfg(all(not(target_arch = "wasm32"), feature = "testing", feature = "rates"))] use andromeda_address_list::mock::{ mock_address_list_instantiate_msg, mock_andromeda_address_list, MockAddressList, }; @@ -93,7 +92,7 @@ fn test_marketplace_app() { ); let marketplace_init_msg = - mock_marketplace_instantiate_msg(andr.kernel.addr().to_string(), None, None); + mock_marketplace_instantiate_msg(andr.kernel.addr().to_string(), None, None, None); let marketplace_component = AppComponent::new( "marketplace".to_string(), "marketplace".to_string(), @@ -144,10 +143,10 @@ fn test_marketplace_app() { assert_eq!(rate, Rate::Contract(AndrAddr::from_string(rates.addr()))); - let rates: AllRatesResponse = marketplace.query_all_rates(&mut router).unwrap(); + let all_rates: AllRatesResponse = marketplace.query_all_rates(&mut router); assert_eq!( - rates, + all_rates, AllRatesResponse { all_rates: vec![( "Buy".to_string(), @@ -187,7 +186,7 @@ fn test_marketplace_app() { Some(vec![coin(200, "uandr")]), ); - let packet = AMPPkt::new(buyer.clone(), andr.kernel.addr().to_string(), vec![amp_msg]); + let packet = AMPPkt::new(buyer.clone(), buyer.clone(), vec![amp_msg]); let receive_packet_msg = mock_receive_packet(packet); let block_info = router.block_info(); @@ -202,7 +201,7 @@ fn test_marketplace_app() { .execute_actor_permission( &mut router, owner.clone(), - buyer.clone(), + vec![AndrAddr::from_string(buyer.clone())], LocalPermission::limited(None, 1), ) .unwrap_err() @@ -221,7 +220,7 @@ fn test_marketplace_app() { .execute_actor_permission( &mut router, owner.clone(), - buyer.clone(), + vec![AndrAddr::from_string(buyer.clone())], LocalPermission::blacklisted(None), ) .unwrap(); @@ -231,7 +230,7 @@ fn test_marketplace_app() { .execute_set_permissions( &mut router, owner.clone(), - AndrAddr::from_string(buyer.clone()), + vec![AndrAddr::from_string(buyer.clone())], "Buy", Permission::Contract(AndrAddr::from_string(address_list.addr())), ) @@ -251,6 +250,15 @@ fn test_marketplace_app() { .unwrap(); assert_eq!(err, ContractError::Unauthorized {}); + address_list + .execute_actor_permission( + &mut router, + owner.clone(), + vec![AndrAddr::from_string(buyer.clone())], + LocalPermission::whitelisted(None), + ) + .unwrap(); + router .execute_contract( buyer.clone(), @@ -326,7 +334,7 @@ fn test_marketplace_app_recipient() { ); let marketplace_init_msg = - mock_marketplace_instantiate_msg(andr.kernel.addr().to_string(), None, None); + mock_marketplace_instantiate_msg(andr.kernel.addr().to_string(), None, None, None); let marketplace_component = AppComponent::new( "marketplace".to_string(), @@ -392,7 +400,7 @@ fn test_marketplace_app_recipient() { Some(vec![coin(200, "uandr")]), ); - let packet = AMPPkt::new(buyer.clone(), andr.kernel.addr().to_string(), vec![amp_msg]); + let packet = AMPPkt::new(buyer.clone(), buyer.clone(), vec![amp_msg]); let receive_packet_msg = mock_receive_packet(packet); let block_info = router.block_info(); @@ -418,6 +426,7 @@ fn test_marketplace_app_recipient() { let balance = router.wrap().query_balance(receiver, "uandr").unwrap(); assert_eq!(balance.amount, Uint128::from(100u128)); } + #[test] fn test_marketplace_app_cw20_restricted() { let mut router = mock_app(None); @@ -502,26 +511,6 @@ fn test_marketplace_app_cw20_restricted() { to_json_binary(&second_cw20_init_msg).unwrap(), ); - let local_rate = LocalRate { - rate_type: LocalRateType::Additive, - recipients: vec![Recipient::from_string(rates_receiver.to_string())], - // This is the cw20's address - value: LocalRateValue::Flat(coin( - 100, - "andr1f5m2mm5gms637c06t0er56g454j5hznlefzavxm5cr7ex8xc5r0s4sfhu4", - )), - description: None, - }; - - let rates_init_msg = mock_rates_instantiate_msg( - "Buy".to_string(), - local_rate, - andr.kernel.addr().to_string(), - None, - ); - let rates_component = - AppComponent::new("rates", "rates", to_json_binary(&rates_init_msg).unwrap()); - let address_list_init_msg = mock_address_list_instantiate_msg(andr.kernel.addr().to_string(), None, None); @@ -534,7 +523,10 @@ fn test_marketplace_app_cw20_restricted() { let marketplace_init_msg = mock_marketplace_instantiate_msg( andr.kernel.addr().to_string(), None, - Some(AndrAddr::from_string(format!("./{}", cw20_component.name))), + Some(vec![AndrAddr::from_string(format!( + "./{}", + cw20_component.name + ))]), None, ); let marketplace_component = AppComponent::new( @@ -548,7 +540,6 @@ fn test_marketplace_app_cw20_restricted() { cw721_component.clone(), cw20_component.clone(), second_cw20_component.clone(), - rates_component.clone(), address_list_component.clone(), marketplace_component.clone(), ]; @@ -572,9 +563,30 @@ fn test_marketplace_app_cw20_restricted() { app.query_ado_by_component_name(&router, marketplace_component.name); let address_list: MockAddressList = app.query_ado_by_component_name(&router, address_list_component.name); - let rates: MockRates = app.query_ado_by_component_name(&router, rates_component.name); let cw20: MockCW20 = app.query_ado_by_component_name(&router, cw20_component.name); + let local_rate = LocalRate { + rate_type: LocalRateType::Additive, + recipients: vec![Recipient::from_string(rates_receiver.to_string())], + // This is the cw20's address + value: LocalRateValue::Flat(coin(100, cw20.addr().to_string())), + description: None, + }; + + let rates_init_msg = mock_rates_instantiate_msg( + "Buy".to_string(), + local_rate, + andr.kernel.addr().to_string(), + None, + ); + let rates_component = + AppComponent::new("rates", "rates", to_json_binary(&rates_init_msg).unwrap()); + + app.execute_add_app_component(&mut router, owner.clone(), rates_component.clone()) + .unwrap(); + + let rates: MockRates = app.query_ado_by_component_name(&router, rates_component.name); + // Set contract rate linked to the above rates contract marketplace .execute_set_rate( @@ -596,34 +608,12 @@ fn test_marketplace_app_cw20_restricted() { .execute_actor_permission( &mut router, owner.clone(), - cw721.addr().clone(), - LocalPermission::whitelisted(None), - ) - .unwrap(); - - address_list - .execute_actor_permission( - &mut router, - owner.clone(), - cw20.addr().clone(), - LocalPermission::whitelisted(None), - ) - .unwrap(); - - address_list - .execute_actor_permission( - &mut router, - owner.clone(), - buyer.clone(), - LocalPermission::whitelisted(None), - ) - .unwrap(); - - address_list - .execute_actor_permission( - &mut router, - owner.clone(), - owner.clone(), + vec![ + AndrAddr::from_string(cw721.addr().clone()), + AndrAddr::from_string(cw20.addr().clone()), + AndrAddr::from_string(buyer.clone()), + AndrAddr::from_string(owner.clone()), + ], LocalPermission::whitelisted(None), ) .unwrap(); @@ -833,7 +823,7 @@ fn test_marketplace_app_cw20_unrestricted() { ); let marketplace_init_msg = - mock_marketplace_instantiate_msg(andr.kernel.addr().to_string(), None, None); + mock_marketplace_instantiate_msg(andr.kernel.addr().to_string(), None, None, None); let marketplace_component = AppComponent::new( "marketplace".to_string(), "marketplace".to_string(), @@ -899,43 +889,13 @@ fn test_marketplace_app_cw20_unrestricted() { .execute_actor_permission( &mut router, owner.clone(), - cw721.addr().clone(), - LocalPermission::whitelisted(None), - ) - .unwrap(); - - address_list - .execute_actor_permission( - &mut router, - owner.clone(), - cw20.addr().clone(), - LocalPermission::whitelisted(None), - ) - .unwrap(); - - address_list - .execute_actor_permission( - &mut router, - owner.clone(), - second_cw20.addr().clone(), - LocalPermission::whitelisted(None), - ) - .unwrap(); - - address_list - .execute_actor_permission( - &mut router, - owner.clone(), - buyer.clone(), - LocalPermission::whitelisted(None), - ) - .unwrap(); - - address_list - .execute_actor_permission( - &mut router, - owner.clone(), - owner.clone(), + vec![ + AndrAddr::from_string(cw721.addr().clone()), + AndrAddr::from_string(cw20.addr().clone()), + AndrAddr::from_string(second_cw20.addr().clone()), + AndrAddr::from_string(buyer.clone()), + AndrAddr::from_string(owner.clone()), + ], LocalPermission::whitelisted(None), ) .unwrap(); diff --git a/tests-integration/tests/mod.rs b/tests-integration/tests/mod.rs index c70ac4360..329bce17a 100644 --- a/tests-integration/tests/mod.rs +++ b/tests-integration/tests/mod.rs @@ -24,3 +24,9 @@ mod validator_staking; #[cfg(test)] mod cw20_app; + +#[cfg(test)] +mod set_amount_splitter; + +#[cfg(test)] +mod shunting; diff --git a/tests-integration/tests/primitive.rs b/tests-integration/tests/primitive.rs index a5facd70f..8b54bd465 100644 --- a/tests-integration/tests/primitive.rs +++ b/tests-integration/tests/primitive.rs @@ -1,5 +1,3 @@ -#![cfg(not(target_arch = "wasm32"))] - use andromeda_app::app::AppComponent; use andromeda_app_contract::mock::{mock_andromeda_app, MockAppContract}; use andromeda_data_storage::primitive::{GetTypeResponse, GetValueResponse, Primitive}; diff --git a/tests-integration/tests/set-amount-splitter.rs b/tests-integration/tests/set_amount_splitter.rs similarity index 100% rename from tests-integration/tests/set-amount-splitter.rs rename to tests-integration/tests/set_amount_splitter.rs diff --git a/tests-integration/tests/validator_staking.rs b/tests-integration/tests/validator_staking.rs index d623ce607..ffec2c661 100644 --- a/tests-integration/tests/validator_staking.rs +++ b/tests-integration/tests/validator_staking.rs @@ -1,5 +1,3 @@ -#![cfg(not(target_arch = "wasm32"))] - use andromeda_app::app::AppComponent; use andromeda_app_contract::mock::{mock_andromeda_app, MockAppContract};