From dcc90b27c279e125452e19a31fdc8252c8387035 Mon Sep 17 00:00:00 2001 From: Kerber0x Date: Mon, 10 Jun 2024 15:18:45 +0100 Subject: [PATCH] tests: fix tests --- contracts/alliance-hub/src/contract.rs | 6 ++-- contracts/alliance-hub/src/migrations.rs | 6 ---- contracts/alliance-hub/src/tests/assets.rs | 10 +++--- contracts/alliance-hub/src/tests/helpers.rs | 14 ++++---- .../alliance-hub/src/tests/instantiate.rs | 10 +++--- contracts/alliance-hub/src/tests/rewards.rs | 26 +++++++-------- .../alliance-hub/src/tests/stake_unstake.rs | 32 +++++++++---------- contracts/alliance-oracle/src/contract.rs | 14 ++++---- contracts/alliance-oracle/src/tests/mod.rs | 20 ++++++------ .../alliance-oracle/src/tests/test_utils.rs | 4 +-- 10 files changed, 68 insertions(+), 74 deletions(-) diff --git a/contracts/alliance-hub/src/contract.rs b/contracts/alliance-hub/src/contract.rs index 69af1ba..e2d75dc 100644 --- a/contracts/alliance-hub/src/contract.rs +++ b/contracts/alliance-hub/src/contract.rs @@ -219,8 +219,8 @@ fn whitelist_assets( let mut attrs = vec![("action".to_string(), "whitelist_assets".to_string())]; for (chain_id, assets) in &assets_request { for asset in assets { - WHITELIST.save(deps.storage, &asset, chain_id)?; - ASSET_REWARD_RATE.update(deps.storage, &asset, |rate| -> StdResult<_> { + WHITELIST.save(deps.storage, asset, chain_id)?; + ASSET_REWARD_RATE.update(deps.storage, asset, |rate| -> StdResult<_> { Ok(rate.unwrap_or(Decimal::zero())) })?; } @@ -245,7 +245,7 @@ fn remove_assets( // Only allow the governance address to update whitelisted assets is_governance(&info, &config)?; for asset in &assets { - WHITELIST.remove(deps.storage, &asset); + WHITELIST.remove(deps.storage, asset); } let assets_str = assets .iter() diff --git a/contracts/alliance-hub/src/migrations.rs b/contracts/alliance-hub/src/migrations.rs index 44f9f05..bcb83f5 100644 --- a/contracts/alliance-hub/src/migrations.rs +++ b/contracts/alliance-hub/src/migrations.rs @@ -26,7 +26,6 @@ fn migrate_whitelist_map(deps: DepsMut) -> Result<(), ContractError> { let old_map = OLD_WHITELIST .range(deps.storage, None, None, Order::Ascending) - .into_iter() .map(|item| { let (key, value) = item.unwrap(); (key, value) @@ -56,7 +55,6 @@ fn migrate_balances_map(deps: DepsMut) -> Result<(), ContractError> { let old_map = OLD_BALANCES .range(deps.storage, None, None, Order::Ascending) - .into_iter() .map(|item| { let (key, value) = item.unwrap(); (key, value) @@ -87,7 +85,6 @@ fn migrate_total_balances_map(deps: DepsMut) -> Result<(), ContractError> { let old_map = OLD_TOTAL_BALANCES .range(deps.storage, None, None, Order::Ascending) - .into_iter() .map(|item| { let (key, value) = item.unwrap(); (key, value) @@ -151,7 +148,6 @@ fn migrate_asset_reward_rate(deps: DepsMut) -> Result<(), ContractError> { let old_map = OLD_ASSET_REWARD_RATE .range(deps.storage, None, None, Order::Ascending) - .into_iter() .map(|item| { let (key, value) = item.unwrap(); (key, value) @@ -183,7 +179,6 @@ fn migrate_user_asset_reward_rate(deps: DepsMut) -> Result<(), ContractError> { let old_map = OLD_USER_ASSET_REWARD_RATE .range(deps.storage, None, None, Order::Ascending) - .into_iter() .map(|item| { let (key, value) = item.unwrap(); (key, value) @@ -215,7 +210,6 @@ fn migrate_unclaimed_rewards(deps: DepsMut) -> Result<(), ContractError> { let old_map = OLD_UNCLAIMED_REWARDS .range(deps.storage, None, None, Order::Ascending) - .into_iter() .map(|item| { let (key, value) = item.unwrap(); (key, value) diff --git a/contracts/alliance-hub/src/tests/assets.rs b/contracts/alliance-hub/src/tests/assets.rs index 2541e49..c4b76e3 100644 --- a/contracts/alliance-hub/src/tests/assets.rs +++ b/contracts/alliance-hub/src/tests/assets.rs @@ -5,8 +5,8 @@ use crate::state::WHITELIST; use crate::tests::helpers::{remove_assets, setup_contract, whitelist_assets}; use alliance_protocol::alliance_protocol::{ExecuteMsg, QueryMsg, WhitelistedAssetsResponse}; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; -use cosmwasm_std::{from_binary, Response}; -use cw_asset_v2::{AssetInfo, AssetInfoKey}; +use cosmwasm_std::{from_json, Response}; +use cw_asset_v3::AssetInfo; use std::collections::HashMap; #[test] @@ -51,13 +51,13 @@ fn test_whitelist_assets() { let chain_id = WHITELIST .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Native("asset2".to_string())), + &AssetInfo::Native("asset2".to_string()), ) .unwrap(); assert_eq!(chain_id, "chain-1".to_string()); let res: WhitelistedAssetsResponse = - from_binary(&query(deps.as_ref(), mock_env(), QueryMsg::WhitelistedAssets {}).unwrap()) + from_json(&query(deps.as_ref(), mock_env(), QueryMsg::WhitelistedAssets {}).unwrap()) .unwrap(); assert_eq!( res, @@ -116,7 +116,7 @@ fn test_remove_assets() { WHITELIST .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Native("asset1".to_string())), + &AssetInfo::Native("asset1".to_string()), ) .unwrap_err(); } diff --git a/contracts/alliance-hub/src/tests/helpers.rs b/contracts/alliance-hub/src/tests/helpers.rs index 62da047..ad69071 100644 --- a/contracts/alliance-hub/src/tests/helpers.rs +++ b/contracts/alliance-hub/src/tests/helpers.rs @@ -2,10 +2,10 @@ use std::collections::HashMap; use cosmwasm_std::testing::{mock_env, mock_info}; use cosmwasm_std::{ - coin, from_binary, to_binary, Decimal, Deps, DepsMut, Response, StdResult, Uint128, + coin, from_json, to_json_binary, Decimal, Deps, DepsMut, Response, StdResult, Uint128, }; use cw20::Cw20ReceiveMsg; -use cw_asset_v2::{Asset, AssetInfo}; +use cw_asset_v3::{Asset, AssetInfo}; use alliance_protocol::alliance_oracle_types::ChainId; use alliance_protocol::alliance_protocol::{ @@ -77,7 +77,7 @@ pub fn stake_cw20(deps: DepsMut, user: &str, amount: u128, denom: &str) -> Respo let msg = ExecuteMsg::Receive(Cw20ReceiveMsg { sender: user.to_string(), amount: amount.into(), - msg: to_binary(&Cw20HookMsg::Stake {}).unwrap(), + msg: to_json_binary(&Cw20HookMsg::Stake {}).unwrap(), }); execute(deps, env, info, msg).unwrap() } @@ -149,7 +149,7 @@ pub fn claim_rewards(deps: DepsMut, user: &str, denom: &str) -> Response { } pub fn query_rewards(deps: Deps, user: &str, denom: &str) -> PendingRewardsRes { - from_binary( + from_json( &query( deps, mock_env(), @@ -164,7 +164,7 @@ pub fn query_rewards(deps: Deps, user: &str, denom: &str) -> PendingRewardsRes { } pub fn query_all_rewards(deps: Deps, user: &str) -> Vec { - from_binary( + from_json( &query( deps, mock_env(), @@ -178,11 +178,11 @@ pub fn query_all_rewards(deps: Deps, user: &str) -> Vec { } pub fn query_all_staked_balances(deps: Deps) -> Vec { - from_binary(&query(deps, mock_env(), QueryMsg::TotalStakedBalances {}).unwrap()).unwrap() + from_json(&query(deps, mock_env(), QueryMsg::TotalStakedBalances {}).unwrap()).unwrap() } pub fn query_asset_reward_distribution(deps: Deps) -> Vec { - from_binary(&query(deps, mock_env(), QueryMsg::RewardDistribution {}).unwrap()).unwrap() + from_json(&query(deps, mock_env(), QueryMsg::RewardDistribution {}).unwrap()).unwrap() } #[inline] diff --git a/contracts/alliance-hub/src/tests/instantiate.rs b/contracts/alliance-hub/src/tests/instantiate.rs index fc9703b..244a904 100644 --- a/contracts/alliance-hub/src/tests/instantiate.rs +++ b/contracts/alliance-hub/src/tests/instantiate.rs @@ -1,6 +1,6 @@ use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{ - from_binary, Addr, Binary, CosmosMsg, Reply, Response, SubMsg, SubMsgResponse, SubMsgResult, + from_json, Addr, Binary, CosmosMsg, Reply, Response, SubMsg, SubMsgResponse, SubMsgResult, Timestamp, Uint128, }; use terra_proto_rs::traits::MessageExt; @@ -34,7 +34,7 @@ fn test_setup_contract() { // alliance_token_denom and alliance_token_supply // will be populated on reply. let query_config = query(deps.as_ref(), mock_env(), QueryMsg::Config {}).unwrap(); - let config: Config = from_binary(&query_config).unwrap(); + let config: Config = from_json(&query_config).unwrap(); assert_eq!( config, Config { @@ -104,7 +104,7 @@ fn test_reply_create_token() { ); let query_config = query(deps.as_ref(), mock_env(), QueryMsg::Config {}).unwrap(); - let config: Config = from_binary(&query_config).unwrap(); + let config: Config = from_json(&query_config).unwrap(); assert_eq!( config, Config { @@ -132,7 +132,7 @@ fn test_update_config() { oracle, operator, .. - } = from_binary(&query_config).unwrap(); + } = from_json(&query_config).unwrap(); assert_eq!(governance, Addr::unchecked("gov")); assert_eq!(controller, Addr::unchecked("controller")); @@ -192,7 +192,7 @@ fn test_update_config() { oracle, operator, .. - } = from_binary(&query_config).unwrap(); + } = from_json(&query_config).unwrap(); assert_eq!(governance, Addr::unchecked("new_gov")); assert_eq!(controller, Addr::unchecked("new_controller")); diff --git a/contracts/alliance-hub/src/tests/rewards.rs b/contracts/alliance-hub/src/tests/rewards.rs index 3d2e231..26f0903 100644 --- a/contracts/alliance-hub/src/tests/rewards.rs +++ b/contracts/alliance-hub/src/tests/rewards.rs @@ -2,10 +2,10 @@ use std::collections::{HashMap, HashSet}; use cosmwasm_std::testing::{mock_dependencies_with_balance, mock_env, mock_info}; use cosmwasm_std::{ - coin, coins, to_binary, Addr, BankMsg, Binary, CosmosMsg, Decimal, Response, SubMsg, Uint128, - WasmMsg, + coin, coins, to_json_binary, Addr, BankMsg, Binary, CosmosMsg, Decimal, Response, SubMsg, + Uint128, WasmMsg, }; -use cw_asset_v2::{AssetInfo, AssetInfoKey}; +use cw_asset_v3::AssetInfo; use terra_proto_rs::alliance::alliance::MsgClaimDelegationRewards; use terra_proto_rs::traits::Message; @@ -63,7 +63,7 @@ fn test_update_rewards() { SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { funds: vec![], contract_addr: "cosmos2contract".to_string(), - msg: to_binary(&ExecuteMsg::UpdateRewardsCallback {}).unwrap(), + msg: to_json_binary(&ExecuteMsg::UpdateRewardsCallback {}).unwrap(), })), ] ); @@ -107,14 +107,14 @@ fn update_reward_callback() { TOTAL_BALANCES .save( deps.as_mut().storage, - AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &AssetInfo::Native("aWHALE".to_string()), &Uint128::new(1000000), ) .unwrap(); TOTAL_BALANCES .save( deps.as_mut().storage, - AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), + &AssetInfo::Native("bWHALE".to_string()), &Uint128::new(100000), ) .unwrap(); @@ -153,7 +153,7 @@ fn update_reward_callback() { let a_whale_rate = ASSET_REWARD_RATE .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &AssetInfo::Native("aWHALE".to_string()), ) .unwrap(); assert_eq!( @@ -163,7 +163,7 @@ fn update_reward_callback() { let b_whale_rate = ASSET_REWARD_RATE .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Native("bWHALE".to_string())), + &AssetInfo::Native("bWHALE".to_string()), ) .unwrap(); assert_eq!( @@ -173,7 +173,7 @@ fn update_reward_callback() { ASSET_REWARD_RATE .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Native("cMONKEY".to_string())), + &AssetInfo::Native("cMONKEY".to_string()), ) .unwrap_err(); @@ -265,14 +265,14 @@ fn claim_user_rewards() { deps.as_ref().storage, ( Addr::unchecked("user1"), - AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &AssetInfo::Native("aWHALE".to_string()), ), ) .unwrap(); let asset_reward_rate = ASSET_REWARD_RATE .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &AssetInfo::Native("aWHALE".to_string()), ) .unwrap(); assert_eq!(user_reward_rate, asset_reward_rate); @@ -460,7 +460,7 @@ fn claim_rewards_after_staking_and_unstaking() { let prev_rate = ASSET_REWARD_RATE .load( deps.as_mut().storage, - AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &AssetInfo::Native("aWHALE".to_string()), ) .unwrap(); @@ -482,7 +482,7 @@ fn claim_rewards_after_staking_and_unstaking() { let curr_rate = ASSET_REWARD_RATE .load( deps.as_mut().storage, - AssetInfoKey::from(AssetInfo::Native("aWHALE".to_string())), + &AssetInfo::Native("aWHALE".to_string()), ) .unwrap(); assert!(curr_rate > prev_rate); diff --git a/contracts/alliance-hub/src/tests/stake_unstake.rs b/contracts/alliance-hub/src/tests/stake_unstake.rs index 41841b5..81c015a 100644 --- a/contracts/alliance-hub/src/tests/stake_unstake.rs +++ b/contracts/alliance-hub/src/tests/stake_unstake.rs @@ -7,8 +7,8 @@ use crate::tests::helpers::{ }; use alliance_protocol::alliance_protocol::{ExecuteMsg, StakedBalanceRes}; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; -use cosmwasm_std::{coin, to_binary, Addr, BankMsg, CosmosMsg, Response, Uint128, WasmMsg}; -use cw_asset_v2::{Asset, AssetInfo, AssetInfoKey}; +use cosmwasm_std::{coin, to_json_binary, Addr, BankMsg, CosmosMsg, Response, Uint128, WasmMsg}; +use cw_asset_v3::{Asset, AssetInfo}; use std::collections::HashMap; mod cw20_support { @@ -42,7 +42,7 @@ mod cw20_support { deps.as_ref().storage, ( Addr::unchecked("user1"), - AssetInfoKey::from(AssetInfo::Cw20(Addr::unchecked("asset1"))), + &AssetInfo::Cw20(Addr::unchecked("asset1")), ), ) .unwrap(); @@ -64,7 +64,7 @@ mod cw20_support { deps.as_ref().storage, ( Addr::unchecked("user1"), - AssetInfoKey::from(AssetInfo::Cw20(Addr::unchecked("asset1"))), + &AssetInfo::Cw20(Addr::unchecked("asset1")), ), ) .unwrap(); @@ -73,7 +73,7 @@ mod cw20_support { let total_balance = TOTAL_BALANCES .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Cw20(Addr::unchecked("asset1"))), + &AssetInfo::Cw20(Addr::unchecked("asset1")), ) .unwrap(); assert_eq!(total_balance, Uint128::new(200)); @@ -123,7 +123,7 @@ mod cw20_support { ]) .add_message(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: "asset1".into(), - msg: to_binary(&cw20::Cw20ExecuteMsg::Transfer { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::Transfer { recipient: "user1".into(), amount: Uint128::new(50), }) @@ -137,7 +137,7 @@ mod cw20_support { deps.as_ref().storage, ( Addr::unchecked("user1"), - AssetInfoKey::from(AssetInfo::Cw20(Addr::unchecked("asset1".to_string()))), + &AssetInfo::Cw20(Addr::unchecked("asset1")), ), ) .unwrap(); @@ -155,7 +155,7 @@ mod cw20_support { ]) .add_message(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: "asset1".into(), - msg: to_binary(&cw20::Cw20ExecuteMsg::Transfer { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::Transfer { recipient: "user1".into(), amount: Uint128::new(50), }) @@ -169,7 +169,7 @@ mod cw20_support { deps.as_ref().storage, ( Addr::unchecked("user1"), - AssetInfoKey::from(AssetInfo::Cw20(Addr::unchecked("asset1".to_string()))), + &AssetInfo::Cw20(Addr::unchecked("asset1")), ), ) .unwrap(); @@ -178,7 +178,7 @@ mod cw20_support { let total_balance = TOTAL_BALANCES .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Cw20(Addr::unchecked("asset1".to_string()))), + &AssetInfo::Cw20(Addr::unchecked("asset1")), ) .unwrap(); assert_eq!(total_balance, Uint128::new(0)); @@ -212,7 +212,7 @@ fn test_stake() { deps.as_ref().storage, ( Addr::unchecked("user1"), - AssetInfoKey::from(AssetInfo::Native("asset1".to_string())), + &AssetInfo::Native("asset1".to_string()), ), ) .unwrap(); @@ -234,7 +234,7 @@ fn test_stake() { deps.as_ref().storage, ( Addr::unchecked("user1"), - AssetInfoKey::from(AssetInfo::Native("asset1".to_string())), + &AssetInfo::Native("asset1".to_string()), ), ) .unwrap(); @@ -243,7 +243,7 @@ fn test_stake() { let total_balance = TOTAL_BALANCES .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Native("asset1".to_string())), + &AssetInfo::Native("asset1".to_string()), ) .unwrap(); assert_eq!(total_balance, Uint128::new(200)); @@ -329,7 +329,7 @@ fn test_unstake() { deps.as_ref().storage, ( Addr::unchecked("user1"), - AssetInfoKey::from(AssetInfo::Native("asset1".to_string())), + &AssetInfo::Native("asset1".to_string()), ), ) .unwrap(); @@ -356,7 +356,7 @@ fn test_unstake() { deps.as_ref().storage, ( Addr::unchecked("user1"), - AssetInfoKey::from(AssetInfo::Native("asset1".to_string())), + &AssetInfo::Native("asset1".to_string()), ), ) .unwrap(); @@ -365,7 +365,7 @@ fn test_unstake() { let total_balance = TOTAL_BALANCES .load( deps.as_ref().storage, - AssetInfoKey::from(AssetInfo::Native("asset1".to_string())), + &AssetInfo::Native("asset1".to_string()), ) .unwrap(); assert_eq!(total_balance, Uint128::new(0)); diff --git a/contracts/alliance-oracle/src/contract.rs b/contracts/alliance-oracle/src/contract.rs index d52e70a..04c57a8 100644 --- a/contracts/alliance-oracle/src/contract.rs +++ b/contracts/alliance-oracle/src/contract.rs @@ -9,7 +9,7 @@ use alliance_protocol::signed_decimal::{Sign, SignedDecimal}; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, + to_json_binary, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, }; use cw2::set_contract_version; @@ -104,7 +104,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { pub fn get_config(deps: Deps) -> StdResult { let cfg = CONFIG.load(deps.storage)?; - to_binary(&cfg) + to_json_binary(&cfg) } pub fn get_luna_info(deps: Deps, env: Env) -> StdResult { @@ -113,7 +113,7 @@ pub fn get_luna_info(deps: Deps, env: Env) -> StdResult { luna_info.is_expired(cfg.data_expiry_seconds, env.block.time)?; - to_binary(&luna_info) + to_json_binary(&luna_info) } pub fn get_chain_info(deps: Deps, env: Env, chain_id: ChainId) -> StdResult { @@ -123,7 +123,7 @@ pub fn get_chain_info(deps: Deps, env: Env, chain_id: ChainId) -> StdResult StdResult { chain_info.is_expired(cfg.data_expiry_seconds, env.block.time)?; } - to_binary(&chains_info) + to_json_binary(&chains_info) } pub fn get_chains_info_unsafe(deps: Deps) -> StdResult { let chains_info = CHAINS_INFO.load(deps.storage)?; - to_binary(&chains_info) + to_json_binary(&chains_info) } pub fn get_emissions_distribution_info( @@ -237,5 +237,5 @@ pub fn get_emissions_distribution_info( } } - to_binary(&emission_distribution) + to_json_binary(&emission_distribution) } diff --git a/contracts/alliance-oracle/src/tests/mod.rs b/contracts/alliance-oracle/src/tests/mod.rs index 4216a89..9e71f56 100644 --- a/contracts/alliance-oracle/src/tests/mod.rs +++ b/contracts/alliance-oracle/src/tests/mod.rs @@ -6,7 +6,7 @@ use alliance_protocol::alliance_oracle_types::{ }; use alliance_protocol::signed_decimal::SignedDecimal; use cosmwasm_std::{ - from_binary, + from_json, testing::{mock_env, mock_info}, Decimal, Uint128, }; @@ -57,7 +57,7 @@ fn test_update_oracle_data() { // Query the chains info to validate the data was stored correctly in the contract let res = query(deps.as_ref(), mock_env(), QueryMsg::QueryChainsInfo {}).unwrap(); - let res: Vec = from_binary(&res).unwrap(); + let res: Vec = from_json(&res).unwrap(); assert_eq!(1, res.len()); let chain_info = res[0].clone(); @@ -94,7 +94,7 @@ fn test_update_oracle_data() { // Query the Luna info to validate the data was stored correctly in the contract let res = query(deps.as_ref(), mock_env(), QueryMsg::QueryLunaInfo {}).unwrap(); - let luna_info: LunaInfo = from_binary(&res).unwrap(); + let luna_info: LunaInfo = from_json(&res).unwrap(); assert_eq!( Decimal::from_str("0.589013565473308100").unwrap(), luna_info.luna_price @@ -109,7 +109,7 @@ fn test_update_oracle_data() { }, ) .unwrap(); - let chain_info: ChainInfo = from_binary(&res).unwrap(); + let chain_info: ChainInfo = from_json(&res).unwrap(); assert_eq!("chain-1", chain_info.chain_id); assert_eq!( NativeToken { @@ -184,7 +184,7 @@ fn test_emissions_distribution() { )])); let res = query(deps.as_ref(), mock_env(), msg).unwrap(); - let res_parsed: Vec = from_binary(&res).unwrap(); + let res_parsed: Vec = from_json(&res).unwrap(); assert_eq!( res_parsed, vec![EmissionsDistribution { @@ -278,7 +278,7 @@ fn test_emissions_distribution_2() { ])); let res = query(deps.as_ref(), mock_env(), msg).unwrap(); - let res_parsed: Vec = from_binary(&res).unwrap(); + let res_parsed: Vec = from_json(&res).unwrap(); assert_eq!( res_parsed, vec![ @@ -378,7 +378,7 @@ fn test_emissions_distribution_3() { ])); let res = query(deps.as_ref(), mock_env(), msg).unwrap(); - let res_parsed: Vec = from_binary(&res).unwrap(); + let res_parsed: Vec = from_json(&res).unwrap(); assert_eq!( res_parsed, vec![ @@ -495,7 +495,7 @@ fn test_emissions_distribution_4() { ])); let res = query(deps.as_ref(), mock_env(), msg).unwrap(); - let res_parsed: Vec = from_binary(&res).unwrap(); + let res_parsed: Vec = from_json(&res).unwrap(); assert_eq!( res_parsed, vec![ @@ -610,7 +610,7 @@ fn test_emissions_distribution_5() { ])); let res = query(deps.as_ref(), mock_env(), msg).unwrap(); - let res_parsed: Vec = from_binary(&res).unwrap(); + let res_parsed: Vec = from_json(&res).unwrap(); assert_eq!( res_parsed, vec![ @@ -747,7 +747,7 @@ fn test_emissions_distribution_6() { ])); let res = query(deps.as_ref(), mock_env(), msg).unwrap(); - let res_parsed: Vec = from_binary(&res).unwrap(); + let res_parsed: Vec = from_json(&res).unwrap(); assert_eq!( res_parsed, vec![ diff --git a/contracts/alliance-oracle/src/tests/test_utils.rs b/contracts/alliance-oracle/src/tests/test_utils.rs index 296f5a8..c90d731 100644 --- a/contracts/alliance-oracle/src/tests/test_utils.rs +++ b/contracts/alliance-oracle/src/tests/test_utils.rs @@ -1,6 +1,6 @@ use alliance_protocol::alliance_oracle_types::{Config, InstantiateMsg, QueryMsg}; use cosmwasm_std::{ - from_binary, + from_json, testing::{mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage}, Empty, OwnedDeps, }; @@ -19,7 +19,7 @@ pub fn setup_contract() -> OwnedDeps { let cfg = query(deps.as_ref(), mock_env(), QueryMsg::QueryConfig {}).unwrap(); - let cfg: Config = from_binary(&cfg).unwrap(); + let cfg: Config = from_json(&cfg).unwrap(); assert_eq!("controller_addr", cfg.controller_addr); assert_eq!(60, cfg.data_expiry_seconds);