Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix in test and lint errors #2

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
421 changes: 92 additions & 329 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/cw-placeholder/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
deps: DepsMut,
_deps: DepsMut,
_env: Env,
_info: MessageInfo,
_msg: InstantiateMsg,
Expand Down
8 changes: 4 additions & 4 deletions contracts/factory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use palomadex::common::{
claim_ownership, drop_ownership_proposal, propose_new_owner, validate_addresses,
};
use palomadex::factory::{
ConfigResponse, DistributionFlow, ExecuteMsg, FeeInfoResponse, InstantiateMsg, MigrateMsg,
PairConfig, PairType, PairsResponse, PartialDefaultStakeConfig, PartialStakeConfig, QueryMsg,
ReceiveMsg, ROUTE,
ConfigResponse, DistributionFlow, ExecuteMsg, FeeInfoResponse, InstantiateMsg, PairConfig,
PairType, PairsResponse, PartialDefaultStakeConfig, PartialStakeConfig, QueryMsg, ReceiveMsg,
ROUTE,
};
use palomadex::fee_config::FeeConfig;
use palomadex::stake::UnbondingPeriod;
Expand Down Expand Up @@ -693,8 +693,8 @@ pub fn deregister_pool_and_staking(
Ok(pairs
.unwrap_or_default()
.iter()
.filter(|&pair| pair != pair_addr)
.cloned()
.filter(|pair| pair != pair_addr)
.collect::<Vec<_>>())
},
)?;
Expand Down
91 changes: 2 additions & 89 deletions contracts/factory/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,20 @@ mod factory_helper;
use cosmwasm_std::{attr, from_slice, Addr, Decimal, StdError, Uint128};
use palomadex::asset::AssetInfo;
use palomadex::factory::{
ConfigResponse, DefaultStakeConfig, ExecuteMsg, FeeInfoResponse, InstantiateMsg, MigrateMsg,
PairConfig, PairType, PartialDefaultStakeConfig, QueryMsg,
ConfigResponse, DefaultStakeConfig, ExecuteMsg, FeeInfoResponse, InstantiateMsg, PairConfig,
PairType, PartialDefaultStakeConfig, QueryMsg,
};
use palomadex::fee_config::FeeConfig;
use palomadex::pair::PairInfo;
use palomadex_factory::{error::ContractError, state::Config};

use crate::factory_helper::{instantiate_token, FactoryHelper};
use cw_multi_test::{App, ContractWrapper, Executor};
use cw_placeholder::msg::InstantiateMsg as PlaceholderContractInstantiateMsg;
use palomadex::pair::ExecuteMsg as PairExecuteMsg;
fn mock_app() -> App {
App::default()
}

fn store_placeholder_code(app: &mut App) -> u64 {
let placeholder_contract = Box::new(ContractWrapper::new_with_empty(
cw_placeholder::contract::execute,
cw_placeholder::contract::instantiate,
cw_placeholder::contract::query,
));

app.store_code(placeholder_contract)
}

