From 9b7d23bc5f2d64d8de2efba0c0a3098fb521462d Mon Sep 17 00:00:00 2001 From: Kayanski Date: Mon, 18 Nov 2024 15:49:00 +0000 Subject: [PATCH] UPdated tests --- framework/contracts/account/src/migrate.rs | 2 +- .../packages/abstract-client/src/builder.rs | 1 + .../abstract-interface/src/account.rs | 2 ++ interchain/framework-clone-testing/Cargo.toml | 1 + .../framework-clone-testing/src/common.rs | 6 ++--- .../tests/upgrade-account.rs | 26 ++++++++++++++++--- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/framework/contracts/account/src/migrate.rs b/framework/contracts/account/src/migrate.rs index ea2326b39..77153db73 100644 --- a/framework/contracts/account/src/migrate.rs +++ b/framework/contracts/account/src/migrate.rs @@ -33,7 +33,7 @@ pub fn migrate(mut deps: DepsMut, env: Env, _msg: MigrateMsg) -> AccountResult { let current_contract_version = get_contract_version(deps.storage)?; // If we already have an abstract account, we just migrate like normal - if current_contract_version.contract != "abstract::account" { + if current_contract_version.contract == "abstract::account" { assert_contract_upgrade(deps.storage, ACCOUNT, version)?; set_contract_version(deps.storage, ACCOUNT, CONTRACT_VERSION)?; return Ok(AccountResponse::action("migrate")); diff --git a/framework/packages/abstract-client/src/builder.rs b/framework/packages/abstract-client/src/builder.rs index c42e9c484..5f32898cd 100644 --- a/framework/packages/abstract-client/src/builder.rs +++ b/framework/packages/abstract-client/src/builder.rs @@ -130,6 +130,7 @@ impl AbstractClientBuilder { /// Deploy abstract with current configuration pub fn build(&self) -> AbstractClientResult> { let abstr = Abstract::deploy_on(self.chain.clone(), ())?; + println!("quid"); self.update_ans(&abstr)?; AbstractClient::new(self.chain.clone()) diff --git a/framework/packages/abstract-interface/src/account.rs b/framework/packages/abstract-interface/src/account.rs index 36e72c628..b1ede08d7 100644 --- a/framework/packages/abstract-interface/src/account.rs +++ b/framework/packages/abstract-interface/src/account.rs @@ -589,9 +589,11 @@ impl AccountI { } sub_account_ids.extend(sub_account_ids_page); } + println!("Upgrades {:?}", sub_account_ids); for sub_account_id in sub_account_ids { let abstract_account = AccountI::load_from(abstract_deployment, AccountId::local(sub_account_id))?; + println!("{:?}", abstract_account.item_query(cw2::CONTRACT)?); if abstract_account.upgrade_account(abstract_deployment)? { one_migration_was_successful = true; } diff --git a/interchain/framework-clone-testing/Cargo.toml b/interchain/framework-clone-testing/Cargo.toml index a1a371714..012a78e60 100644 --- a/interchain/framework-clone-testing/Cargo.toml +++ b/interchain/framework-clone-testing/Cargo.toml @@ -16,6 +16,7 @@ cw-orch-clone-testing = { workspace = true } abstract-std = { workspace = true } abstract-app = { workspace = true, features = ["test-utils"] } abstract-testing = { workspace = true } +abstract-account = { workspace = true } abstract-client = { workspace = true } abstract-interface = { workspace = true, features = ["daemon"] } abstract-integration-tests = { path = "../../framework/packages/abstract-integration-tests" } diff --git a/interchain/framework-clone-testing/src/common.rs b/interchain/framework-clone-testing/src/common.rs index 65fe4e302..4f3b4dd71 100644 --- a/interchain/framework-clone-testing/src/common.rs +++ b/interchain/framework-clone-testing/src/common.rs @@ -6,7 +6,7 @@ use cw_orch_clone_testing::CloneTesting; /// Returns the abstract deployment and sender (=mainnet admin) pub fn setup(chain: ChainInfo) -> anyhow::Result<(Abstract, CloneTesting)> { let _ = env_logger::builder().is_test(true).try_init(); - // Run migration tests against Juno mainnet + // Run migration tests against mainnet // We set the state file to be able to clone test std::env::set_var("STATE_FILE", "../scripts/state.json"); let mut app = CloneTesting::new(chain)?; @@ -16,7 +16,7 @@ pub fn setup(chain: ChainInfo) -> anyhow::Result<(Abstract, CloneT .wasm_querier() .code(abstr_deployment.registry.code_id()?)? .creator; - app.set_sender(creator); + app.set_sender(creator.clone()); - Ok((abstr_deployment, app)) + Ok((abstr_deployment.call_as(&creator), app)) } diff --git a/interchain/framework-clone-testing/tests/upgrade-account.rs b/interchain/framework-clone-testing/tests/upgrade-account.rs index 3f2aa5cdb..b13bf6ba0 100644 --- a/interchain/framework-clone-testing/tests/upgrade-account.rs +++ b/interchain/framework-clone-testing/tests/upgrade-account.rs @@ -10,6 +10,8 @@ use cw_orch::{daemon::networks::PION_1, prelude::*}; use cw_orch_clone_testing::CloneTesting; use semver::Version; +pub const FORBIDDEN_VERSIONS: &[&str] = &["0.24.1-beta.1"]; + fn find_old_account() -> anyhow::Result<(CloneTesting, u32, Addr)> { let (abstr_deployment, chain) = common::setup(PION_1)?; @@ -24,7 +26,13 @@ fn find_old_account() -> anyhow::Result<(CloneTesting, u32, Addr)> { if let Ok(owner) = account.top_level_owner() { let ver = account.item_query(cw2::CONTRACT)?; let account_version = Version::parse(&ver.version)?; - + if FORBIDDEN_VERSIONS.iter().any(|&s| { + println!("current account version {}", ver.version); + s == ver.version + }) { + bail!("Can't migrate from this version"); + } + println!("Keeping {account_version}"); Ok((account_id, owner.address, account_version)) } else { bail!("No owner for this account") @@ -39,6 +47,7 @@ fn find_old_account() -> anyhow::Result<(CloneTesting, u32, Addr)> { #[test] fn upgrade_account_iteratively() -> anyhow::Result<()> { let (chain, account_id, owner) = find_old_account()?; + println!("Found, {account_id}"); let abstr_deployment = Abstract::load_from(chain.call_as(&owner).clone())?; let account = AccountI::load_from(&abstr_deployment, AccountId::local(account_id))?; @@ -79,13 +88,22 @@ fn upgrade_accounts_and_sub_accounts() -> anyhow::Result<()> { account.upgrade_account(&abstr_deployment)?; let info_account = account.item_query(cw2::CONTRACT)?; - assert_eq!(info_account.version, TEST_VERSION); + assert_eq!( + info_account.version, + abstract_account::contract::CONTRACT_VERSION + ); let info_sub_account = sub_account.item_query(cw2::CONTRACT)?; - assert_eq!(info_sub_account.version, TEST_VERSION); + assert_eq!( + info_sub_account.version, + abstract_account::contract::CONTRACT_VERSION + ); let info_sub_sub_account = sub_sub_account.item_query(cw2::CONTRACT)?; - assert_eq!(info_sub_sub_account.version, TEST_VERSION); + assert_eq!( + info_sub_sub_account.version, + abstract_account::contract::CONTRACT_VERSION + ); Ok(()) }