From 0041ccb000581276023176f02450ec5d6b7ac1ea Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 4 Oct 2024 10:15:55 +0300 Subject: [PATCH 01/14] update whitelist tests and fixes --- framework/contracts/account/src/config.rs | 161 ++++++++++++++++-- framework/contracts/account/src/contract.rs | 9 +- framework/contracts/account/src/error.rs | 2 +- framework/contracts/account/src/modules.rs | 67 +++----- .../account/src/modules/migration.rs | 11 +- framework/contracts/account/tests/upgrades.rs | 17 +- 6 files changed, 187 insertions(+), 80 deletions(-) diff --git a/framework/contracts/account/src/config.rs b/framework/contracts/account/src/config.rs index 12b4512e5..7b73a7042 100644 --- a/framework/contracts/account/src/config.rs +++ b/framework/contracts/account/src/config.rs @@ -1,7 +1,7 @@ use crate::{ contract::{AccountResponse, AccountResult}, error::AccountError, - modules::{_remove_whitelist_modules, _whitelist_modules, update_module_addresses}, + modules::{_update_whitelisted_modules, update_module_addresses}, }; use abstract_sdk::cw_helpers::AbstractAttributes; use abstract_std::{ @@ -49,7 +49,7 @@ pub fn update_suspension_status( /// Allows the owner to manually update the internal configuration of the account. /// This can be used to unblock the account and its modules in case of a bug/lock on the account. pub fn update_internal_config( - mut deps: DepsMut, + deps: DepsMut, info: MessageInfo, action: InternalConfigAction, ) -> AccountResult { @@ -71,19 +71,21 @@ pub fn update_internal_config( update_module_addresses(deps, add, to_remove) } - // TODO: Add tests for this action InternalConfigAction::UpdateWhitelist { to_add, to_remove } => { - let module_addresses_to_add: Result, _> = to_add + let module_addresses_to_add = to_add .into_iter() .map(|str_addr| deps.api.addr_validate(&str_addr)) - .collect(); - let module_addresses_to_remove: Result, _> = to_remove + .collect::, _>>()?; + let module_addresses_to_remove = to_remove .into_iter() .map(|str_addr| deps.api.addr_validate(&str_addr)) - .collect(); + .collect::, _>>()?; - _whitelist_modules(deps.branch(), module_addresses_to_add?)?; - _remove_whitelist_modules(deps, module_addresses_to_remove?)?; + _update_whitelisted_modules( + deps.storage, + module_addresses_to_add, + module_addresses_to_remove, + )?; Ok(AccountResponse::action("update_whitelist")) } @@ -521,9 +523,11 @@ mod tests { } mod update_internal_config { - use abstract_std::account::InternalConfigAction::UpdateModuleAddresses; + use abstract_std::account::InternalConfigAction; use ownership::GovOwnershipError; + use crate::modules::WHITELIST_SIZE_LIMIT; + use super::*; #[test] @@ -534,10 +538,11 @@ mod tests { mock_init(&mut deps)?; - let msg = ExecuteMsg::UpdateInternalConfig(UpdateModuleAddresses { - to_add: vec![], - to_remove: vec![], - }); + let msg = + ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateModuleAddresses { + to_add: vec![], + to_remove: vec![], + }); let bad_sender = deps.api.addr_make("not_account_owner"); let res = execute_as(deps.as_mut(), &bad_sender, msg.clone()); @@ -554,6 +559,134 @@ mod tests { Ok(()) } + + #[test] + fn whitelist_size_limit() -> anyhow::Result<()> { + let mut deps = mock_dependencies(); + let abstr = AbstractMockAddrs::new(deps.api); + let owner = abstr.owner; + + mock_init(&mut deps)?; + + // One too many + let mut to_add: Vec = (0..WHITELIST_SIZE_LIMIT + 1) + .map(|i| deps.api.addr_make(&format!("white_list_{i}")).to_string()) + .collect(); + let too_many_msg = + ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateWhitelist { + to_add: to_add.clone(), + to_remove: vec![], + }); + let too_many = execute_as(deps.as_mut(), &owner, too_many_msg).unwrap_err(); + assert_eq!(too_many, AccountError::ModuleLimitReached {}); + + // Exact amount + to_add.pop(); + let exactly_limit_msg = + ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateWhitelist { + to_add: to_add.clone(), + to_remove: vec![], + }); + let white_list_add = execute_as(deps.as_mut(), &owner, exactly_limit_msg); + assert!(white_list_add.is_ok()); + + // Can't add after hitting limit + let to_add = vec![deps.api.addr_make("over_limit").to_string()]; + let module_limit_reached = execute_as( + deps.as_mut(), + &owner, + ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateWhitelist { + to_add, + to_remove: vec![], + }), + ) + .unwrap_err(); + assert_eq!(module_limit_reached, AccountError::ModuleLimitReached {}); + + Ok(()) + } + + #[test] + fn whitelist_duplicates() -> anyhow::Result<()> { + let mut deps = mock_dependencies(); + let abstr = AbstractMockAddrs::new(deps.api); + let owner = abstr.owner; + + mock_init(&mut deps)?; + + // duplicate after add + let to_add: Vec = vec![deps.api.addr_make("module").to_string()]; + let msg = ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateWhitelist { + to_add: to_add.clone(), + to_remove: vec![], + }); + execute_as(deps.as_mut(), &owner, msg.clone()).unwrap(); + + let duplicate_err = execute_as(deps.as_mut(), &owner, msg).unwrap_err(); + assert_eq!( + duplicate_err, + AccountError::AlreadyWhitelisted(to_add[0].clone()) + ); + + // duplicate inside add + let to_add: Vec = vec![ + deps.api.addr_make("module2").to_string(), + deps.api.addr_make("module2").to_string(), + ]; + let msg = ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateWhitelist { + to_add: to_add.clone(), + to_remove: vec![], + }); + let duplicate_err = execute_as(deps.as_mut(), &owner, msg).unwrap_err(); + assert_eq!( + duplicate_err, + AccountError::AlreadyWhitelisted(to_add[0].clone()) + ); + + Ok(()) + } + + #[test] + fn whitelist_remove() -> anyhow::Result<()> { + let mut deps = mock_dependencies(); + let abstr = AbstractMockAddrs::new(deps.api); + let owner = abstr.owner; + + mock_init(&mut deps)?; + + // Add and remove same + let to_add: Vec = vec![deps.api.addr_make("module").to_string()]; + let msg = ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateWhitelist { + to_add: to_add.clone(), + to_remove: to_add.clone(), + }); + let no_changes = execute_as(deps.as_mut(), &owner, msg.clone()); + assert!(no_changes.is_ok()); + + // Remove not whitelisted + let to_remove: Vec = vec![deps.api.addr_make("module").to_string()]; + let msg = ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateWhitelist { + to_add: vec![], + to_remove, + }); + let not_whitelisted = execute_as(deps.as_mut(), &owner, msg.clone()).unwrap_err(); + assert_eq!(not_whitelisted, AccountError::NotWhitelisted {}); + + // Remove same twice + let to_add: Vec = vec![deps.api.addr_make("module").to_string()]; + let to_remove: Vec = vec![ + deps.api.addr_make("module").to_string(), + deps.api.addr_make("module").to_string(), + ]; + let msg = ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateWhitelist { + to_add: to_add.clone(), + to_remove: to_remove.clone(), + }); + let not_whitelisted = execute_as(deps.as_mut(), &owner, msg.clone()).unwrap_err(); + assert_eq!(not_whitelisted, AccountError::NotWhitelisted {}); + + Ok(()) + } } mod update_ownership { diff --git a/framework/contracts/account/src/contract.rs b/framework/contracts/account/src/contract.rs index 68a3efc41..4c200af0e 100644 --- a/framework/contracts/account/src/contract.rs +++ b/framework/contracts/account/src/contract.rs @@ -176,13 +176,8 @@ pub fn instantiate( }; // Set owner - let cw_gov_owner = ownership::initialize_owner( - deps.branch(), - // TODO: support no owner here (ownership handled in SUDO) - // Or do we want to add a `Sudo` governance type? - owner.clone(), - registry.address.clone(), - )?; + let cw_gov_owner = + ownership::initialize_owner(deps.branch(), owner.clone(), registry.address.clone())?; SUSPENSION_STATUS.save(deps.storage, &false)?; diff --git a/framework/contracts/account/src/error.rs b/framework/contracts/account/src/error.rs index 28ebbc489..66f075ea5 100644 --- a/framework/contracts/account/src/error.rs +++ b/framework/contracts/account/src/error.rs @@ -72,7 +72,7 @@ pub enum AccountError { DependencyNotMet(String, String), #[error("Max amount of modules registered")] - ModuleLimitReached, + ModuleLimitReached {}, #[error("Module with address {0} is already whitelisted")] AlreadyWhitelisted(String), diff --git a/framework/contracts/account/src/modules.rs b/framework/contracts/account/src/modules.rs index 18989b2ad..9ed422347 100644 --- a/framework/contracts/account/src/modules.rs +++ b/framework/contracts/account/src/modules.rs @@ -1,6 +1,6 @@ use abstract_std::{ account::{ - state::{ACCOUNT_ID, ACCOUNT_MODULES, DEPENDENTS, WHITELISTED_MODULES}, + state::{WhitelistedModules, ACCOUNT_ID, ACCOUNT_MODULES, DEPENDENTS, WHITELISTED_MODULES}, ModuleInstallConfig, }, adapter::{AdapterBaseMsg, BaseExecuteMsg, ExecuteMsg as AdapterExecMsg}, @@ -18,7 +18,7 @@ use abstract_std::{ }; use cosmwasm_std::{ ensure, wasm_execute, Addr, Attribute, Binary, CanonicalAddr, Coin, CosmosMsg, Deps, DepsMut, - MessageInfo, StdError, StdResult, Storage, SubMsg, + MessageInfo, StdResult, Storage, SubMsg, }; use cw2::ContractVersion; use cw_storage_plus::Item; @@ -35,7 +35,7 @@ pub(crate) const INSTALL_MODULES_CONTEXT: Item)>> = pub mod migration; -const LIST_SIZE_LIMIT: usize = 15; +pub const WHITELIST_SIZE_LIMIT: usize = 15; /// Attempts to install a new module through the Module Factory Contract pub fn install_modules( @@ -130,7 +130,7 @@ pub fn _install_modules( }; manager_modules.push(FactoryModuleInstallConfig::new(module.info, init_msg_salt)); } - _whitelist_modules(deps.branch(), add_to_whitelist)?; + _update_whitelisted_modules(deps.storage, add_to_whitelist, vec![])?; INSTALL_MODULES_CONTEXT.save(deps.storage, &install_context)?; @@ -181,7 +181,7 @@ pub fn update_module_addresses( } /// Uninstall the module with the ID [`module_id`] -pub fn uninstall_module(mut deps: DepsMut, info: MessageInfo, module_id: String) -> AccountResult { +pub fn uninstall_module(deps: DepsMut, info: MessageInfo, module_id: String) -> AccountResult { // only owner can uninstall modules ownership::assert_nested_owner(deps.storage, &deps.querier, &info.sender)?; @@ -213,7 +213,7 @@ pub fn uninstall_module(mut deps: DepsMut, info: MessageInfo, module_id: String) // Remove module from whitelist if it supposed to be removed if module.should_be_whitelisted() { let module_addr = ACCOUNT_MODULES.load(deps.storage, &module_id)?; - _remove_whitelist_modules(deps.branch(), vec![module_addr])?; + _update_whitelisted_modules(deps.storage, vec![], vec![module_addr])?; } ACCOUNT_MODULES.remove(deps.storage, &module_id); @@ -285,52 +285,41 @@ fn configure_adapter( Ok(wasm_execute(adapter_address, &adapter_msg, vec![])?.into()) } -/// Add a contract to the whitelist -pub(crate) fn _whitelist_modules(deps: DepsMut, module_addresses: Vec) -> AccountResult<()> { - let mut whitelisted_modules = WHITELISTED_MODULES.load(deps.storage)?; - +/// Update whitelist by adding or removing addresses +pub(crate) fn _update_whitelisted_modules( + storage: &mut dyn Storage, + to_add_module_addresses: Vec, + to_remove_module_addresses: Vec, +) -> AccountResult<()> { + let mut whitelisted_modules = WHITELISTED_MODULES.load(storage)?.0; + let new_len = (whitelisted_modules.len() + to_add_module_addresses.len()) + .checked_sub(to_remove_module_addresses.len()) + // If overflowed - tried to remove not whitelisted + .ok_or(AccountError::NotWhitelisted {})?; // This is a limit to prevent potentially running out of gas when doing lookups on the modules list - if whitelisted_modules.0.len() >= LIST_SIZE_LIMIT { + if new_len > WHITELIST_SIZE_LIMIT { return Err(AccountError::ModuleLimitReached {}); } - for module_addr in module_addresses.into_iter() { - if whitelisted_modules.0.contains(&module_addr) { + for module_addr in to_add_module_addresses { + if whitelisted_modules.contains(&module_addr) { return Err(AccountError::AlreadyWhitelisted(module_addr.into())); } // Add contract to whitelist. - whitelisted_modules.0.push(module_addr); + whitelisted_modules.push(module_addr); } - WHITELISTED_MODULES.save(deps.storage, &whitelisted_modules)?; - - Ok(()) -} - -/// Remove a contract from the whitelist -pub(crate) fn _remove_whitelist_modules( - deps: DepsMut, - addresses_to_remove: Vec, -) -> AccountResult<()> { - let mut len: i8 = addresses_to_remove.len() as i8; - - WHITELISTED_MODULES.update(deps.storage, |mut whitelisted_modules| { - whitelisted_modules.0.retain(|addr| { - // retain any addresses that are not in the list of addresses to remove - if addresses_to_remove.contains(addr) { - len -= 1; - false - } else { - true - } - }); - Ok::<_, StdError>(whitelisted_modules) - })?; + whitelisted_modules.retain(|addr| { + // retain any addresses that are not in the list of addresses to remove + !to_remove_module_addresses.contains(addr) + }); - if len != 0 { + // Error won't match if something didn't remove + if whitelisted_modules.len() != new_len { return Err(AccountError::NotWhitelisted {}); } + WHITELISTED_MODULES.save(storage, &WhitelistedModules(whitelisted_modules))?; Ok(()) } diff --git a/framework/contracts/account/src/modules/migration.rs b/framework/contracts/account/src/modules/migration.rs index fb4b8ba69..d641424be 100644 --- a/framework/contracts/account/src/modules/migration.rs +++ b/framework/contracts/account/src/modules/migration.rs @@ -24,8 +24,8 @@ use cw2::get_contract_version; use cw_storage_plus::Item; use super::{ - _remove_whitelist_modules, _whitelist_modules, configure_adapter, load_module_addr, - query_module, update_module_addresses, + _update_whitelisted_modules, configure_adapter, load_module_addr, query_module, + update_module_addresses, }; use crate::{ contract::{AccountResponse, AccountResult}, @@ -237,7 +237,7 @@ pub(crate) fn build_module_migrate_msg( /// Replaces the current adapter with a different version /// Also moves all the authorized address permissions to the new contract and removes them from the old pub fn replace_adapter( - mut deps: DepsMut, + deps: DepsMut, env: &Env, new_adapter_addr: Addr, old_adapter_addr: Addr, @@ -272,10 +272,7 @@ pub fn replace_adapter( to_remove: vec![], }, )?); - // Remove adapter permissions from proxy - _remove_whitelist_modules(deps.branch(), vec![old_adapter_addr])?; - // Add new adapter to proxy - _whitelist_modules(deps.branch(), vec![new_adapter_addr])?; + _update_whitelisted_modules(deps.storage, vec![new_adapter_addr], vec![old_adapter_addr])?; Ok(msgs) } diff --git a/framework/contracts/account/tests/upgrades.rs b/framework/contracts/account/tests/upgrades.rs index 8bfa63960..7d93f5df9 100644 --- a/framework/contracts/account/tests/upgrades.rs +++ b/framework/contracts/account/tests/upgrades.rs @@ -113,7 +113,7 @@ fn upgrade_app() -> AResult { // successfully install app 1 let app1 = install_module_version(&account, app_1::MOCK_APP_ID, V1)?; - account.expect_modules(vec![adapter1, adapter2, app1])?; + account.expect_modules(vec![adapter1.clone(), adapter2, app1])?; // attempt upgrade app 1 to version 2 let res = account.upgrade_module( @@ -205,7 +205,7 @@ fn upgrade_app() -> AResult { .to_string(), ); - // attempt to upgrade app 1 to identical version while updating other modules + // attempt to upgrade adapters to the same version(same address) let res = account.upgrade(vec![ ( ModuleInfo::from_id(app_1::MOCK_APP_ID, ModuleVersion::Version(V2.to_string()))?, @@ -230,16 +230,9 @@ fn upgrade_app() -> AResult { ), ]); - // fails because app v1 is depends on adapter 1 being version 2. - assert_that!(res.unwrap_err().root().to_string()).contains( - AccountError::VersionRequirementNotMet { - module_id: adapter_1::MOCK_ADAPTER_ID.into(), - version: V1.into(), - comp: "^2.0.0".into(), - post_migration: true, - } - .to_string(), - ); + // fails because adapter v1 already whitelisted + assert_that!(res.unwrap_err().root().to_string()) + .contains(AccountError::AlreadyWhitelisted(adapter1).to_string()); // successfully upgrade all the modules account.upgrade(vec![ From dd6ff6bc990744468a93f04b44fce4faf22f6d2e Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 4 Oct 2024 16:50:44 +0300 Subject: [PATCH 02/14] upgrade account test --- framework/contracts/account/src/modules.rs | 177 +----------------- .../account/src/modules/migration.rs | 4 +- framework/contracts/account/src/versioning.rs | 8 +- .../account/tests/install_modules.rs | 156 ++++++++++++++- framework/contracts/account/tests/upgrades.rs | 174 +++++++++++------ .../abstract-interface/src/account.rs | 12 +- .../abstract-interface/src/migrate.rs | 11 +- .../abstract-interface/src/native/registry.rs | 9 +- 8 files changed, 290 insertions(+), 261 deletions(-) diff --git a/framework/contracts/account/src/modules.rs b/framework/contracts/account/src/modules.rs index 9ed422347..b9da08e7e 100644 --- a/framework/contracts/account/src/modules.rs +++ b/framework/contracts/account/src/modules.rs @@ -85,10 +85,7 @@ pub fn _install_modules( let salt: Binary = generate_instantiate_salt(&account_id); for (ModuleResponse { module, .. }, init_msg) in modules.into_iter().zip(init_msgs) { // Check if module is already enabled. - if ACCOUNT_MODULES - .may_load(deps.storage, &module.info.id())? - .is_some() - { + if ACCOUNT_MODULES.has(deps.storage, &module.info.id()) { return Err(AccountError::ModuleAlreadyInstalled(module.info.id())); } installed_modules.push(module.info.id_with_version()); @@ -203,16 +200,16 @@ pub fn uninstall_module(deps: DepsMut, info: MessageInfo, module_id: String) -> crate::versioning::remove_as_dependent(deps.storage, &module_id, module_dependencies)?; // Remove for proxy if needed - let vc = RegistryContract::new(deps.api)?; + let registry = RegistryContract::new(deps.api)?; - let module = vc.query_module( + let module = registry.query_module( ModuleInfo::from_id(&module_data.module, module_data.version.into())?, &deps.querier, )?; // Remove module from whitelist if it supposed to be removed if module.should_be_whitelisted() { - let module_addr = ACCOUNT_MODULES.load(deps.storage, &module_id)?; + let module_addr = load_module_addr(deps.storage, &module_id)?; _update_whitelisted_modules(deps.storage, vec![], vec![module_addr])?; } @@ -224,10 +221,10 @@ pub fn uninstall_module(deps: DepsMut, info: MessageInfo, module_id: String) -> } /// Checked load of a module address -pub fn load_module_addr(storage: &dyn Storage, module_id: &String) -> AccountResult { +pub fn load_module_addr(storage: &dyn Storage, module_id: &str) -> AccountResult { ACCOUNT_MODULES .may_load(storage, module_id)? - .ok_or_else(|| AccountError::ModuleNotFound(module_id.clone())) + .ok_or_else(|| AccountError::ModuleNotFound(module_id.to_string())) } /// Query Version Control for the [`Module`] given the provided [`ContractVersion`] @@ -475,32 +472,6 @@ mod tests { } } - // TODO: move those tests to integrations tests, since we can't do query in unit tests - mod install_module { - use super::*; - - #[test] - fn only_account_owner() -> anyhow::Result<()> { - let mut deps = mock_dependencies(); - let not_owner = deps.api.addr_make("not_owner"); - mock_init(&mut deps)?; - - let msg = ExecuteMsg::InstallModules { - modules: vec![ModuleInstallConfig::new( - ModuleInfo::from_id_latest("test:module")?, - None, - )], - }; - - let res = execute_as(deps.as_mut(), ¬_owner, msg); - assert_that!(&res) - .is_err() - .is_equal_to(AccountError::Ownership(GovOwnershipError::NotOwner)); - - Ok(()) - } - } - mod uninstall_module { use std::collections::HashSet; @@ -629,140 +600,4 @@ mod tests { Ok(()) } } - - // TODO: move these tests to integration tests - - // mod add_module { - // use super::*; - - // use cw_controllers::AdminError; - - // #[test] - // fn only_admin_can_add_module() { - // let mut deps = mock_dependencies(); - // mock_init(&mut deps); - - // let test_module_addr = deps.api.addr_make(TEST_MODULE); - // let msg = ExecuteMsg::AddModules { - // modules: vec![test_module_addr.to_string()], - // }; - // let info = message_info(&deps.api.addr_make("not_admin"), &[]); - - // let res = execute(deps.as_mut(), mock_env(), info, msg); - // assert_that(&res) - // .is_err() - // .is_equal_to(AccountError::Admin(AdminError::NotAdmin {})) - // } - // #[test] - // fn fails_adding_previously_added_module() { - // let mut deps = mock_dependencies(); - // mock_init(&mut deps); - - // let test_module_addr = deps.api.addr_make(TEST_MODULE); - // let msg = ExecuteMsg::AddModules { - // modules: vec![test_module_addr.to_string()], - // }; - - // let res = execute_as_admin(&mut deps, msg.clone()); - // assert_that(&res).is_ok(); - - // let res = execute_as_admin(&mut deps, msg); - // assert_that(&res) - // .is_err() - // .is_equal_to(AccountError::AlreadyWhitelisted( - // test_module_addr.to_string(), - // )); - // } - - // #[test] - // fn fails_adding_module_when_list_is_full() { - // let mut deps = mock_dependencies(); - // mock_init(&mut deps); - - // let test_module_addr = deps.api.addr_make(TEST_MODULE); - // let mut msg = ExecuteMsg::AddModules { - // modules: vec![test_module_addr.to_string()], - // }; - - // // -1 because manager counts as module as well - // for i in 0..LIST_SIZE_LIMIT - 1 { - // let test_module = format!("module_{i}"); - // let test_module_addr = deps.api.addr_make(&test_module); - // msg = ExecuteMsg::AddModules { - // modules: vec![test_module_addr.to_string()], - // }; - // let res = execute_as_admin(&mut deps, msg.clone()); - // assert_that(&res).is_ok(); - // } - - // let res = execute_as_admin(&mut deps, msg); - // assert_that(&res) - // .is_err() - // .is_equal_to(AccountError::ModuleLimitReached {}); - // } - // } - - // mod remove_module { - // use abstract_std::account::state::State; - // use cw_controllers::AdminError; - - // use super::*; - - // #[test] - // fn only_admin() { - // let mut deps = mock_dependencies(); - // mock_init(&mut deps); - - // let msg = ExecuteMsg::RemoveModule { - // module: TEST_MODULE.to_string(), - // }; - // let info = message_info(&deps.api.addr_make("not_admin"), &[]); - - // let res = execute(deps.as_mut(), mock_env(), info, msg); - // assert_that(&res) - // .is_err() - // .is_equal_to(AccountError::Admin(AdminError::NotAdmin {})) - // } - - // #[test] - // fn remove_module() -> ProxyTestResult { - // let mut deps = mock_dependencies(); - // mock_init(&mut deps); - - // let test_module_addr = deps.api.addr_make(TEST_MODULE); - // STATE.save( - // &mut deps.storage, - // &State { - // modules: vec![test_module_addr.clone()], - // }, - // )?; - - // let msg = ExecuteMsg::RemoveModule { - // module: test_module_addr.to_string(), - // }; - // let res = execute_as_admin(&mut deps, msg); - // assert_that(&res).is_ok(); - - // let actual_modules = load_modules(&deps.storage); - // assert_that(&actual_modules).is_empty(); - - // Ok(()) - // } - - // #[test] - // fn fails_removing_non_existing_module() { - // let mut deps = mock_dependencies(); - // mock_init(&mut deps); - - // let test_module_addr = deps.api.addr_make(TEST_MODULE); - // let msg = ExecuteMsg::RemoveModule { - // module: test_module_addr.to_string(), - // }; - - // let res = execute_as_admin(&mut deps, msg); - // assert_that(&res) - // .is_err() - // .is_equal_to(AccountError::NotWhitelisted(test_module_addr.to_string())); - // } - // } } diff --git a/framework/contracts/account/src/modules/migration.rs b/framework/contracts/account/src/modules/migration.rs index d641424be..4a2cca06c 100644 --- a/framework/contracts/account/src/modules/migration.rs +++ b/framework/contracts/account/src/modules/migration.rs @@ -137,14 +137,14 @@ pub fn set_migrate_msgs_and_context( requested_module.module.info, code_id, )?, - ModuleReference::Account(code_id) | ModuleReference::Standalone(code_id) => { + ModuleReference::Standalone(code_id) => { vec![build_module_migrate_msg( old_module_addr, code_id, migrate_msg.unwrap(), )] } - + // Account migrated separately _ => return Err(AccountError::NotUpgradeable(module_info)), }; msgs.extend(migrate_msgs); diff --git a/framework/contracts/account/src/versioning.rs b/framework/contracts/account/src/versioning.rs index 88cd9f41f..fa0445e4f 100644 --- a/framework/contracts/account/src/versioning.rs +++ b/framework/contracts/account/src/versioning.rs @@ -8,7 +8,11 @@ use abstract_std::{ use cosmwasm_std::{Deps, DepsMut, StdError, Storage}; use semver::{Comparator, Version}; -use crate::{contract::AccountResult, error::AccountError, modules::MIGRATE_CONTEXT}; +use crate::{ + contract::AccountResult, + error::AccountError, + modules::{load_module_addr, MIGRATE_CONTEXT}, +}; /// Assert the dependencies that this app or adapter relies on are installed. pub fn assert_install_requirements(deps: Deps, module_id: &str) -> AccountResult> { @@ -143,7 +147,7 @@ pub fn assert_dependency_requirements( pub fn load_module_data(deps: Deps, module_id: &str) -> AccountResult { let querier = &deps.querier; - let module_addr = ACCOUNT_MODULES.load(deps.storage, module_id)?; + let module_addr = load_module_addr(deps.storage, module_id)?; let module_data = MODULE.query(querier, module_addr)?; Ok(module_data) } diff --git a/framework/contracts/account/tests/install_modules.rs b/framework/contracts/account/tests/install_modules.rs index 3e3fc0050..fd30127b1 100644 --- a/framework/contracts/account/tests/install_modules.rs +++ b/framework/contracts/account/tests/install_modules.rs @@ -1,12 +1,12 @@ use abstract_account::error::AccountError; use abstract_integration_tests::{create_default_account, mock_modules, AResult}; -use abstract_interface::{Abstract, RegistryExecFns}; +use abstract_interface::{Abstract, AccountQueryFns, RegistryExecFns}; use abstract_std::{ account::{ - ExecuteMsg as AccountMsg, ModuleAddressesResponse, ModuleInstallConfig, - QueryMsg as AccountQuery, + AccountModuleInfo, ExecuteMsg as AccountMsg, ModuleAddressesResponse, ModuleInfosResponse, + ModuleInstallConfig, QueryMsg as AccountQuery, }, - objects::module::ModuleInfo, + objects::{module::ModuleInfo, ownership::GovOwnershipError}, }; use abstract_testing::prelude::{TEST_ACCOUNT_ID, TEST_NAMESPACE}; use cw_orch::{prelude::*, take_storage_snapshot}; @@ -111,3 +111,151 @@ fn useful_error_module_not_found() -> AResult { )); Ok(()) } + +#[test] +fn only_admin_can_add_or_remove_module() -> AResult { + let chain = MockBech32::new("mock"); + let abstr = Abstract::deploy_on_mock(chain.clone())?; + let account = create_default_account(&chain.sender_addr(), &abstr)?; + + let not_admin = chain.addr_make("not_admin"); + let not_admin_error: AccountError = account + .call_as(¬_admin) + .execute( + &AccountMsg::InstallModules { + modules: vec![ModuleInstallConfig::new( + ModuleInfo::from_id(adapter_1::MOCK_ADAPTER_ID, V1.into()).unwrap(), + None, + )], + }, + &[], + ) + .unwrap_err() + .downcast() + .unwrap(); + + assert_eq!( + not_admin_error, + AccountError::Ownership(GovOwnershipError::NotOwner) + ); + + let not_admin_error: AccountError = account + .call_as(¬_admin) + .execute( + &AccountMsg::UninstallModule { + module_id: adapter_1::MOCK_ADAPTER_ID.to_string(), + }, + &[], + ) + .unwrap_err() + .downcast() + .unwrap(); + + assert_eq!( + not_admin_error, + AccountError::Ownership(GovOwnershipError::NotOwner) + ); + + Ok(()) +} + +#[test] +fn fails_adding_previously_added_module() -> AResult { + let chain = MockBech32::new("mock"); + let abstr = Abstract::deploy_on_mock(chain.clone())?; + let account = create_default_account(&chain.sender_addr(), &abstr)?; + + abstr + .registry + .claim_namespace(TEST_ACCOUNT_ID, TEST_NAMESPACE.to_string())?; + // Deploy and install + deploy_modules(&chain); + account.execute( + &AccountMsg::InstallModules { + modules: vec![ModuleInstallConfig::new( + ModuleInfo::from_id(adapter_1::MOCK_ADAPTER_ID, V1.into()).unwrap(), + None, + )], + }, + &[], + )?; + + let already_whitelisted: AccountError = account + .execute( + &AccountMsg::InstallModules { + modules: vec![ModuleInstallConfig::new( + ModuleInfo::from_id(adapter_1::MOCK_ADAPTER_ID, V1.into()).unwrap(), + None, + )], + }, + &[], + ) + .unwrap_err() + .downcast() + .unwrap(); + assert_eq!( + already_whitelisted, + AccountError::ModuleAlreadyInstalled(adapter_1::MOCK_ADAPTER_ID.to_string()) + ); + Ok(()) +} + +#[test] +fn remove_module() -> AResult { + let chain = MockBech32::new("mock"); + let abstr = Abstract::deploy_on_mock(chain.clone())?; + let account = create_default_account(&chain.sender_addr(), &abstr)?; + + abstr + .registry + .claim_namespace(TEST_ACCOUNT_ID, TEST_NAMESPACE.to_string())?; + // Deploy and install + deploy_modules(&chain); + account.execute( + &AccountMsg::InstallModules { + modules: vec![ModuleInstallConfig::new( + ModuleInfo::from_id(adapter_1::MOCK_ADAPTER_ID, V1.into()).unwrap(), + None, + )], + }, + &[], + )?; + + let module_infos = account.module_infos(None, None)?.module_infos; + assert_eq!(module_infos[0].id, adapter_1::MOCK_ADAPTER_ID); + + account.execute( + &AccountMsg::UninstallModule { + module_id: adapter_1::MOCK_ADAPTER_ID.to_string(), + }, + &[], + )?; + let module_infos = account.module_infos(None, None)?.module_infos; + assert!(module_infos.is_empty()); + + Ok(()) +} + +#[test] +fn fails_removing_non_existing_module() -> AResult { + let chain = MockBech32::new("mock"); + let abstr = Abstract::deploy_on_mock(chain.clone())?; + let account = create_default_account(&chain.sender_addr(), &abstr)?; + + let err: AccountError = account + .execute( + &AccountMsg::UninstallModule { + module_id: adapter_1::MOCK_ADAPTER_ID.to_string(), + }, + &[], + ) + .unwrap_err() + .downcast() + .unwrap(); + + assert_eq!( + err, + AccountError::ModuleNotFound(adapter_1::MOCK_ADAPTER_ID.to_string()) + ); + Ok(()) +} diff --git a/framework/contracts/account/tests/upgrades.rs b/framework/contracts/account/tests/upgrades.rs index 7d93f5df9..f20739295 100644 --- a/framework/contracts/account/tests/upgrades.rs +++ b/framework/contracts/account/tests/upgrades.rs @@ -273,67 +273,6 @@ fn update_adapter_with_authorized_addrs() -> AResult { ) } -/*#[test] -fn upgrade_manager_last() -> AResult { - let sender = Addr::unchecked(OWNER); - let chain = Mock::new(&sender); - let abstr = Abstract::deploy_on(chain.clone(), mock_bech32_sender(&chain))?; - let account = create_default_account(&sender,&abstr)?; - let AccountI { account, proxy: _ } = &account; - - abstr - .registry - .claim_namespace(TEST_ACCOUNT_ID, vec![TEST_NAMESPACE.to_string()])?; - deploy_modules(&chain); - - // install adapter 1 - let adapter1 = install_module_version(&account, &abstr, adapter_1::MOCK_ADAPTER_ID, V1)?; - - // install adapter 2 - let adapter2 = install_module_version(&account, &abstr, adapter_2::MOCK_ADAPTER_ID, V1)?; - - // successfully install app 1 - let app1 = install_module_version(&account, &abstr, app_1::MOCK_APP_ID, V1)?; - account.expect_modules(vec![adapter1, adapter2, app1])?; - - // Upgrade all modules, including the account module, but ensure the account is upgraded last - let res = account.upgrade(vec![ - ( - ModuleInfo::from_id_latest(app_1::MOCK_APP_ID)?, - Some(to_json_binary(&app::MigrateMsg { - base: app::BaseMigrateMsg {}, - module: MockMigrateMsg, - })?), - ), - ( - ModuleInfo::from_id_latest("abstract:account")?, - Some(to_json_binary(&account::MigrateMsg {})?), - ), - (ModuleInfo::from_id_latest(adapter_1::MOCK_ADAPTER_ID)?, None), - (ModuleInfo::from_id_latest(adapter_2::MOCK_ADAPTER_ID)?, None), - ])?; - - // get the events - let mut events: Vec = res.events; - events.pop(); - let migrate_event = events.pop().unwrap(); - - // the 2nd last event will be the account execution - assert_that!(migrate_event.attributes).has_length(3); - let mut attributes = migrate_event.attributes; - // check that the action was migrate - assert_that!(attributes.pop()) - .is_some() - .is_equal_to(Attribute::from(("action", "migrate"))); - - // and that it was the account - assert_that!(attributes.pop()) - .is_some() - .is_equal_to(Attribute::from(("contract", "abstract:account"))); - - Ok(()) -}*/ - #[test] fn no_duplicate_migrations() -> AResult { let chain = MockBech32::new("mock"); @@ -899,6 +838,119 @@ fn native_not_migratable() -> AResult { Ok(()) } +mod upgrade_account { + use cosmwasm_std::{Attribute, DepsMut, Env}; + + use super::*; + + fn new_version() -> String { + let mut new_account_version: semver::Version = abstract_account::contract::CONTRACT_VERSION + .parse() + .unwrap(); + new_account_version.patch += 1; + new_account_version.to_string() + } + + fn fake_migrate( + deps: DepsMut, + _env: Env, + _msg: abstract_std::account::MigrateMsg, + ) -> abstract_account::contract::AccountResult { + cw2::set_contract_version(deps.storage, abstract_std::ACCOUNT, new_version())?; + + Ok(abstract_account::contract::AccountResponse::action( + "migrate", + )) + } + + #[test] + fn upgrade_account_last() -> AResult { + let chain = MockBech32::new("mock"); + let abstr = Abstract::deploy_on_mock(chain.clone())?; + let account = create_default_account(&chain.sender_addr(), &abstr)?; + + let account_custom = chain.upload_custom( + "account-2", + Box::new( + ContractWrapper::new_with_empty( + abstract_account::contract::execute, + abstract_account::contract::instantiate, + abstract_account::contract::query, + ) + .with_migrate(fake_migrate), + ), + )?; + let account_custom_code_id = account_custom.uploaded_code_id().unwrap(); + abstr + .registry + .call_as(&Abstract::mock_admin(&chain)) + .propose_modules(vec![( + ModuleInfo::from_id(abstract_std::ACCOUNT, ModuleVersion::Version(new_version()))?, + ModuleReference::Account(account_custom_code_id), + )])?; + + abstr + .registry + .claim_namespace(TEST_ACCOUNT_ID, TEST_NAMESPACE.to_string())?; + deploy_modules(&chain); + + // install adapter 1 + let adapter1 = install_module_version(&account, adapter_1::MOCK_ADAPTER_ID, V1)?; + + // install adapter 2 + let adapter2 = install_module_version(&account, adapter_2::MOCK_ADAPTER_ID, V1)?; + + // successfully install app 1 + let app1 = install_module_version(&account, app_1::MOCK_APP_ID, V1)?; + account.expect_modules(vec![adapter1, adapter2, app1])?; + + // Upgrade all modules, including the account module, but ensure the account is upgraded last + let res = account.upgrade(vec![ + ( + ModuleInfo::from_id_latest(app_1::MOCK_APP_ID)?, + Some(to_json_binary(&app::MigrateMsg { + base: app::BaseMigrateMsg {}, + module: MockMigrateMsg, + })?), + ), + ( + ModuleInfo::from_id_latest("abstract:account")?, + Some(to_json_binary(&abstract_std::account::MigrateMsg {})?), + ), + ( + ModuleInfo::from_id_latest(adapter_1::MOCK_ADAPTER_ID)?, + None, + ), + ( + ModuleInfo::from_id_latest(adapter_2::MOCK_ADAPTER_ID)?, + None, + ), + ])?; + + // get the events + let mut events: Vec = res.events; + events.pop(); + let migrate_event = events.pop().unwrap(); + + // the 2nd last event will be the account execution + assert_eq!(migrate_event.attributes.len(), 3); + let mut attributes = migrate_event.attributes; + // check that the action was migrate + assert_eq!( + attributes.pop(), + Some(Attribute::from(("action", "migrate"))) + ); + + // and that it was the account + assert_eq!( + attributes.pop(), + Some(Attribute::from(("contract", "abstract:account"))) + ); + + Ok(()) + } +} + // TODO: // - adapter-adapter dependencies // - app-adapter dependencies diff --git a/framework/packages/abstract-interface/src/account.rs b/framework/packages/abstract-interface/src/account.rs index 2fe902089..fc5f70c40 100644 --- a/framework/packages/abstract-interface/src/account.rs +++ b/framework/packages/abstract-interface/src/account.rs @@ -544,17 +544,11 @@ impl AccountI { &self, registry: &Registry, ) -> Result { - let mut modules_to_register = Vec::with_capacity(2); - - if self.upload_if_needed()?.is_some() { - modules_to_register.push(( + let migrated = if self.upload_if_needed()?.is_some() { + registry.register_account( self.as_instance(), ::account::contract::CONTRACT_VERSION.to_string(), - )); - }; - - let migrated = if !modules_to_register.is_empty() { - registry.register_account_mods(modules_to_register)?; + ); true } else { false diff --git a/framework/packages/abstract-interface/src/migrate.rs b/framework/packages/abstract-interface/src/migrate.rs index 45c2e21bc..a28635978 100644 --- a/framework/packages/abstract-interface/src/migrate.rs +++ b/framework/packages/abstract-interface/src/migrate.rs @@ -81,9 +81,7 @@ impl Abstract { )); } - let mut accounts_to_register = Vec::with_capacity(2); - - // We need to check the version in version control for the account contracts + // We need to check the version in version control for the account contract let versions = self .registry .modules(vec![ @@ -95,14 +93,11 @@ impl Abstract { if ::account::contract::CONTRACT_VERSION != versions[0].module.info.version.to_string() && self.account.upload_if_needed()?.is_some() { - accounts_to_register.push(( + self.registry.register_account( self.account.as_instance(), ::account::contract::CONTRACT_VERSION.to_string(), - )); - } + )?; - if !accounts_to_register.is_empty() { - self.registry.register_account_mods(accounts_to_register)?; has_migrated = true } diff --git a/framework/packages/abstract-interface/src/native/registry.rs b/framework/packages/abstract-interface/src/native/registry.rs index d20154835..c433e84af 100644 --- a/framework/packages/abstract-interface/src/native/registry.rs +++ b/framework/packages/abstract-interface/src/native/registry.rs @@ -211,12 +211,13 @@ impl Registry { Ok(()) } - /// Register account modules - pub fn register_account_mods( + /// Register account module + pub fn register_account( &self, - apps: Vec<(&Contract, VersionString)>, + account: &Contract, + version: VersionString, ) -> Result<(), crate::AbstractInterfaceError> { - let to_register = self.contracts_into_module_entries(apps, |c| { + let to_register = self.contracts_into_module_entries(vec![(account, version)], |c| { ModuleReference::Account(c.code_id().unwrap()) })?; self.propose_modules(to_register)?; From 3fce4e0150d85ebe7c68952fbc1ad812d9853c98 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 4 Oct 2024 17:11:42 +0300 Subject: [PATCH 03/14] ans host full filter test --- .../contracts/native/ans-host/src/queries.rs | 102 ++++++++++-------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/framework/contracts/native/ans-host/src/queries.rs b/framework/contracts/native/ans-host/src/queries.rs index 1b9f43eab..0af8987c6 100644 --- a/framework/contracts/native/ans-host/src/queries.rs +++ b/framework/contracts/native/ans-host/src/queries.rs @@ -178,50 +178,50 @@ pub fn list_pool_entries( None => (None, None), }; - let full_key_provided = asset_pair_filter.is_some() && dex_filter.is_some(); - - let entry_list: Vec = if full_key_provided { - // We have the full key, so load the entry - let (asset_x, asset_y) = asset_pair_filter.unwrap(); - let key = DexAssetPairing::new(asset_x, asset_y, &dex_filter.unwrap()); - let entry = load_asset_pairing_entry(deps.storage, key)?; - // Add the result to a vec - vec![entry] - } else if let Some((asset_x, asset_y)) = asset_pair_filter { - let start_bound = start_after.map(|pairing| Bound::exclusive(pairing.dex())); - - // We can use the prefix to load all the entries for the asset pair - let res: Result)>, _> = ASSET_PAIRINGS - .prefix((&asset_x, &asset_y)) - .range(deps.storage, start_bound, None, Order::Ascending) - .take(limit) - .collect(); - - // Re add the key prefix, since only the dex is returned as a key - let matched: Vec = res? - .into_iter() - .map(|(dex, ids)| { - ( - DexAssetPairing::new(asset_x.clone(), asset_y.clone(), &dex), - ids, - ) - }) - .collect(); - - matched - } else { - let start_bound: Option> = - start_after.as_ref().map(Bound::exclusive); - - // We have no filter, so load all the entries - let res: Result, _> = ASSET_PAIRINGS - .range(deps.storage, start_bound, None, Order::Ascending) - .filter(|e| { - let pairing = &e.as_ref().unwrap().0; - dex_filter.as_ref().map_or(true, |f| f == pairing.dex()) - }) - .collect(); - res? + let entry_list = match (asset_pair_filter, dex_filter) { + (Some((asset_x, asset_y)), Some(dex_filter)) => { + // We have the full key, so load the entry + let key = DexAssetPairing::new(asset_x, asset_y, &dex_filter); + let entry = load_asset_pairing_entry(deps.storage, key)?; + vec![entry] + } + (Some((asset_x, asset_y)), None) => { + let start_bound = start_after.map(|pairing| Bound::exclusive(pairing.dex())); + + // We can use the prefix to load all the entries for the asset pair + let res: Result)>, _> = ASSET_PAIRINGS + .prefix((&asset_x, &asset_y)) + .range(deps.storage, start_bound, None, Order::Ascending) + .take(limit) + .collect(); + + // Re add the key prefix, since only the dex is returned as a key + let matched: Vec = res? + .into_iter() + .map(|(dex, ids)| { + ( + DexAssetPairing::new(asset_x.clone(), asset_y.clone(), &dex), + ids, + ) + }) + .collect(); + + matched + } + (None, dex_filter) => { + let start_bound: Option> = + start_after.as_ref().map(Bound::exclusive); + + // We have no filter, so load all the entries + ASSET_PAIRINGS + .range(deps.storage, start_bound, None, Order::Ascending) + .filter(|e| { + dex_filter + .as_ref() + .map_or(true, |f| f == e.as_ref().unwrap().0.dex()) + }) + .collect::>()? + } }; to_json_binary(&PoolAddressListResponse { pools: entry_list }) @@ -1001,6 +1001,19 @@ mod test { )?; let res_bar: PoolsResponse = from_json(query_helper(deps.as_ref(), msg_bar)?)?; + // Exact filter + let msg_full_filter_bar = create_pool_list_msg( + Some(create_asset_pairing_filter( + "btc", + "eth", + Some("bar".to_string()), + )?), + None, + None, + )?; + let res_full_filter_bar: PoolsResponse = + from_json(query_helper(deps.as_ref(), msg_full_filter_bar)?)?; + let msg_foo = create_pool_list_msg( Some(create_asset_pairing_filter("juno", "atom", None)?), None, @@ -1054,6 +1067,7 @@ mod test { // assert assert_eq!(&res_bar, &expected_bar); + assert_eq!(&res_full_filter_bar, &expected_bar); assert_eq!(&res_foo, &expected_foo); assert!(res_foo.pools.len() == 1usize); assert_eq!(&res_foo_using_start_after, &expected_foo); From a6ea38fd56c69c42fa306bf81c4864d7716d9ae6 Mon Sep 17 00:00:00 2001 From: Buckram Date: Mon, 7 Oct 2024 14:08:34 +0300 Subject: [PATCH 04/14] ans-host coverage --- .../contracts/native/ans-host/src/contract.rs | 8 +- .../contracts/native/ans-host/src/queries.rs | 181 ++++++++++--- .../native/module-factory/src/lib.rs | 1 - .../native/module-factory/src/response.proto | 9 - .../native/module-factory/src/response.rs | 254 ------------------ .../src/cw_helpers/cw_storage_plus.rs | 81 ------ .../abstract-sdk/src/cw_helpers/mod.rs | 3 +- .../abstract-std/src/native/ans_host.rs | 12 +- scripts/framework-coverage.sh | 5 +- 9 files changed, 157 insertions(+), 397 deletions(-) delete mode 100644 framework/contracts/native/module-factory/src/response.proto delete mode 100644 framework/contracts/native/module-factory/src/response.rs delete mode 100644 framework/packages/abstract-sdk/src/cw_helpers/cw_storage_plus.rs diff --git a/framework/contracts/native/ans-host/src/contract.rs b/framework/contracts/native/ans-host/src/contract.rs index 5ea12b1b8..29e8fd4d9 100644 --- a/framework/contracts/native/ans-host/src/contract.rs +++ b/framework/contracts/native/ans-host/src/contract.rs @@ -68,17 +68,13 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { limit, filter: _filter, // TODO: Implement filtering } => queries::query_asset_info_list(deps, start_after, limit), - QueryMsg::Contracts { entries } => { - queries::query_contract(deps, env, entries.iter().collect()) - } + QueryMsg::Contracts { entries } => queries::query_contract(deps, env, entries), QueryMsg::ContractList { start_after, limit, filter: _filter, // TODO: Implement filtering } => queries::query_contract_list(deps, start_after, limit), - QueryMsg::Channels { entries: names } => { - queries::query_channels(deps, env, names.iter().collect()) - } + QueryMsg::Channels { entries: names } => queries::query_channels(deps, env, names), QueryMsg::ChannelList { start_after, limit, diff --git a/framework/contracts/native/ans-host/src/queries.rs b/framework/contracts/native/ans-host/src/queries.rs index 0af8987c6..1ae855f9a 100644 --- a/framework/contracts/native/ans-host/src/queries.rs +++ b/framework/contracts/native/ans-host/src/queries.rs @@ -1,4 +1,3 @@ -use abstract_sdk::cw_helpers::load_many; use abstract_std::{ ans_host::{ state::{ @@ -37,13 +36,16 @@ pub fn query_config(deps: Deps) -> StdResult { } pub fn query_assets(deps: Deps, _env: Env, keys: Vec) -> StdResult { - let keys: Vec = keys.into_iter().map(|name| name.as_str().into()).collect(); - - let assets = load_many(ASSET_ADDRESSES, deps.storage, keys.iter().collect())?; + let assets = keys + .into_iter() + .map(|name| { + let key = AssetEntry::new(&name); + let value = ASSET_ADDRESSES.load(deps.storage, &key)?; + Ok((key, value)) + }) + .collect::>()?; - to_json_binary(&AssetsResponse { - assets: assets.into_iter().map(|(k, v)| (k.to_owned(), v)).collect(), - }) + to_json_binary(&AssetsResponse { assets }) } pub fn query_asset_list( @@ -68,19 +70,18 @@ pub fn query_asset_infos( _env: Env, keys: Vec, ) -> StdResult { - let keys = keys + let infos = keys .into_iter() .map(|info| { - info.check(deps.api, None) - .map_err(|e| StdError::generic_err(e.to_string())) + let key = info + .check(deps.api, None) + .map_err(|err| StdError::generic_err(err.to_string()))?; + let value = REV_ASSET_ADDRESSES.load(deps.storage, &key)?; + Ok((key, value)) }) - .collect::>>()?; - - let infos = load_many(REV_ASSET_ADDRESSES, deps.storage, keys.iter().collect())?; + .collect::>()?; - to_json_binary(&AssetInfosResponse { - infos: infos.into_iter().map(|(k, v)| (k.to_owned(), v)).collect(), - }) + to_json_binary(&AssetInfosResponse { infos }) } pub fn query_asset_info_list( @@ -105,26 +106,28 @@ pub fn query_asset_info_list( to_json_binary(&AssetInfoListResponse { infos: res? }) } -pub fn query_contract(deps: Deps, _env: Env, keys: Vec<&ContractEntry>) -> StdResult { - let contracts = load_many(CONTRACT_ADDRESSES, deps.storage, keys)?; +pub fn query_contract(deps: Deps, _env: Env, keys: Vec) -> StdResult { + let contracts = keys + .into_iter() + .map(|key| { + let value = CONTRACT_ADDRESSES.load(deps.storage, &key)?; + Ok((key, value)) + }) + .collect::>()?; - to_json_binary(&ContractsResponse { - contracts: contracts - .into_iter() - .map(|(x, a)| (x.to_owned(), a)) - .collect(), - }) + to_json_binary(&ContractsResponse { contracts }) } -pub fn query_channels(deps: Deps, _env: Env, keys: Vec<&ChannelEntry>) -> StdResult { - let channels = load_many(CHANNELS, deps.storage, keys)?; +pub fn query_channels(deps: Deps, _env: Env, keys: Vec) -> StdResult { + let channels = keys + .into_iter() + .map(|key| { + let value = CHANNELS.load(deps.storage, &key)?; + Ok((key, value)) + }) + .collect::>()?; - to_json_binary(&ChannelsResponse { - channels: channels - .into_iter() - .map(|(k, v)| (k.to_owned(), v)) - .collect(), - }) + to_json_binary(&ChannelsResponse { channels }) } pub fn query_contract_list( @@ -1190,4 +1193,118 @@ mod test { assert_that!(res_foo).is_equal_to(expected_foo); Ok(()) } + + #[test] + fn test_query_asset_infos() -> AnsHostTestResult { + let mut deps = mock_dependencies(); + mock_init(&mut deps).unwrap(); + let native_1 = AssetInfo::native("foo"); + let native_2 = AssetInfo::native("bar"); + let cw20_1 = AssetInfo::cw20(deps.api.addr_make("foo")); + let cw20_2 = AssetInfo::cw20(deps.api.addr_make("bar")); + + // create asset entries + REV_ASSET_ADDRESSES.save(&mut deps.storage, &native_1, &AssetEntry::new("foo_n"))?; + REV_ASSET_ADDRESSES.save(&mut deps.storage, &native_2, &AssetEntry::new("bar_n"))?; + REV_ASSET_ADDRESSES.save(&mut deps.storage, &cw20_1, &AssetEntry::new("foo_ft"))?; + REV_ASSET_ADDRESSES.save(&mut deps.storage, &cw20_2, &AssetEntry::new("bar_ft"))?; + + let msg = QueryMsg::AssetInfos { + infos: vec![ + native_1.clone().into(), + native_2.clone().into(), + cw20_1.clone().into(), + cw20_2.clone().into(), + ], + }; + let res: AssetInfosResponse = from_json(query_helper(deps.as_ref(), msg)?)?; + let expected_bar = AssetInfosResponse { + infos: vec![ + (native_1, AssetEntry::new("foo_n")), + (native_2, AssetEntry::new("bar_n")), + (cw20_1, AssetEntry::new("foo_ft")), + (cw20_2, AssetEntry::new("bar_ft")), + ], + }; + assert_eq!(res, expected_bar); + + // Query invalid asset + let res = query_helper( + deps.as_ref(), + QueryMsg::AssetInfos { + infos: vec![AssetInfoUnchecked::cw20("invalid_addr".to_string())], + }, + ); + assert!(res.is_err()); + // Query not saved asset + let res = query_helper( + deps.as_ref(), + QueryMsg::AssetInfos { + infos: vec![AssetInfoUnchecked::native("not_saved".to_string())], + }, + ); + assert!(res.is_err()); + Ok(()) + } + + #[test] + fn test_query_asset_infos_list() -> AnsHostTestResult { + let mut deps = mock_dependencies(); + mock_init(&mut deps).unwrap(); + let native_1 = AssetInfo::native("foo"); + let native_2 = AssetInfo::native("bar"); + let cw20_1 = AssetInfo::cw20(deps.api.addr_make("foo")); + let cw20_2 = AssetInfo::cw20(deps.api.addr_make("bar")); + + // create asset entries + REV_ASSET_ADDRESSES.save(&mut deps.storage, &native_1, &AssetEntry::new("foo_n"))?; + REV_ASSET_ADDRESSES.save(&mut deps.storage, &native_2, &AssetEntry::new("bar_n"))?; + REV_ASSET_ADDRESSES.save(&mut deps.storage, &cw20_1, &AssetEntry::new("foo_ft"))?; + REV_ASSET_ADDRESSES.save(&mut deps.storage, &cw20_2, &AssetEntry::new("bar_ft"))?; + + let msg = QueryMsg::AssetInfoList { + filter: None, + start_after: None, + limit: None, + }; + let res: AssetInfoListResponse = from_json(query_helper(deps.as_ref(), msg)?)?; + let expected_infos = AssetInfoListResponse { + infos: vec![ + (cw20_1.clone(), AssetEntry::new("foo_ft")), + (cw20_2.clone(), AssetEntry::new("bar_ft")), + (native_2.clone(), AssetEntry::new("bar_n")), + (native_1.clone(), AssetEntry::new("foo_n")), + ], + }; + assert_eq!(res, expected_infos); + + // Start after + let msg = QueryMsg::AssetInfoList { + filter: None, + start_after: Some(cw20_2.clone().into()), + limit: None, + }; + let res: AssetInfoListResponse = from_json(query_helper(deps.as_ref(), msg)?)?; + let expected_infos = AssetInfoListResponse { + infos: vec![ + (native_2, AssetEntry::new("bar_n")), + (native_1, AssetEntry::new("foo_n")), + ], + }; + assert_eq!(res, expected_infos); + + // Limit + let msg = QueryMsg::AssetInfoList { + filter: None, + start_after: None, + limit: Some(1), + }; + let res: AssetInfoListResponse = from_json(query_helper(deps.as_ref(), msg)?)?; + let expected_infos = AssetInfoListResponse { + infos: vec![(cw20_1.clone(), AssetEntry::new("foo_ft"))], + }; + assert_eq!(res, expected_infos); + + Ok(()) + } } diff --git a/framework/contracts/native/module-factory/src/lib.rs b/framework/contracts/native/module-factory/src/lib.rs index 3bdf9722a..ac865fc96 100644 --- a/framework/contracts/native/module-factory/src/lib.rs +++ b/framework/contracts/native/module-factory/src/lib.rs @@ -1,7 +1,6 @@ mod commands; pub mod contract; pub mod error; -mod response; pub(crate) use abstract_sdk::std::module_factory::state; diff --git a/framework/contracts/native/module-factory/src/response.proto b/framework/contracts/native/module-factory/src/response.proto deleted file mode 100644 index 0d5a3fa90..000000000 --- a/framework/contracts/native/module-factory/src/response.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -// MsgInstantiateContractResponse defines the Msg/InstantiateContract response type. -message MsgInstantiateContractResponse { - // ContractAddress is the bech32 address of the new contract instance. - string contract_address = 1; - // Data contains base64-encoded bytes to returned from the contract - bytes data = 2; - } \ No newline at end of file diff --git a/framework/contracts/native/module-factory/src/response.rs b/framework/contracts/native/module-factory/src/response.rs deleted file mode 100644 index a77050c6e..000000000 --- a/framework/contracts/native/module-factory/src/response.rs +++ /dev/null @@ -1,254 +0,0 @@ -// This file is generated by rust-protobuf 2.23.0. Do not edit -// @generated - -// https://github.com/rust-lang/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![allow(unused_attributes)] -#![cfg_attr(rustfmt, rustfmt::skip)] - -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unused_imports)] -#![allow(unused_results)] -//! Generated file from `src/response.proto` - -/// Generated files are compatible only with the same version -/// of protobuf runtime. -// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_23_0; - -#[derive(PartialEq,Clone,Default)] -pub struct MsgInstantiateContractResponse { - // message fields - pub contract_address: ::std::string::String, - pub data: ::std::vec::Vec, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a MsgInstantiateContractResponse { - fn default() -> &'a MsgInstantiateContractResponse { - ::default_instance() - } -} - -impl MsgInstantiateContractResponse { - pub fn new() -> MsgInstantiateContractResponse { - ::std::default::Default::default() - } - - // string contract_address = 1; - - - pub fn get_contract_address(&self) -> &str { - &self.contract_address - } - pub fn clear_contract_address(&mut self) { - self.contract_address.clear(); - } - - // Param is passed by value, moved - pub fn set_contract_address(&mut self, v: ::std::string::String) { - self.contract_address = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_contract_address(&mut self) -> &mut ::std::string::String { - &mut self.contract_address - } - - // Take field - pub fn take_contract_address(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.contract_address, ::std::string::String::new()) - } - - // bytes data = 2; - - - pub fn get_data(&self) -> &[u8] { - &self.data - } - pub fn clear_data(&mut self) { - self.data.clear(); - } - - // Param is passed by value, moved - pub fn set_data(&mut self, v: ::std::vec::Vec) { - self.data = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_data(&mut self) -> &mut ::std::vec::Vec { - &mut self.data - } - - // Take field - pub fn take_data(&mut self) -> ::std::vec::Vec { - ::std::mem::replace(&mut self.data, ::std::vec::Vec::new()) - } -} - -impl ::protobuf::Message for MsgInstantiateContractResponse { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.contract_address)?; - }, - 2 => { - ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.data)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.contract_address.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.contract_address); - } - if !self.data.is_empty() { - my_size += ::protobuf::rt::bytes_size(2, &self.data); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if !self.contract_address.is_empty() { - os.write_string(1, &self.contract_address)?; - } - if !self.data.is_empty() { - os.write_bytes(2, &self.data)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &dyn (::std::any::Any) { - self as &dyn (::std::any::Any) - } - fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { - self as &mut dyn (::std::any::Any) - } - fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> MsgInstantiateContractResponse { - MsgInstantiateContractResponse::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "contract_address", - |m: &MsgInstantiateContractResponse| { &m.contract_address }, - |m: &mut MsgInstantiateContractResponse| { &mut m.contract_address }, - )); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( - "data", - |m: &MsgInstantiateContractResponse| { &m.data }, - |m: &mut MsgInstantiateContractResponse| { &mut m.data }, - )); - ::protobuf::reflect::MessageDescriptor::new_pb_name::( - "MsgInstantiateContractResponse", - fields, - file_descriptor_proto() - ) - }) - } - - fn default_instance() -> &'static MsgInstantiateContractResponse { - static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; - instance.get(MsgInstantiateContractResponse::new) - } -} - -impl ::protobuf::Clear for MsgInstantiateContractResponse { - fn clear(&mut self) { - self.contract_address.clear(); - self.data.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for MsgInstantiateContractResponse { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for MsgInstantiateContractResponse { - fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { - ::protobuf::reflect::ReflectValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x12src/response.proto\"_\n\x1eMsgInstantiateContractResponse\x12)\n\ - \x10contract_address\x18\x01\x20\x01(\tR\x0fcontractAddress\x12\x12\n\ - \x04data\x18\x02\x20\x01(\x0cR\x04dataJ\xf8\x02\n\x06\x12\x04\0\0\x08\ - \x03\n\x08\n\x01\x0c\x12\x03\0\0\x12\n_\n\x02\x04\0\x12\x04\x03\0\x08\ - \x03\x1aS\x20MsgInstantiateContractResponse\x20defines\x20the\x20Msg/Ins\ - tantiateContract\x20response\x20type.\n\n\n\n\x03\x04\0\x01\x12\x03\x03\ - \x08&\nR\n\x04\x04\0\x02\0\x12\x03\x05\x04\x20\x1aE\x20ContractAddress\ - \x20is\x20the\x20bech32\x20address\x20of\x20the\x20new\x20contract\x20in\ - stance.\n\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\ - \0\x02\0\x01\x12\x03\x05\x0b\x1b\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x05\ - \x1e\x1f\nO\n\x04\x04\0\x02\x01\x12\x03\x07\x04\x13\x1aB\x20Data\x20cont\ - ains\x20base64-encoded\x20bytes\x20to\x20returned\x20from\x20the\x20cont\ - ract\n\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x07\x04\t\n\x0c\n\x05\x04\0\ - \x02\x01\x01\x12\x03\x07\n\x0e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x07\ - \x11\x12b\x06proto3\ -"; - -static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) -} diff --git a/framework/packages/abstract-sdk/src/cw_helpers/cw_storage_plus.rs b/framework/packages/abstract-sdk/src/cw_helpers/cw_storage_plus.rs deleted file mode 100644 index a7290a7ee..000000000 --- a/framework/packages/abstract-sdk/src/cw_helpers/cw_storage_plus.rs +++ /dev/null @@ -1,81 +0,0 @@ -use cosmwasm_std::{StdResult, Storage}; -use cw_storage_plus::{Map, PrimaryKey}; -use serde::{de::DeserializeOwned, Serialize}; - -/// Load a batch of values by their keys from a [`Map`]. -pub fn load_many<'a, K, V>( - map: Map, - storage: &dyn Storage, - keys: Vec, -) -> StdResult> -where - K: PrimaryKey<'a>, - V: DeserializeOwned + Serialize, -{ - let mut res: Vec<(K, V)> = vec![]; - - for key in keys.into_iter() { - let value = map.load(storage, key.clone())?; - res.push((key, value)); - } - - Ok(res) -} - -#[cfg(test)] -mod test { - #![allow(clippy::needless_borrows_for_generic_args)] - use cosmwasm_std::{ - testing::{mock_dependencies, MockApi, MockQuerier, MockStorage}, - OwnedDeps, - }; - use speculoos::prelude::*; - - use super::*; - - const TEST_MAP: Map = Map::new("test_map"); - - const EXISTING_KEYS: [&str; 4] = ["a", "b", "c", "d"]; - - fn setup() -> OwnedDeps { - let mut deps = mock_dependencies(); - - for key in EXISTING_KEYS.iter() { - let string_key = key.to_string(); - TEST_MAP - .save(deps.as_mut().storage, string_key.clone(), &string_key) - .unwrap(); - } - - deps - } - - #[test] - fn load_many_works() { - let deps = setup(); - let keys = EXISTING_KEYS - .iter() - .map(|key| key.to_string()) - .collect::>(); - let res = load_many(TEST_MAP, deps.as_ref().storage, keys).unwrap(); - - assert_that!(res).has_length(EXISTING_KEYS.len()); - - for (key, value) in res.into_iter() { - assert_that!(key).is_equal_to(value); - } - } - - #[test] - fn load_many_with_not_existing() { - let deps = setup(); - let with_non_existing = EXISTING_KEYS - .iter() - .map(|key| key.to_string()) - .chain(vec!["e".to_string()]) - .collect::>(); - let res = load_many(TEST_MAP, deps.as_ref().storage, with_non_existing); - - assert_that!(res).is_err(); - } -} diff --git a/framework/packages/abstract-sdk/src/cw_helpers/mod.rs b/framework/packages/abstract-sdk/src/cw_helpers/mod.rs index 735c4b861..05579fde4 100644 --- a/framework/packages/abstract-sdk/src/cw_helpers/mod.rs +++ b/framework/packages/abstract-sdk/src/cw_helpers/mod.rs @@ -1,11 +1,10 @@ //! Helper functions and objects for working with the CosmWasm framework. mod cosmwasm_std; mod cw_ownable; -mod cw_storage_plus; mod fees; mod migrate_instantiate; pub use cw_clearable::*; pub use migrate_instantiate::*; -pub use self::{cosmwasm_std::*, cw_storage_plus::*, fees::*}; +pub use self::{cosmwasm_std::*, fees::*}; diff --git a/framework/packages/abstract-std/src/native/ans_host.rs b/framework/packages/abstract-std/src/native/ans_host.rs index f1c4add08..1f28469dd 100644 --- a/framework/packages/abstract-std/src/native/ans_host.rs +++ b/framework/packages/abstract-std/src/native/ans_host.rs @@ -284,11 +284,7 @@ pub struct AssetsResponse { } /// Query response -#[cosmwasm_schema::cw_serde] -pub struct AssetListResponse { - /// Assets (name, assetinfo) - pub assets: Vec, -} +pub type AssetListResponse = AssetsResponse; #[cosmwasm_schema::cw_serde] pub struct AssetInfosResponse { @@ -296,11 +292,7 @@ pub struct AssetInfosResponse { pub infos: Vec, } -#[cosmwasm_schema::cw_serde] -pub struct AssetInfoListResponse { - /// Assets (assetinfo, name) - pub infos: Vec, -} +pub type AssetInfoListResponse = AssetInfosResponse; #[cosmwasm_schema::cw_serde] pub struct ContractsResponse { diff --git a/scripts/framework-coverage.sh b/scripts/framework-coverage.sh index 2142ac9ce..1d5876bcb 100755 --- a/scripts/framework-coverage.sh +++ b/scripts/framework-coverage.sh @@ -12,7 +12,8 @@ if [ ! -f Cargo.lock ]; then cargo generate-lockfile fi -cargo llvm-cov --locked --lcov --output-path lcov.info - +cargo llvm-cov --workspace --locked --lcov --output-path lcov.info \ + --exclude abstract-testing --exclude abstract-integration-tests --exclude abstract-interface + # print the result. ls -la . \ No newline at end of file From 748ecab95e0542245c46dd25b64e1febbc422519 Mon Sep 17 00:00:00 2001 From: Buckram Date: Mon, 7 Oct 2024 14:31:17 +0300 Subject: [PATCH 05/14] aftermerge fixes --- framework/contracts/account/src/config.rs | 18 +++++++++--------- framework/contracts/account/src/modules.rs | 2 +- .../contracts/account/tests/install_modules.rs | 4 ++-- .../contracts/native/ans-host/src/queries.rs | 14 +++++++------- .../packages/abstract-interface/src/account.rs | 2 +- scripts/framework-coverage.sh | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/framework/contracts/account/src/config.rs b/framework/contracts/account/src/config.rs index 11c27cc27..cb3346f7c 100644 --- a/framework/contracts/account/src/config.rs +++ b/framework/contracts/account/src/config.rs @@ -573,7 +573,7 @@ mod tests { to_add: to_add.clone(), to_remove: vec![], }); - let too_many = execute_as(deps.as_mut(), &owner, too_many_msg).unwrap_err(); + let too_many = execute_as(&mut deps, &owner, too_many_msg).unwrap_err(); assert_eq!(too_many, AccountError::ModuleLimitReached {}); // Exact amount @@ -583,13 +583,13 @@ mod tests { to_add: to_add.clone(), to_remove: vec![], }); - let white_list_add = execute_as(deps.as_mut(), &owner, exactly_limit_msg); + let white_list_add = execute_as(&mut deps, &owner, exactly_limit_msg); assert!(white_list_add.is_ok()); // Can't add after hitting limit let to_add = vec![deps.api.addr_make("over_limit").to_string()]; let module_limit_reached = execute_as( - deps.as_mut(), + &mut deps, &owner, ExecuteMsg::UpdateInternalConfig(InternalConfigAction::UpdateWhitelist { to_add, @@ -616,9 +616,9 @@ mod tests { to_add: to_add.clone(), to_remove: vec![], }); - execute_as(deps.as_mut(), &owner, msg.clone()).unwrap(); + execute_as(&mut deps, &owner, msg.clone()).unwrap(); - let duplicate_err = execute_as(deps.as_mut(), &owner, msg).unwrap_err(); + let duplicate_err = execute_as(&mut deps, &owner, msg).unwrap_err(); assert_eq!( duplicate_err, AccountError::AlreadyWhitelisted(to_add[0].clone()) @@ -633,7 +633,7 @@ mod tests { to_add: to_add.clone(), to_remove: vec![], }); - let duplicate_err = execute_as(deps.as_mut(), &owner, msg).unwrap_err(); + let duplicate_err = execute_as(&mut deps, &owner, msg).unwrap_err(); assert_eq!( duplicate_err, AccountError::AlreadyWhitelisted(to_add[0].clone()) @@ -656,7 +656,7 @@ mod tests { to_add: to_add.clone(), to_remove: to_add.clone(), }); - let no_changes = execute_as(deps.as_mut(), &owner, msg.clone()); + let no_changes = execute_as(&mut deps, &owner, msg.clone()); assert!(no_changes.is_ok()); // Remove not whitelisted @@ -665,7 +665,7 @@ mod tests { to_add: vec![], to_remove, }); - let not_whitelisted = execute_as(deps.as_mut(), &owner, msg.clone()).unwrap_err(); + let not_whitelisted = execute_as(&mut deps, &owner, msg.clone()).unwrap_err(); assert_eq!(not_whitelisted, AccountError::NotWhitelisted {}); // Remove same twice @@ -678,7 +678,7 @@ mod tests { to_add: to_add.clone(), to_remove: to_remove.clone(), }); - let not_whitelisted = execute_as(deps.as_mut(), &owner, msg.clone()).unwrap_err(); + let not_whitelisted = execute_as(&mut deps, &owner, msg.clone()).unwrap_err(); assert_eq!(not_whitelisted, AccountError::NotWhitelisted {}); Ok(()) diff --git a/framework/contracts/account/src/modules.rs b/framework/contracts/account/src/modules.rs index 3fcac2128..309d215ed 100644 --- a/framework/contracts/account/src/modules.rs +++ b/framework/contracts/account/src/modules.rs @@ -18,7 +18,7 @@ use abstract_std::{ }; use cosmwasm_std::{ ensure, wasm_execute, Addr, Attribute, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, - MessageInfo, StdError, StdResult, Storage, SubMsg, + MessageInfo, StdResult, Storage, SubMsg, }; use cw2::ContractVersion; use cw_storage_plus::Item; diff --git a/framework/contracts/account/tests/install_modules.rs b/framework/contracts/account/tests/install_modules.rs index fd30127b1..5cc196c60 100644 --- a/framework/contracts/account/tests/install_modules.rs +++ b/framework/contracts/account/tests/install_modules.rs @@ -3,8 +3,8 @@ use abstract_integration_tests::{create_default_account, mock_modules, AResult}; use abstract_interface::{Abstract, AccountQueryFns, RegistryExecFns}; use abstract_std::{ account::{ - AccountModuleInfo, ExecuteMsg as AccountMsg, ModuleAddressesResponse, ModuleInfosResponse, - ModuleInstallConfig, QueryMsg as AccountQuery, + ExecuteMsg as AccountMsg, ModuleAddressesResponse, ModuleInstallConfig, + QueryMsg as AccountQuery, }, objects::{module::ModuleInfo, ownership::GovOwnershipError}, }; diff --git a/framework/contracts/native/ans-host/src/queries.rs b/framework/contracts/native/ans-host/src/queries.rs index 7e8f4d384..5c76e233b 100644 --- a/framework/contracts/native/ans-host/src/queries.rs +++ b/framework/contracts/native/ans-host/src/queries.rs @@ -1021,7 +1021,7 @@ mod test { None, )?; let res_full_filter_bar: PoolsResponse = - from_json(query_helper(deps.as_ref(), msg_full_filter_bar)?)?; + from_json(query_helper(&deps, msg_full_filter_bar)?)?; let msg_foo = create_pool_list_msg( Some(create_asset_pairing_filter("juno", "atom", None)?), @@ -1223,7 +1223,7 @@ mod test { cw20_2.clone().into(), ], }; - let res: AssetInfosResponse = from_json(query_helper(deps.as_ref(), msg)?)?; + let res: AssetInfosResponse = from_json(query_helper(&deps, msg)?)?; let expected_bar = AssetInfosResponse { infos: vec![ (native_1, AssetEntry::new("foo_n")), @@ -1236,7 +1236,7 @@ mod test { // Query invalid asset let res = query_helper( - deps.as_ref(), + &deps, QueryMsg::AssetInfos { infos: vec![AssetInfoUnchecked::cw20("invalid_addr".to_string())], }, @@ -1244,7 +1244,7 @@ mod test { assert!(res.is_err()); // Query not saved asset let res = query_helper( - deps.as_ref(), + &deps, QueryMsg::AssetInfos { infos: vec![AssetInfoUnchecked::native("not_saved".to_string())], }, @@ -1273,7 +1273,7 @@ mod test { start_after: None, limit: None, }; - let res: AssetInfoListResponse = from_json(query_helper(deps.as_ref(), msg)?)?; + let res: AssetInfoListResponse = from_json(query_helper(&deps, msg)?)?; let expected_infos = AssetInfoListResponse { infos: vec![ (cw20_1.clone(), AssetEntry::new("foo_ft")), @@ -1290,7 +1290,7 @@ mod test { start_after: Some(cw20_2.clone().into()), limit: None, }; - let res: AssetInfoListResponse = from_json(query_helper(deps.as_ref(), msg)?)?; + let res: AssetInfoListResponse = from_json(query_helper(&deps, msg)?)?; let expected_infos = AssetInfoListResponse { infos: vec![ (native_2, AssetEntry::new("bar_n")), @@ -1305,7 +1305,7 @@ mod test { start_after: None, limit: Some(1), }; - let res: AssetInfoListResponse = from_json(query_helper(deps.as_ref(), msg)?)?; + let res: AssetInfoListResponse = from_json(query_helper(&deps, msg)?)?; let expected_infos = AssetInfoListResponse { infos: vec![(cw20_1.clone(), AssetEntry::new("foo_ft"))], }; diff --git a/framework/packages/abstract-interface/src/account.rs b/framework/packages/abstract-interface/src/account.rs index fc5f70c40..3cf06a0b2 100644 --- a/framework/packages/abstract-interface/src/account.rs +++ b/framework/packages/abstract-interface/src/account.rs @@ -548,7 +548,7 @@ impl AccountI { registry.register_account( self.as_instance(), ::account::contract::CONTRACT_VERSION.to_string(), - ); + )?; true } else { false diff --git a/scripts/framework-coverage.sh b/scripts/framework-coverage.sh index 1d5876bcb..75dfe13c0 100755 --- a/scripts/framework-coverage.sh +++ b/scripts/framework-coverage.sh @@ -12,8 +12,8 @@ if [ ! -f Cargo.lock ]; then cargo generate-lockfile fi -cargo llvm-cov --workspace --locked --lcov --output-path lcov.info \ - --exclude abstract-testing --exclude abstract-integration-tests --exclude abstract-interface +cargo llvm-cov --workspace --exclude abstract-testing --exclude abstract-integration-tests --exclude abstract-interface \ + --locked --lcov --output-path lcov.info # print the result. -ls -la . \ No newline at end of file +ls -la . From b4f4da60678dbe642844bb3c6119796d87021e18 Mon Sep 17 00:00:00 2001 From: Buckram Date: Mon, 7 Oct 2024 17:15:18 +0300 Subject: [PATCH 06/14] abstract sdk codecov progress --- framework/packages/abstract-sdk/Cargo.toml | 5 ++ .../abstract-sdk/src/account_action.rs | 43 ++++++++++++++-- .../packages/abstract-sdk/src/ans_resolve.rs | 10 +++- .../packages/abstract-sdk/src/apis/bank.rs | 46 +++++++++++++++++ .../abstract-sdk/src/apis/splitter.rs | 2 +- framework/packages/abstract-sdk/src/error.rs | 1 + .../abstract-sdk/src/feature_objects.rs | 49 ++++++++++++------- framework/packages/abstract-sdk/src/lib.rs | 1 + 8 files changed, 132 insertions(+), 25 deletions(-) diff --git a/framework/packages/abstract-sdk/Cargo.toml b/framework/packages/abstract-sdk/Cargo.toml index 29b10149f..270e8ec24 100644 --- a/framework/packages/abstract-sdk/Cargo.toml +++ b/framework/packages/abstract-sdk/Cargo.toml @@ -52,3 +52,8 @@ doc-comment = "0.3.3" # Set our own feature when running tests! abstract-sdk = { path = ".", features = ["test-utils"] } cw-ownable = { workspace = true } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(coverage,coverage_nightly)', +] } diff --git a/framework/packages/abstract-sdk/src/account_action.rs b/framework/packages/abstract-sdk/src/account_action.rs index 80378bcf2..8b666022a 100644 --- a/framework/packages/abstract-sdk/src/account_action.rs +++ b/framework/packages/abstract-sdk/src/account_action.rs @@ -4,24 +4,22 @@ use cosmwasm_std::CosmosMsg; /// When a method returns an AccountAction, this means this message needs to be dispatched to the account using the [`Execution`](crate::Execution) api. /// /// If required you can create an AccountAction from a CosmosMsg using `AccountAction::from(msg)`. -#[derive(Debug, PartialEq, Clone, Default)] +#[derive(Debug, Default, PartialEq, Clone)] #[must_use = "Pass AccountAction to the Executor, see the docs"] pub struct AccountAction(Vec); impl AccountAction { - /// Create a new empty AccountAction - pub fn new() -> Self { - Self(vec![]) - } /// Access the underlying messages /// Don't use this to execute the action, use the `Execution` API instead. pub fn messages(&self) -> Vec { self.0.clone() } + /// Merge two AccountActions into one. pub fn merge(&mut self, other: AccountAction) { self.0.extend(other.0) } + /// Creates an account action from multiple messages pub fn from_vec(msgs: Vec) -> Self where @@ -39,3 +37,38 @@ where Self(vec![m.into()]) } } + +#[cfg(test)] +mod test { + use cosmwasm_std::coins; + + use super::*; + + #[test] + fn account_action() { + let mut account_action = + AccountAction::from_vec(vec![CosmosMsg::Bank(cosmwasm_std::BankMsg::Burn { + amount: coins(5, "test"), + })]); + assert_eq!( + account_action.messages(), + vec![CosmosMsg::Bank(cosmwasm_std::BankMsg::Burn { + amount: coins(5, "test"), + })] + ); + + // merge + account_action.merge(account_action.clone()); + assert_eq!( + account_action.messages(), + vec![ + CosmosMsg::Bank(cosmwasm_std::BankMsg::Burn { + amount: coins(5, "test"), + }), + CosmosMsg::Bank(cosmwasm_std::BankMsg::Burn { + amount: coins(5, "test"), + }) + ] + ) + } +} diff --git a/framework/packages/abstract-sdk/src/ans_resolve.rs b/framework/packages/abstract-sdk/src/ans_resolve.rs index d4f27cdca..cf2da6ba2 100644 --- a/framework/packages/abstract-sdk/src/ans_resolve.rs +++ b/framework/packages/abstract-sdk/src/ans_resolve.rs @@ -204,7 +204,11 @@ mod tests { let is_registered = test_asset_entry.is_registered(&QuerierWrapper::new(&querier), &ans_host); - assert_that!(is_registered).is_true(); + assert!(is_registered); + + let assert_registered = + test_asset_entry.assert_registered(&QuerierWrapper::new(&querier), &ans_host); + assert!(assert_registered.is_ok()) } #[test] @@ -217,7 +221,9 @@ mod tests { let wrapper = wrap_querier(&querier); let is_registered = not_exist_asset.is_registered(&wrapper, &ans_host); - assert_that!(is_registered).is_false(); + assert!(!is_registered); + let assert_registered = not_exist_asset.assert_registered(&wrapper, &ans_host); + assert!(assert_registered.is_err()); } } diff --git a/framework/packages/abstract-sdk/src/apis/bank.rs b/framework/packages/abstract-sdk/src/apis/bank.rs index 756c99bba..d26fb8e57 100644 --- a/framework/packages/abstract-sdk/src/apis/bank.rs +++ b/framework/packages/abstract-sdk/src/apis/bank.rs @@ -292,6 +292,52 @@ mod test { use super::*; use crate::mock_module::*; + mod balance { + use super::*; + + #[test] + fn balance() { + let (mut deps, account, app) = mock_module_setup(); + let env = mock_env_validated(deps.api); + + let bank: Bank<'_, MockModule> = app.bank(deps.as_ref(), &env); + let res = bank + .balances(&[AssetEntry::new("asset_entry")]) + .unwrap_err(); + let AbstractSdkError::ApiQuery { + api, + module_id, + error: _, + } = res + else { + panic!("expected api error"); + }; + assert_eq!(api, "Bank"); + assert_eq!(module_id, app.module_id()); + drop(bank); + + let abstr = abstract_testing::prelude::AbstractMockAddrs::new(deps.api); + // update querier and balances + deps.querier = abstract_testing::abstract_mock_querier_builder(deps.api) + .with_contract_map_entry( + &abstr.ans_host, + abstract_std::ans_host::state::ASSET_ADDRESSES, + ( + &AssetEntry::new("asset_entry"), + cw_asset::AssetInfo::native("asset"), + ), + ) + .build(); + let recipient: Addr = account.into_addr(); + let coins: Vec = coins(100u128, "asset"); + deps.querier.bank.update_balance(recipient, coins.clone()); + + let bank: Bank<'_, MockModule> = app.bank(deps.as_ref(), &env); + let res = bank.balances(&[AssetEntry::new("asset_entry")]).unwrap(); + assert_eq!(res, vec![Asset::native("asset", 100u128)]); + } + } + mod transfer_coins { use abstract_std::account::ExecuteMsg; diff --git a/framework/packages/abstract-sdk/src/apis/splitter.rs b/framework/packages/abstract-sdk/src/apis/splitter.rs index 7acba452b..3d94cde89 100644 --- a/framework/packages/abstract-sdk/src/apis/splitter.rs +++ b/framework/packages/abstract-sdk/src/apis/splitter.rs @@ -64,7 +64,7 @@ impl<'a, T: SplitterInterface> Splitter<'a, T> { // Construct the transfer message bank.transfer(vec![&receives_each], receiver) }) - .try_fold(AccountAction::new(), |mut acc, v| match v { + .try_fold(AccountAction::default(), |mut acc, v| match v { Ok(action) => { // Merge two AccountAction objects acc.merge(action); diff --git a/framework/packages/abstract-sdk/src/error.rs b/framework/packages/abstract-sdk/src/error.rs index e67f3b598..fc255d710 100644 --- a/framework/packages/abstract-sdk/src/error.rs +++ b/framework/packages/abstract-sdk/src/error.rs @@ -20,6 +20,7 @@ impl Display for EndpointError { write!(f, "Error in {} - {}", self.module_id, self.source) } } + /// Error type for the abstract sdk crate. #[derive(Error, Debug, PartialEq)] pub enum AbstractSdkError { diff --git a/framework/packages/abstract-sdk/src/feature_objects.rs b/framework/packages/abstract-sdk/src/feature_objects.rs index 4847f18a0..3fe481455 100644 --- a/framework/packages/abstract-sdk/src/feature_objects.rs +++ b/framework/packages/abstract-sdk/src/feature_objects.rs @@ -5,7 +5,7 @@ //! requiring the usage of a base contract. pub use abstract_std::objects::{ans_host::AnsHost, registry::RegistryContract}; -use abstract_std::{registry::Account, REGISTRY}; +use abstract_std::{registry::Account, ANS_HOST, REGISTRY}; use cosmwasm_std::{Deps, Env}; use crate::{ @@ -45,15 +45,20 @@ impl crate::features::AbstractNameService for AnsHost { } } +impl ModuleIdentification for AnsHost { + fn module_id(&self) -> abstract_std::objects::module::ModuleId<'static> { + ANS_HOST + } +} + #[cfg(test)] mod tests { use abstract_testing::prelude::*; - use speculoos::prelude::*; + use cosmwasm_std::testing::mock_dependencies; use super::*; mod registry { - use cosmwasm_std::testing::mock_dependencies; use super::*; use crate::features::AbstractRegistryAccess; @@ -62,34 +67,44 @@ mod tests { fn test_registry() { let deps = mock_dependencies(); let env = mock_env_validated(deps.api); - let vc = RegistryContract::new(&deps.api, &env).unwrap(); + let registry = RegistryContract::new(&deps.api, &env).unwrap(); - assert_that!(vc.abstract_registry(deps.as_ref(), &env)) - .is_ok() - .is_equal_to(vc); + assert_eq!( + registry.abstract_registry(deps.as_ref(), &env).unwrap(), + registry + ); + assert_eq!(registry.module_id(), REGISTRY); } } - mod account { - use cosmwasm_std::{testing::mock_dependencies, Addr}; + mod ans { + + use abstract_std::ANS_HOST; use super::*; + use crate::features::AbstractNameService; #[test] - fn test_account_addr() { + fn test_ans() { let deps = mock_dependencies(); - let account = test_account(deps.api); + let env = mock_env_validated(deps.api); + let ans = AnsHost::new(&deps.api, &env).unwrap(); - assert_that!(account.account(deps.as_ref())) - .is_ok() - .is_equal_to(account); + assert_eq!(ans.ans_host(deps.as_ref(), &env).unwrap(), ans); + assert_eq!(ans.module_id(), ANS_HOST); } + } + + mod account { + use super::*; #[test] - fn should_identify_self_as_account() { - let account = Account::new(Addr::unchecked("test")); + fn test_account_object() { + let deps = mock_dependencies(); + let account = test_account(deps.api); - assert_that!(account.module_id()).is_equal_to(ACCOUNT); + assert_eq!(account.account(deps.as_ref()).unwrap(), account); + assert_eq!(account.module_id(), ACCOUNT); } } } diff --git a/framework/packages/abstract-sdk/src/lib.rs b/framework/packages/abstract-sdk/src/lib.rs index ddd50dc10..aa26c3ad2 100644 --- a/framework/packages/abstract-sdk/src/lib.rs +++ b/framework/packages/abstract-sdk/src/lib.rs @@ -53,4 +53,5 @@ pub mod register { } #[cfg(feature = "test-utils")] +#[cfg_attr(coverage, coverage(off))] pub mod mock_module; From a29b2d08726f8ff43f8f39a39bc34923946f1f32 Mon Sep 17 00:00:00 2001 From: Buckram Date: Mon, 7 Oct 2024 17:58:26 +0300 Subject: [PATCH 07/14] update snapshots --- ...oxy__account_install_multiple_modules.snap | 32 +++++++++---------- ...y__account_install_standalone_modules.snap | 32 +++++++++---------- .../proxy__account_with_response_data.snap | 26 +++++++-------- ...updating_on_subaccount_should_succeed.snap | 24 +++++++------- 4 files changed, 57 insertions(+), 57 deletions(-) diff --git a/framework/contracts/account/tests/snapshots/proxy__account_install_multiple_modules.snap b/framework/contracts/account/tests/snapshots/proxy__account_install_multiple_modules.snap index f8d30f8bb..bc743c1d2 100644 --- a/framework/contracts/account/tests/snapshots/proxy__account_install_multiple_modules.snap +++ b/framework/contracts/account/tests/snapshots/proxy__account_install_multiple_modules.snap @@ -4,9 +4,9 @@ expression: all_storage --- "abstract:account-local-0": - - "\u0000\u0002acabstract:standalone1" - - "\"mock1kw7xtucfdzuptc4plzem3c3mnysw7v8rp62jtp276pztea574meqd4nen0\"" + - "\"mock1x7x3ytgtqcgmq85hxtr4llsj9wdeg9wkp84l30pct39gf8257pfswcrwtx\"" - - "\u0000\u0002acabstract:standalone2" - - "\"mock1qwff5lphmmgu0pawkn99p8a289ms46y5gyzwww24dzf9fcczhdpstzh8da\"" + - "\"mock1k76kwzlgv6puhx37s3gx9554l487wk6n8ph5t0wrtm4eklz2vecqpv532h\"" - - aa - "false" - - ab @@ -16,13 +16,13 @@ expression: all_storage - - ag - "{\"trace\":\"local\",\"seq\":0}" - - ah - - "[[{\"info\":{\"namespace\":\"abstract\",\"name\":\"standalone1\",\"version\":{\"version\":\"1.0.0\"}},\"reference\":{\"standalone\":13}},\"mock1kw7xtucfdzuptc4plzem3c3mnysw7v8rp62jtp276pztea574meqd4nen0\"],[{\"info\":{\"namespace\":\"abstract\",\"name\":\"standalone2\",\"version\":{\"version\":\"1.0.0\"}},\"reference\":{\"standalone\":14}},\"mock1qwff5lphmmgu0pawkn99p8a289ms46y5gyzwww24dzf9fcczhdpstzh8da\"]]" + - "[[{\"info\":{\"namespace\":\"abstract\",\"name\":\"standalone1\",\"version\":{\"version\":\"1.0.0\"}},\"reference\":{\"standalone\":13}},\"mock1x7x3ytgtqcgmq85hxtr4llsj9wdeg9wkp84l30pct39gf8257pfswcrwtx\"],[{\"info\":{\"namespace\":\"abstract\",\"name\":\"standalone2\",\"version\":{\"version\":\"1.0.0\"}},\"reference\":{\"standalone\":14}},\"mock1k76kwzlgv6puhx37s3gx9554l487wk6n8ph5t0wrtm4eklz2vecqpv532h\"]]" - - ai - "[]" - - contract_info - "{\"contract\":\"abstract:account\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":{\"monarchy\":{\"monarch\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\"}},\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":{\"monarchy\":{\"monarch\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\"}},\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ans-host": - - be - "[]" @@ -31,43 +31,43 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:ans-host\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ibc-client": - - contract_info - "{\"contract\":\"abstract:ibc-client\",\"version\":\"0.23.0\"}" - - mod - "{\"module\":\"abstract:ibc-client\",\"version\":\"0.23.0\",\"dependencies\":[],\"metadata\":null}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ibc-host": - - contract_info - "{\"contract\":\"abstract:ibc-host\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:module-factory": - - contract_info - "{\"contract\":\"abstract:module-factory\",\"version\":\"0.23.0\"}" - - da - - "\"mock183tnnc2hqt8tj677neekarwkmlygw09uqrchq4c2aaauleyxzc3sy9w235\"" + - "\"mock1ys8clus4qf2haemyck0uljz74dj2k8hu4ggfpe7vty6zd5j2982q9sf90k\"" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:version-control": - - "\u0000\u0002cb\u0000\babstract\u0000\u0007account0.23.0" - "{\"account\":5}" - - "\u0000\u0002cb\u0000\babstract\u0000\bans-host0.23.0" - - "{\"native\":\"mock17r8ljc3tw8tdx85gpwxpq5ten89622svh2ct0utcg75x89ed7cgsyz0g62\"}" + - "{\"native\":\"mock1pzf4rfa8ly8y306c2zxm9ka4hegpv9c4tsffcxejc3mz4jkcac4qkernmj\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\bibc-host0.23.0" - - "{\"native\":\"mock19jf2y29m2qvgfezcyy5zhq8phfdcysngew508eeumdsg2dyzqrqshlx44z\"}" + - "{\"native\":\"mock1dtw8lua8qpav6x3sngqwd3xqmyvg5q0pnv2lkmajzk0rjkjetm2s2pyq4n\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\nibc-client0.23.0" - - "{\"native\":\"mock1u377ag8ewzrskj6r0pqutnpyvh7hd2yqq6uh3rh2pclex2gzhslsq3frn0\"}" + - "{\"native\":\"mock1l487rfqw2yevhvh4c3dw706mdy9u703zsawq7xt4h9e0h9up9fgqwk620q\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000bstandalone11.0.0" - "{\"standalone\":13}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000bstandalone21.0.0" - "{\"standalone\":14}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000emodule-factory0.23.0" - - "{\"native\":\"mock10ymkph7y47lmxkyan49cq2yjm5m3n2nk83efppcwwpunx7gs374qg8fkqs\"}" + - "{\"native\":\"mock1wzrl9hf8xukhu7ukx5quted5m5c2vklmr70tg88a0zkduts7f0sqpr58lc\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000fversion-control0.23.0" - - "{\"native\":\"mock18aq2nqrm809gdktwetuk6c48c6yj379ptkdeewv6j797xv3j2gssdzgurv\"}" + - "{\"native\":\"mock1tnv2hfx6gqdtelccc57aru3ju8wlff8pslrsfdqn862qjc69gsas0vscja\"}" - - "\u0000\u0002cc\u0000\u0000\u0000\u0000\u0000\u0000\u0000\r" - "{\"namespace\":\"abstract\",\"name\":\"standalone1\",\"version\":{\"version\":\"1.0.0\"}}" - - "\u0000\u0002cc\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u000e" @@ -77,7 +77,7 @@ expression: all_storage - - "\u0000\u0002cf\u0000\babstract\u0000\u000bstandalone21.0.0" - "{\"monetization\":\"none\",\"metadata\":null,\"instantiation_funds\":[{\"denom\":\"token1\",\"amount\":\"42\"},{\"denom\":\"token2\",\"amount\":\"500\"}]}" - - "\u0000\u0002ch\u0000\u0005local\u0000\u0000\u0000\u0000" - - "\"mock183tnnc2hqt8tj677neekarwkmlygw09uqrchq4c2aaauleyxzc3sy9w235\"" + - "\"mock1ys8clus4qf2haemyck0uljz74dj2k8hu4ggfpe7vty6zd5j2982q9sf90k\"" - - "\u0000\u0005nmspcabstract" - "{\"trace\":\"local\",\"seq\":0}" - - "\u0000\u0007nmspc_a\u0000\u0005local\u0000\u0004\u0000\u0000\u0000\u0000abstract" @@ -89,4 +89,4 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:version-control\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" diff --git a/framework/contracts/account/tests/snapshots/proxy__account_install_standalone_modules.snap b/framework/contracts/account/tests/snapshots/proxy__account_install_standalone_modules.snap index fe8a00c60..2c758e658 100644 --- a/framework/contracts/account/tests/snapshots/proxy__account_install_standalone_modules.snap +++ b/framework/contracts/account/tests/snapshots/proxy__account_install_standalone_modules.snap @@ -4,9 +4,9 @@ expression: all_storage --- "abstract:account-local-0": - - "\u0000\u0002acabstract:standalone1" - - "\"mock1kw7xtucfdzuptc4plzem3c3mnysw7v8rp62jtp276pztea574meqd4nen0\"" + - "\"mock1x7x3ytgtqcgmq85hxtr4llsj9wdeg9wkp84l30pct39gf8257pfswcrwtx\"" - - "\u0000\u0002acabstract:standalone2" - - "\"mock1qwff5lphmmgu0pawkn99p8a289ms46y5gyzwww24dzf9fcczhdpstzh8da\"" + - "\"mock1k76kwzlgv6puhx37s3gx9554l487wk6n8ph5t0wrtm4eklz2vecqpv532h\"" - - aa - "false" - - ab @@ -16,13 +16,13 @@ expression: all_storage - - ag - "{\"trace\":\"local\",\"seq\":0}" - - ah - - "[[{\"info\":{\"namespace\":\"abstract\",\"name\":\"standalone2\",\"version\":{\"version\":\"1.0.0\"}},\"reference\":{\"standalone\":14}},\"mock1qwff5lphmmgu0pawkn99p8a289ms46y5gyzwww24dzf9fcczhdpstzh8da\"]]" + - "[[{\"info\":{\"namespace\":\"abstract\",\"name\":\"standalone2\",\"version\":{\"version\":\"1.0.0\"}},\"reference\":{\"standalone\":14}},\"mock1k76kwzlgv6puhx37s3gx9554l487wk6n8ph5t0wrtm4eklz2vecqpv532h\"]]" - - ai - "[]" - - contract_info - "{\"contract\":\"abstract:account\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":{\"monarchy\":{\"monarch\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\"}},\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":{\"monarchy\":{\"monarch\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\"}},\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ans-host": - - be - "[]" @@ -31,49 +31,49 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:ans-host\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ibc-client": - - contract_info - "{\"contract\":\"abstract:ibc-client\",\"version\":\"0.23.0\"}" - - mod - "{\"module\":\"abstract:ibc-client\",\"version\":\"0.23.0\",\"dependencies\":[],\"metadata\":null}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ibc-host": - - contract_info - "{\"contract\":\"abstract:ibc-host\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:module-factory": - - contract_info - "{\"contract\":\"abstract:module-factory\",\"version\":\"0.23.0\"}" - - da - - "\"mock183tnnc2hqt8tj677neekarwkmlygw09uqrchq4c2aaauleyxzc3sy9w235\"" + - "\"mock1ys8clus4qf2haemyck0uljz74dj2k8hu4ggfpe7vty6zd5j2982q9sf90k\"" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:version-control": - - "\u0000\u0002cb\u0000\babstract\u0000\u0007account0.23.0" - "{\"account\":5}" - - "\u0000\u0002cb\u0000\babstract\u0000\bans-host0.23.0" - - "{\"native\":\"mock17r8ljc3tw8tdx85gpwxpq5ten89622svh2ct0utcg75x89ed7cgsyz0g62\"}" + - "{\"native\":\"mock1pzf4rfa8ly8y306c2zxm9ka4hegpv9c4tsffcxejc3mz4jkcac4qkernmj\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\bibc-host0.23.0" - - "{\"native\":\"mock19jf2y29m2qvgfezcyy5zhq8phfdcysngew508eeumdsg2dyzqrqshlx44z\"}" + - "{\"native\":\"mock1dtw8lua8qpav6x3sngqwd3xqmyvg5q0pnv2lkmajzk0rjkjetm2s2pyq4n\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\nibc-client0.23.0" - - "{\"native\":\"mock1u377ag8ewzrskj6r0pqutnpyvh7hd2yqq6uh3rh2pclex2gzhslsq3frn0\"}" + - "{\"native\":\"mock1l487rfqw2yevhvh4c3dw706mdy9u703zsawq7xt4h9e0h9up9fgqwk620q\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000bstandalone11.0.0" - "{\"standalone\":13}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000bstandalone21.0.0" - "{\"standalone\":14}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000emodule-factory0.23.0" - - "{\"native\":\"mock10ymkph7y47lmxkyan49cq2yjm5m3n2nk83efppcwwpunx7gs374qg8fkqs\"}" + - "{\"native\":\"mock1wzrl9hf8xukhu7ukx5quted5m5c2vklmr70tg88a0zkduts7f0sqpr58lc\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000fversion-control0.23.0" - - "{\"native\":\"mock18aq2nqrm809gdktwetuk6c48c6yj379ptkdeewv6j797xv3j2gssdzgurv\"}" + - "{\"native\":\"mock1tnv2hfx6gqdtelccc57aru3ju8wlff8pslrsfdqn862qjc69gsas0vscja\"}" - - "\u0000\u0002cc\u0000\u0000\u0000\u0000\u0000\u0000\u0000\r" - "{\"namespace\":\"abstract\",\"name\":\"standalone1\",\"version\":{\"version\":\"1.0.0\"}}" - - "\u0000\u0002cc\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u000e" - "{\"namespace\":\"abstract\",\"name\":\"standalone2\",\"version\":{\"version\":\"1.0.0\"}}" - - "\u0000\u0002ch\u0000\u0005local\u0000\u0000\u0000\u0000" - - "\"mock183tnnc2hqt8tj677neekarwkmlygw09uqrchq4c2aaauleyxzc3sy9w235\"" + - "\"mock1ys8clus4qf2haemyck0uljz74dj2k8hu4ggfpe7vty6zd5j2982q9sf90k\"" - - "\u0000\u0005nmspcabstract" - "{\"trace\":\"local\",\"seq\":0}" - - "\u0000\u0007nmspc_a\u0000\u0005local\u0000\u0004\u0000\u0000\u0000\u0000abstract" @@ -85,4 +85,4 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:version-control\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" diff --git a/framework/contracts/account/tests/snapshots/proxy__account_with_response_data.snap b/framework/contracts/account/tests/snapshots/proxy__account_with_response_data.snap index a58322559..09a89925d 100644 --- a/framework/contracts/account/tests/snapshots/proxy__account_with_response_data.snap +++ b/framework/contracts/account/tests/snapshots/proxy__account_with_response_data.snap @@ -16,7 +16,7 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:account\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":{\"monarchy\":{\"monarch\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\"}},\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":{\"monarchy\":{\"monarch\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\"}},\"pending_owner\":null,\"pending_expiry\":null}" "abstract:account-local-1": - - "\u0000\u0002actester:test-module-id" - "\"mock14xc5dkz0rn8j99lxz69mkv3wzawmadg7xurkzy49m9yefmqx5c6s4lc5ql\"" @@ -44,41 +44,41 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:ans-host\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ibc-client": - - contract_info - "{\"contract\":\"abstract:ibc-client\",\"version\":\"0.23.0\"}" - - mod - "{\"module\":\"abstract:ibc-client\",\"version\":\"0.23.0\",\"dependencies\":[],\"metadata\":null}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ibc-host": - - contract_info - "{\"contract\":\"abstract:ibc-host\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:module-factory": - - contract_info - "{\"contract\":\"abstract:module-factory\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:version-control": - - "\u0000\u0002cb\u0000\u0006tester\u0000\u000etest-module-id0.23.0" - "{\"adapter\":\"mock14xc5dkz0rn8j99lxz69mkv3wzawmadg7xurkzy49m9yefmqx5c6s4lc5ql\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\u0007account0.23.0" - "{\"account\":5}" - - "\u0000\u0002cb\u0000\babstract\u0000\bans-host0.23.0" - - "{\"native\":\"mock17r8ljc3tw8tdx85gpwxpq5ten89622svh2ct0utcg75x89ed7cgsyz0g62\"}" + - "{\"native\":\"mock1pzf4rfa8ly8y306c2zxm9ka4hegpv9c4tsffcxejc3mz4jkcac4qkernmj\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\bibc-host0.23.0" - - "{\"native\":\"mock19jf2y29m2qvgfezcyy5zhq8phfdcysngew508eeumdsg2dyzqrqshlx44z\"}" + - "{\"native\":\"mock1dtw8lua8qpav6x3sngqwd3xqmyvg5q0pnv2lkmajzk0rjkjetm2s2pyq4n\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\nibc-client0.23.0" - - "{\"native\":\"mock1u377ag8ewzrskj6r0pqutnpyvh7hd2yqq6uh3rh2pclex2gzhslsq3frn0\"}" + - "{\"native\":\"mock1l487rfqw2yevhvh4c3dw706mdy9u703zsawq7xt4h9e0h9up9fgqwk620q\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000emodule-factory0.23.0" - - "{\"native\":\"mock10ymkph7y47lmxkyan49cq2yjm5m3n2nk83efppcwwpunx7gs374qg8fkqs\"}" + - "{\"native\":\"mock1wzrl9hf8xukhu7ukx5quted5m5c2vklmr70tg88a0zkduts7f0sqpr58lc\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000fversion-control0.23.0" - - "{\"native\":\"mock18aq2nqrm809gdktwetuk6c48c6yj379ptkdeewv6j797xv3j2gssdzgurv\"}" + - "{\"native\":\"mock1tnv2hfx6gqdtelccc57aru3ju8wlff8pslrsfdqn862qjc69gsas0vscja\"}" - - "\u0000\u0002ch\u0000\u0005local\u0000\u0000\u0000\u0000" - - "\"mock183tnnc2hqt8tj677neekarwkmlygw09uqrchq4c2aaauleyxzc3sy9w235\"" + - "\"mock1ys8clus4qf2haemyck0uljz74dj2k8hu4ggfpe7vty6zd5j2982q9sf90k\"" - - "\u0000\u0002ch\u0000\u0005local\u0000\u0000\u0000\u0001" - "\"mock1jdl4tasw0x00k2edyf8656lqxy95gx06h2nt5n8qjzv45yxr5ekq0myk0q\"" - - "\u0000\u0005nmspcabstract" @@ -96,12 +96,12 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:version-control\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "tester:test-module-id": - - "\u0000\u0014authorized_addressesmock1jdl4tasw0x00k2edyf8656lqxy95gx06h2nt5n8qjzv45yxr5ekq0myk0q" - "[\"mock1jdl4tasw0x00k2edyf8656lqxy95gx06h2nt5n8qjzv45yxr5ekq0myk0q\"]" - - base_state - - "{\"registry\":{\"address\":\"mock18aq2nqrm809gdktwetuk6c48c6yj379ptkdeewv6j797xv3j2gssdzgurv\"},\"ans_host\":{\"address\":\"mock17r8ljc3tw8tdx85gpwxpq5ten89622svh2ct0utcg75x89ed7cgsyz0g62\"}}" + - "{}" - - contract_info - "{\"contract\":\"tester:test-module-id\",\"version\":\"0.23.0\"}" - - ibc_callback_received diff --git a/framework/contracts/account/tests/snapshots/subaccount__account_updating_on_subaccount_should_succeed.snap b/framework/contracts/account/tests/snapshots/subaccount__account_updating_on_subaccount_should_succeed.snap index 88b7c8a0d..3ee265c2d 100644 --- a/framework/contracts/account/tests/snapshots/subaccount__account_updating_on_subaccount_should_succeed.snap +++ b/framework/contracts/account/tests/snapshots/subaccount__account_updating_on_subaccount_should_succeed.snap @@ -16,7 +16,7 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:account\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":{\"monarchy\":{\"monarch\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\"}},\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":{\"monarchy\":{\"monarch\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\"}},\"pending_owner\":null,\"pending_expiry\":null}" "abstract:account-local-1": - - "\u0000\u0002ae\u0000\u0000\u0000\u0002" - "{}" @@ -57,39 +57,39 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:ans-host\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ibc-client": - - contract_info - "{\"contract\":\"abstract:ibc-client\",\"version\":\"0.23.0\"}" - - mod - "{\"module\":\"abstract:ibc-client\",\"version\":\"0.23.0\",\"dependencies\":[],\"metadata\":null}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:ibc-host": - - contract_info - "{\"contract\":\"abstract:ibc-host\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:module-factory": - - contract_info - "{\"contract\":\"abstract:module-factory\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" "abstract:version-control": - - "\u0000\u0002cb\u0000\babstract\u0000\u0007account0.23.0" - "{\"account\":5}" - - "\u0000\u0002cb\u0000\babstract\u0000\bans-host0.23.0" - - "{\"native\":\"mock17r8ljc3tw8tdx85gpwxpq5ten89622svh2ct0utcg75x89ed7cgsyz0g62\"}" + - "{\"native\":\"mock1pzf4rfa8ly8y306c2zxm9ka4hegpv9c4tsffcxejc3mz4jkcac4qkernmj\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\bibc-host0.23.0" - - "{\"native\":\"mock19jf2y29m2qvgfezcyy5zhq8phfdcysngew508eeumdsg2dyzqrqshlx44z\"}" + - "{\"native\":\"mock1dtw8lua8qpav6x3sngqwd3xqmyvg5q0pnv2lkmajzk0rjkjetm2s2pyq4n\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\nibc-client0.23.0" - - "{\"native\":\"mock1u377ag8ewzrskj6r0pqutnpyvh7hd2yqq6uh3rh2pclex2gzhslsq3frn0\"}" + - "{\"native\":\"mock1l487rfqw2yevhvh4c3dw706mdy9u703zsawq7xt4h9e0h9up9fgqwk620q\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000emodule-factory0.23.0" - - "{\"native\":\"mock10ymkph7y47lmxkyan49cq2yjm5m3n2nk83efppcwwpunx7gs374qg8fkqs\"}" + - "{\"native\":\"mock1wzrl9hf8xukhu7ukx5quted5m5c2vklmr70tg88a0zkduts7f0sqpr58lc\"}" - - "\u0000\u0002cb\u0000\babstract\u0000\u000fversion-control0.23.0" - - "{\"native\":\"mock18aq2nqrm809gdktwetuk6c48c6yj379ptkdeewv6j797xv3j2gssdzgurv\"}" + - "{\"native\":\"mock1tnv2hfx6gqdtelccc57aru3ju8wlff8pslrsfdqn862qjc69gsas0vscja\"}" - - "\u0000\u0002ch\u0000\u0005local\u0000\u0000\u0000\u0000" - - "\"mock183tnnc2hqt8tj677neekarwkmlygw09uqrchq4c2aaauleyxzc3sy9w235\"" + - "\"mock1ys8clus4qf2haemyck0uljz74dj2k8hu4ggfpe7vty6zd5j2982q9sf90k\"" - - "\u0000\u0002ch\u0000\u0005local\u0000\u0000\u0000\u0001" - "\"mock1jdl4tasw0x00k2edyf8656lqxy95gx06h2nt5n8qjzv45yxr5ekq0myk0q\"" - - "\u0000\u0002ch\u0000\u0005local\u0000\u0000\u0000\u0002" @@ -105,4 +105,4 @@ expression: all_storage - - contract_info - "{\"contract\":\"abstract:version-control\",\"version\":\"0.23.0\"}" - - ownership - - "{\"owner\":\"mock16g2rahf5846rxzp3fwlswy08fz8ccuwkgsny9p\",\"pending_owner\":null,\"pending_expiry\":null}" + - "{\"owner\":\"mock14cl2dthqamgucg9sfvv4relp3aa83e40yfzzc8\",\"pending_owner\":null,\"pending_expiry\":null}" From 877fe80ee2f59998143f2a9f091a180c4d1593ef Mon Sep 17 00:00:00 2001 From: Buckram Date: Mon, 7 Oct 2024 18:06:10 +0300 Subject: [PATCH 08/14] protobuf unused dep --- framework/Cargo.lock | 1 - framework/contracts/native/module-factory/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/framework/Cargo.lock b/framework/Cargo.lock index 15a427213..897394d49 100644 --- a/framework/Cargo.lock +++ b/framework/Cargo.lock @@ -422,7 +422,6 @@ dependencies = [ "cw-ownable", "cw-storage-plus 2.0.0", "cw2", - "protobuf", "semver", "serde-cw-value", "speculoos", diff --git a/framework/contracts/native/module-factory/Cargo.toml b/framework/contracts/native/module-factory/Cargo.toml index 6c5efcd37..6e4b43d5e 100644 --- a/framework/contracts/native/module-factory/Cargo.toml +++ b/framework/contracts/native/module-factory/Cargo.toml @@ -29,7 +29,6 @@ cw-storage-plus = { workspace = true } cw2 = { workspace = true } thiserror = { workspace = true } semver = { workspace = true } -protobuf = { workspace = true } abstract-sdk = { workspace = true } abstract-std = { workspace = true } abstract-macros = { workspace = true } From 0f51b1c21a02c417466399527cb12cf47bb3beb4 Mon Sep 17 00:00:00 2001 From: Buckram Date: Tue, 8 Oct 2024 12:26:30 +0300 Subject: [PATCH 09/14] change code coverage tool --- .../abstract-integration-tests/Cargo.toml | 3 ++ .../abstract-integration-tests/src/lib.rs | 1 + .../packages/abstract-interface/Cargo.toml | 3 ++ .../packages/abstract-interface/src/lib.rs | 2 ++ framework/packages/abstract-sdk/Cargo.toml | 4 +-- .../packages/abstract-sdk/src/apis/bank.rs | 32 ++++++++++--------- framework/packages/abstract-sdk/src/lib.rs | 1 - .../packages/abstract-testing/Cargo.toml | 3 ++ .../packages/abstract-testing/src/lib.rs | 2 ++ scripts/framework-coverage.sh | 8 +++-- 10 files changed, 37 insertions(+), 22 deletions(-) diff --git a/framework/packages/abstract-integration-tests/Cargo.toml b/framework/packages/abstract-integration-tests/Cargo.toml index 44ac9cc5e..2b7e92911 100644 --- a/framework/packages/abstract-integration-tests/Cargo.toml +++ b/framework/packages/abstract-integration-tests/Cargo.toml @@ -27,3 +27,6 @@ cw-asset = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] workspace-hack = { version = "0.1", path = "../../workspace-hack" } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/framework/packages/abstract-integration-tests/src/lib.rs b/framework/packages/abstract-integration-tests/src/lib.rs index 1f3c14560..ee6c6495a 100644 --- a/framework/packages/abstract-integration-tests/src/lib.rs +++ b/framework/packages/abstract-integration-tests/src/lib.rs @@ -1,6 +1,7 @@ //! # Testing Functions //! //! This module contains testing functions that can be used in different environments. +#![cfg(not(tarpaulin_include))] pub mod account; pub mod create; diff --git a/framework/packages/abstract-interface/Cargo.toml b/framework/packages/abstract-interface/Cargo.toml index c5cc301ef..77cbbbd33 100644 --- a/framework/packages/abstract-interface/Cargo.toml +++ b/framework/packages/abstract-interface/Cargo.toml @@ -67,3 +67,6 @@ dotenv = "0.15.0" env_logger = "0.11.3" cw-orch = { workspace = true, features = ["daemon"] } cw-orch-interchain = { workspace = true, features = ["daemon"] } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/framework/packages/abstract-interface/src/lib.rs b/framework/packages/abstract-interface/src/lib.rs index eb620aa2b..de06cdf67 100644 --- a/framework/packages/abstract-interface/src/lib.rs +++ b/framework/packages/abstract-interface/src/lib.rs @@ -1,4 +1,6 @@ #![cfg(not(target_arch = "wasm32"))] +#![cfg(not(tarpaulin_include))] + pub const VERSION: &str = env!("CARGO_PKG_VERSION"); mod account; diff --git a/framework/packages/abstract-sdk/Cargo.toml b/framework/packages/abstract-sdk/Cargo.toml index 270e8ec24..d31504569 100644 --- a/framework/packages/abstract-sdk/Cargo.toml +++ b/framework/packages/abstract-sdk/Cargo.toml @@ -54,6 +54,4 @@ abstract-sdk = { path = ".", features = ["test-utils"] } cw-ownable = { workspace = true } [lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = [ - 'cfg(coverage,coverage_nightly)', -] } +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/framework/packages/abstract-sdk/src/apis/bank.rs b/framework/packages/abstract-sdk/src/apis/bank.rs index d26fb8e57..9f37d36ba 100644 --- a/framework/packages/abstract-sdk/src/apis/bank.rs +++ b/framework/packages/abstract-sdk/src/apis/bank.rs @@ -300,21 +300,23 @@ mod test { let (mut deps, account, app) = mock_module_setup(); let env = mock_env_validated(deps.api); - let bank: Bank<'_, MockModule> = app.bank(deps.as_ref(), &env); - let res = bank - .balances(&[AssetEntry::new("asset_entry")]) - .unwrap_err(); - let AbstractSdkError::ApiQuery { - api, - module_id, - error: _, - } = res - else { - panic!("expected api error"); - }; - assert_eq!(api, "Bank"); - assert_eq!(module_id, app.module_id()); - drop(bank); + // API Query Error + { + let bank: Bank<'_, MockModule> = app.bank(deps.as_ref(), &env); + let res = bank + .balances(&[AssetEntry::new("asset_entry")]) + .unwrap_err(); + let AbstractSdkError::ApiQuery { + api, + module_id, + error: _, + } = res + else { + panic!("expected api error"); + }; + assert_eq!(api, "Bank"); + assert_eq!(module_id, app.module_id()); + } let abstr = abstract_testing::prelude::AbstractMockAddrs::new(deps.api); // update querier and balances diff --git a/framework/packages/abstract-sdk/src/lib.rs b/framework/packages/abstract-sdk/src/lib.rs index febfc0b30..6e8c06aa2 100644 --- a/framework/packages/abstract-sdk/src/lib.rs +++ b/framework/packages/abstract-sdk/src/lib.rs @@ -53,5 +53,4 @@ pub mod register { } #[cfg(feature = "test-utils")] -#[cfg_attr(coverage, coverage(off))] pub mod mock_module; diff --git a/framework/packages/abstract-testing/Cargo.toml b/framework/packages/abstract-testing/Cargo.toml index 2d5578fc6..f451c3ecd 100644 --- a/framework/packages/abstract-testing/Cargo.toml +++ b/framework/packages/abstract-testing/Cargo.toml @@ -28,3 +28,6 @@ workspace-hack = { version = "0.1", path = "../../workspace-hack" } [dev-dependencies] abstract-sdk = { path = "../abstract-sdk", features = ["test-utils"] } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/framework/packages/abstract-testing/src/lib.rs b/framework/packages/abstract-testing/src/lib.rs index 5bfdc9e69..dc832953b 100644 --- a/framework/packages/abstract-testing/src/lib.rs +++ b/framework/packages/abstract-testing/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg(not(tarpaulin_include))] + pub(crate) mod abstract_mock_querier; pub mod map_tester; pub mod mock_ans; diff --git a/scripts/framework-coverage.sh b/scripts/framework-coverage.sh index 75dfe13c0..216fa302c 100755 --- a/scripts/framework-coverage.sh +++ b/scripts/framework-coverage.sh @@ -12,8 +12,10 @@ if [ ! -f Cargo.lock ]; then cargo generate-lockfile fi -cargo llvm-cov --workspace --exclude abstract-testing --exclude abstract-integration-tests --exclude abstract-interface \ - --locked --lcov --output-path lcov.info - +# cargo llvm-cov --workspace --exclude abstract-testing --exclude abstract-integration-tests --exclude abstract-interface \ +# --locked --lcov --output-path lcov.info + +cargo tarpaulin --workspace --locked --out Lcov + # print the result. ls -la . From 85e0f45e715e8c350dd005a6a4ad77106788cb86 Mon Sep 17 00:00:00 2001 From: Buckram Date: Tue, 8 Oct 2024 12:30:32 +0300 Subject: [PATCH 10/14] download correct binary --- scripts/framework-coverage.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/framework-coverage.sh b/scripts/framework-coverage.sh index 216fa302c..eac8dd4e9 100755 --- a/scripts/framework-coverage.sh +++ b/scripts/framework-coverage.sh @@ -5,7 +5,8 @@ cd ./framework # Get host target host=$(rustc -Vv | grep host | sed 's/host: //') # # Download binary and install to $HOME/.cargo/bin -curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin +# curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin +curl -LsSf https://github.com/taiki-e/xd009642/tarpaulin/releases/latest/download/cargo-tarpaulin-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin # Create lock file if it does not exist if [ ! -f Cargo.lock ]; then From 21c2516a91f1408fa3fe312d473eca4cc38b3bbd Mon Sep 17 00:00:00 2001 From: Buckram Date: Tue, 8 Oct 2024 12:37:42 +0300 Subject: [PATCH 11/14] tarpaulin misses branches --- .../packages/abstract-integration-tests/Cargo.toml | 3 --- .../packages/abstract-integration-tests/src/lib.rs | 1 - framework/packages/abstract-interface/Cargo.toml | 3 --- framework/packages/abstract-interface/src/lib.rs | 1 - framework/packages/abstract-sdk/Cargo.toml | 3 --- framework/packages/abstract-testing/Cargo.toml | 3 --- framework/packages/abstract-testing/src/lib.rs | 2 -- scripts/framework-coverage.sh | 10 +++++----- 8 files changed, 5 insertions(+), 21 deletions(-) diff --git a/framework/packages/abstract-integration-tests/Cargo.toml b/framework/packages/abstract-integration-tests/Cargo.toml index 2b7e92911..44ac9cc5e 100644 --- a/framework/packages/abstract-integration-tests/Cargo.toml +++ b/framework/packages/abstract-integration-tests/Cargo.toml @@ -27,6 +27,3 @@ cw-asset = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] workspace-hack = { version = "0.1", path = "../../workspace-hack" } - -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/framework/packages/abstract-integration-tests/src/lib.rs b/framework/packages/abstract-integration-tests/src/lib.rs index ee6c6495a..1f3c14560 100644 --- a/framework/packages/abstract-integration-tests/src/lib.rs +++ b/framework/packages/abstract-integration-tests/src/lib.rs @@ -1,7 +1,6 @@ //! # Testing Functions //! //! This module contains testing functions that can be used in different environments. -#![cfg(not(tarpaulin_include))] pub mod account; pub mod create; diff --git a/framework/packages/abstract-interface/Cargo.toml b/framework/packages/abstract-interface/Cargo.toml index 77cbbbd33..c5cc301ef 100644 --- a/framework/packages/abstract-interface/Cargo.toml +++ b/framework/packages/abstract-interface/Cargo.toml @@ -67,6 +67,3 @@ dotenv = "0.15.0" env_logger = "0.11.3" cw-orch = { workspace = true, features = ["daemon"] } cw-orch-interchain = { workspace = true, features = ["daemon"] } - -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/framework/packages/abstract-interface/src/lib.rs b/framework/packages/abstract-interface/src/lib.rs index de06cdf67..ab6a4c265 100644 --- a/framework/packages/abstract-interface/src/lib.rs +++ b/framework/packages/abstract-interface/src/lib.rs @@ -1,5 +1,4 @@ #![cfg(not(target_arch = "wasm32"))] -#![cfg(not(tarpaulin_include))] pub const VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/framework/packages/abstract-sdk/Cargo.toml b/framework/packages/abstract-sdk/Cargo.toml index d31504569..29b10149f 100644 --- a/framework/packages/abstract-sdk/Cargo.toml +++ b/framework/packages/abstract-sdk/Cargo.toml @@ -52,6 +52,3 @@ doc-comment = "0.3.3" # Set our own feature when running tests! abstract-sdk = { path = ".", features = ["test-utils"] } cw-ownable = { workspace = true } - -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/framework/packages/abstract-testing/Cargo.toml b/framework/packages/abstract-testing/Cargo.toml index f451c3ecd..2d5578fc6 100644 --- a/framework/packages/abstract-testing/Cargo.toml +++ b/framework/packages/abstract-testing/Cargo.toml @@ -28,6 +28,3 @@ workspace-hack = { version = "0.1", path = "../../workspace-hack" } [dev-dependencies] abstract-sdk = { path = "../abstract-sdk", features = ["test-utils"] } - -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/framework/packages/abstract-testing/src/lib.rs b/framework/packages/abstract-testing/src/lib.rs index dc832953b..5bfdc9e69 100644 --- a/framework/packages/abstract-testing/src/lib.rs +++ b/framework/packages/abstract-testing/src/lib.rs @@ -1,5 +1,3 @@ -#![cfg(not(tarpaulin_include))] - pub(crate) mod abstract_mock_querier; pub mod map_tester; pub mod mock_ans; diff --git a/scripts/framework-coverage.sh b/scripts/framework-coverage.sh index eac8dd4e9..5416420ba 100755 --- a/scripts/framework-coverage.sh +++ b/scripts/framework-coverage.sh @@ -5,18 +5,18 @@ cd ./framework # Get host target host=$(rustc -Vv | grep host | sed 's/host: //') # # Download binary and install to $HOME/.cargo/bin -# curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin -curl -LsSf https://github.com/taiki-e/xd009642/tarpaulin/releases/latest/download/cargo-tarpaulin-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin +curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin +# curl -LsSf https://github.com/taiki-e/xd009642/tarpaulin/releases/latest/download/cargo-tarpaulin-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin # Create lock file if it does not exist if [ ! -f Cargo.lock ]; then cargo generate-lockfile fi -# cargo llvm-cov --workspace --exclude abstract-testing --exclude abstract-integration-tests --exclude abstract-interface \ -# --locked --lcov --output-path lcov.info +cargo llvm-cov --workspace --exclude abstract-testing --exclude abstract-integration-tests --exclude abstract-interface \ + --locked --lcov --output-path lcov.info -cargo tarpaulin --workspace --locked --out Lcov +# cargo tarpaulin --workspace --locked --out Lcov # print the result. ls -la . From e1aa7bf9eae02c1d59d80bbb78f4008db5ecb3cb Mon Sep 17 00:00:00 2001 From: Buckram Date: Tue, 8 Oct 2024 13:07:32 +0300 Subject: [PATCH 12/14] try nightly coverage --- .circleci/config.yml | 10 ++++++++++ framework/Cargo.lock | 7 +++++++ framework/packages/abstract-sdk/Cargo.toml | 7 +++++++ framework/packages/abstract-sdk/src/apis/adapter.rs | 8 ++++---- framework/packages/abstract-sdk/src/lib.rs | 2 ++ scripts/framework-coverage.sh | 6 +----- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e040528ae..6736e8726 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,6 +4,15 @@ orbs: codecov: codecov/codecov@4.2.0 discord: antonioned/discord@0.1.0 +commands: + rust_install_nightly: + steps: + - run: + name: "Install nightly toolchain" + command: | + rustup toolchain install nightly-x86_64-unknown-linux-gnu + rustup component add llvm-tools-preview + parameters: GHA_Event: type: string @@ -368,6 +377,7 @@ jobs: - image: cimg/rust:1.80.0 resource_class: xlarge steps: + - rust_install_nightly - setup_remote_docker - checkout - run: diff --git a/framework/Cargo.lock b/framework/Cargo.lock index 897394d49..8b3dcb50f 100644 --- a/framework/Cargo.lock +++ b/framework/Cargo.lock @@ -541,6 +541,7 @@ dependencies = [ "cosmos-sdk-proto 0.24.0", "cosmwasm-schema 2.1.4", "cosmwasm-std 2.1.4", + "coverage-helper", "cw-asset", "cw-clearable", "cw-controllers", @@ -1901,6 +1902,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "coverage-helper" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8174551717bb3d1e75935e38d33f5f8ee8f680dd8dd42c90851e6c644faad14e" + [[package]] name = "cpufeatures" version = "0.2.14" diff --git a/framework/packages/abstract-sdk/Cargo.toml b/framework/packages/abstract-sdk/Cargo.toml index 29b10149f..5f690d3b3 100644 --- a/framework/packages/abstract-sdk/Cargo.toml +++ b/framework/packages/abstract-sdk/Cargo.toml @@ -52,3 +52,10 @@ doc-comment = "0.3.3" # Set our own feature when running tests! abstract-sdk = { path = ".", features = ["test-utils"] } cw-ownable = { workspace = true } + +coverage-helper = { version = "0.2.2" } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(coverage,coverage_nightly)', +] } diff --git a/framework/packages/abstract-sdk/src/apis/adapter.rs b/framework/packages/abstract-sdk/src/apis/adapter.rs index 0432881bb..a1e89f4d6 100644 --- a/framework/packages/abstract-sdk/src/apis/adapter.rs +++ b/framework/packages/abstract-sdk/src/apis/adapter.rs @@ -131,7 +131,7 @@ mod tests { use crate::std::adapter; - #[test] + #[coverage_helper::test] fn should_return_err_if_not_dependency() { fail_when_not_dependency_test( |app, deps| { @@ -142,7 +142,7 @@ mod tests { ); } - #[test] + #[coverage_helper::test] fn expected_adapter_request() { let (deps, account, app) = mock_module_setup(); let abstr = AbstractMockAddrs::new(deps.api); @@ -170,7 +170,7 @@ mod tests { mod query_api { use super::*; - #[test] + #[coverage_helper::test] fn should_return_err_if_not_dependency() { fail_when_not_dependency_test( |app, deps| { @@ -181,7 +181,7 @@ mod tests { ); } - #[test] + #[coverage_helper::test] fn expected_adapter_query() { let (deps, _, app) = mock_module_setup(); diff --git a/framework/packages/abstract-sdk/src/lib.rs b/framework/packages/abstract-sdk/src/lib.rs index 6e8c06aa2..264da53ed 100644 --- a/framework/packages/abstract-sdk/src/lib.rs +++ b/framework/packages/abstract-sdk/src/lib.rs @@ -2,6 +2,7 @@ #![doc = include_str ! ("../README.md")] // #![doc(test(attr(warn(unused), deny(warnings), allow(unused_extern_crates, unused),)))] #![warn(missing_docs)] +#![cfg_attr(all(coverage_nightly, test), feature(coverage_attribute))] /// Result returned by the Abstract SDK APIs and features. pub type AbstractSdkResult = Result; @@ -53,4 +54,5 @@ pub mod register { } #[cfg(feature = "test-utils")] +#[cfg_attr(coverage_nightly, coverage(off))] pub mod mock_module; diff --git a/scripts/framework-coverage.sh b/scripts/framework-coverage.sh index 5416420ba..3297e2843 100755 --- a/scripts/framework-coverage.sh +++ b/scripts/framework-coverage.sh @@ -6,17 +6,13 @@ cd ./framework host=$(rustc -Vv | grep host | sed 's/host: //') # # Download binary and install to $HOME/.cargo/bin curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin -# curl -LsSf https://github.com/taiki-e/xd009642/tarpaulin/releases/latest/download/cargo-tarpaulin-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin # Create lock file if it does not exist if [ ! -f Cargo.lock ]; then cargo generate-lockfile fi -cargo llvm-cov --workspace --exclude abstract-testing --exclude abstract-integration-tests --exclude abstract-interface \ - --locked --lcov --output-path lcov.info - -# cargo tarpaulin --workspace --locked --out Lcov +cargo +nightly llvm-cov --all-features --workspace --locked --lcov --output-path lcov.info # print the result. ls -la . From 42bc017905c44359a5b0786b6d1f65d5f4be6590 Mon Sep 17 00:00:00 2001 From: Buckram Date: Tue, 8 Oct 2024 13:16:18 +0300 Subject: [PATCH 13/14] circlecli orb typo --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6736e8726..022c72e60 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,12 +6,12 @@ orbs: commands: rust_install_nightly: - steps: - - run: - name: "Install nightly toolchain" - command: | - rustup toolchain install nightly-x86_64-unknown-linux-gnu - rustup component add llvm-tools-preview + steps: + - run: + name: "Install nightly toolchain" + command: | + rustup toolchain install nightly-x86_64-unknown-linux-gnu + rustup component add llvm-tools-preview parameters: GHA_Event: From 6f5203e5cd9a02e8ebb160d7c85f4b05123e80af Mon Sep 17 00:00:00 2001 From: Buckram Date: Tue, 8 Oct 2024 14:23:02 +0300 Subject: [PATCH 14/14] no coverage feature --- framework/packages/abstract-sdk/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/packages/abstract-sdk/src/lib.rs b/framework/packages/abstract-sdk/src/lib.rs index 264da53ed..f4cfb73e9 100644 --- a/framework/packages/abstract-sdk/src/lib.rs +++ b/framework/packages/abstract-sdk/src/lib.rs @@ -54,5 +54,4 @@ pub mod register { } #[cfg(feature = "test-utils")] -#[cfg_attr(coverage_nightly, coverage(off))] pub mod mock_module;