fn store_factory_code(app: &mut App) -> u64 {
let factory_contract = Box::new(
ContractWrapper::new_with_empty(
Expand Down Expand Up @@ -868,79 +857,3 @@ fn check_update_owner() {

assert_eq!(res.owner, new_owner)
}

#[test]
fn can_migrate_the_placeholder_to_a_factory_properly() {
let mut app = mock_app();

let owner = Addr::unchecked("owner");

let place_holder_id = store_placeholder_code(&mut app);
let factory_id = store_factory_code(&mut app);

let pair_configs = vec![PairConfig {
code_id: 321,
pair_type: PairType::Xyk {},
fee_config: FeeConfig {
total_fee_bps: 100,
protocol_fee_bps: 10,
},
is_disabled: false,
}];
// Instantiate an instance of the placeholder contract which we will migrate
let placeholder = app
.instantiate_contract(
place_holder_id,
owner.clone(),
&PlaceholderContractInstantiateMsg {},
&[],
"placeholder",
Some(owner.clone().into_string()),
)
.unwrap();

let factory_msg = InstantiateMsg {
pair_configs: pair_configs.clone(),
token_code_id: 123,
fee_address: None,
owner: owner.to_string(),
max_referral_commission: Decimal::one(),
default_stake_config: default_stake_config(),
trading_starts: None,
};
// Migrate the contract
app.migrate_contract(
owner.clone(),
placeholder.clone(),
&MigrateMsg::Init(factory_msg.clone()),
factory_id,
)
.unwrap();

// Now instantiate a normal factory directly
let factory_instance = app
.instantiate_contract(
factory_id,
Addr::unchecked(owner.clone()),
&factory_msg,
&[],
"factory",
None,
)
.unwrap();
// To verify we will check configs, confirming its the same ConfigResponse and the same values
let msg = QueryMsg::Config {};
// Query the 'placeholder' which is now a Factory
let migrated_factory_config: ConfigResponse =
app.wrap().query_wasm_smart(&placeholder, &msg).unwrap();
let direct_factory_config: ConfigResponse =
app.wrap().query_wasm_smart(factory_instance, &msg).unwrap();

assert_eq!(123, migrated_factory_config.token_code_id);
assert_eq!(pair_configs, migrated_factory_config.pair_configs);
assert_eq!(owner, migrated_factory_config.owner);

assert_eq!(123, direct_factory_config.token_code_id);
assert_eq!(pair_configs, direct_factory_config.pair_configs);
assert_eq!(owner, direct_factory_config.owner);
}
2 changes: 1 addition & 1 deletion contracts/gauge-adapter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use palomadex::stake::{FundingInfo, ReceiveMsg as StakeReceiveDelegationMsg};
use palomadex_stake::msg::ExecuteMsg as StakeExecuteMsg;

use crate::error::ContractError;
use crate::msg::{AdapterQueryMsg, ExecuteMsg, InstantiateMsg, MigrateMsg};
use crate::msg::{AdapterQueryMsg, ExecuteMsg, InstantiateMsg};
use crate::state::{Config, CONFIG};

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
20 changes: 0 additions & 20 deletions contracts/gauge-adapter/src/multitest/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,6 @@ fn cw20_rewards_work_direct() {
cw20_rewards_work(suite);
}

#[test]
// Like the above test, but here we create the adapter via migration
fn cw20_rewards_work_via_migration() {
let suite = SuiteBuilder::new()
.with_funds("owner", &[])
.with_stake_config(DefaultStakeConfig {
staking_code_id: 0,
tokens_per_power: 1000u128.into(),
min_bond: 1000u128.into(),
unbonding_periods: vec![SECONDS_PER_DAY * 7],
max_distributions: 5,
converter: None,
})
.with_cw20_reward(100)
.via_placeholder()
.build();

cw20_rewards_work(suite);
}

fn cw20_rewards_work(mut suite: Suite) {
// FIXME: how does this work? AssetInfo::to_string() ?? not a cleaner way to unwrap the enum?
let reward_contract = Addr::unchecked(suite.reward.info.to_string());
Expand Down
5 changes: 0 additions & 5 deletions contracts/gauge-adapter/src/multitest/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ impl SuiteBuilder {
self
}

pub fn via_placeholder(mut self) -> Self {
self.via_placeholder = true;
self
}

pub fn with_native_reward(mut self, amount: u128, denom: &str) -> Self {
self.reward = Asset {
amount: amount.into(),
Expand Down
5 changes: 0 additions & 5 deletions contracts/junoswap-staking/.cargo/config

This file was deleted.

49 changes: 0 additions & 49 deletions contracts/junoswap-staking/Cargo.toml

This file was deleted.

11 changes: 0 additions & 11 deletions contracts/junoswap-staking/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions contracts/junoswap-staking/src/bin/schema.rs

This file was deleted.

Loading
Loading