Skip to content

Commit

Permalink
chore: fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x committed May 16, 2024
1 parent e3336f5 commit 0a2b551
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 82 deletions.
1 change: 0 additions & 1 deletion contracts/liquidity_hub/epoch-manager/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub fn create_epoch(deps: DepsMut, env: Env, info: MessageInfo) -> Result<Respon

let mut current_epoch = query_current_epoch(deps.as_ref())?.epoch;
let config = CONFIG.load(deps.storage)?;
println!("----create_epoch----");

ensure!(
env.block.time >= current_epoch.start_time,
Expand Down
46 changes: 23 additions & 23 deletions contracts/liquidity_hub/pool-manager/src/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2701,7 +2701,7 @@ mod locking_lp {
assert_eq!(positions.len(), 1);
assert_eq!(positions[0], Position {
identifier: "1".to_string(),
lp_asset: Coin { denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(999_000u128) },
lp_asset: Coin { denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(999_000u128) },
unlocking_duration: 86_400,
open: true,
expiring_at: None,
Expand Down Expand Up @@ -2753,15 +2753,15 @@ mod locking_lp {
assert_eq!(positions.len(), 2);
assert_eq!(positions[0], Position {
identifier: "1".to_string(),
lp_asset: Coin { denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(999_000u128) },
lp_asset: Coin { denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(999_000u128) },
unlocking_duration: 86_400,
open: true,
expiring_at: None,
receiver: creator.clone(),
});
assert_eq!(positions[1], Position {
identifier: "2".to_string(),
lp_asset: Coin { denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(1_000_000u128) },
lp_asset: Coin { denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(1_000_000u128) },
unlocking_duration: 200_000,
open: true,
expiring_at: None,
Expand Down Expand Up @@ -2897,7 +2897,7 @@ mod locking_lp {
assert_eq!(positions.len(), 1);
assert_eq!(positions[0], Position {
identifier: "incentive_identifier".to_string(),
lp_asset: Coin { denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(999_000u128) },
lp_asset: Coin { denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(999_000u128) },
unlocking_duration: 86_400,
open: true,
expiring_at: None,
Expand Down Expand Up @@ -2950,7 +2950,7 @@ mod locking_lp {
assert_eq!(positions.len(), 1);
assert_eq!(positions[0], Position {
identifier: "incentive_identifier".to_string(),
lp_asset: Coin { denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(1_999_000u128) },
lp_asset: Coin { denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna.uLP".to_string(), amount: Uint128::from(1_999_000u128) },
unlocking_duration: 86_400,
open: true,
expiring_at: None,
Expand Down Expand Up @@ -3775,15 +3775,15 @@ mod multiple_pools {
balances,
vec![
Coin {
denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
amount: Uint128::from(1_000u128),
},
Coin {
denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
amount: Uint128::from(1_000u128),
},
Coin {
denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
amount: Uint128::from(1_000u128),
},
Coin {
Expand Down Expand Up @@ -3830,7 +3830,7 @@ mod multiple_pools {

assert_eq!(pool_info, PoolInfo {
asset_denoms: vec!["uwhale".to_string(), "uluna".to_string()],
lp_denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
lp_denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
asset_decimals: vec![6u8, 6u8],
assets: vec![coin(1001000, "uwhale"), coin(999070, "uluna")],
pool_type: PoolType::ConstantProduct,
Expand Down Expand Up @@ -3873,7 +3873,7 @@ mod multiple_pools {

assert_eq!(pool_info, PoolInfo {
asset_denoms: vec!["uwhale".to_string(), "uluna".to_string()],
lp_denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
lp_denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
asset_decimals: vec![6u8, 6u8],
assets: vec![coin(999_140, "uwhale"), coin(1_001_070, "uluna")],
pool_type: PoolType::ConstantProduct,
Expand Down Expand Up @@ -3926,7 +3926,7 @@ mod multiple_pools {

assert_eq!(pool_info, PoolInfo {
asset_denoms: vec!["uwhale".to_string(), "uluna".to_string()],
lp_denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
lp_denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
asset_decimals: vec![6u8, 6u8],
assets: vec![coin(1001000, "uwhale"), coin(999_150, "uluna")],
pool_type: PoolType::ConstantProduct,
Expand Down Expand Up @@ -3962,7 +3962,7 @@ mod multiple_pools {

assert_eq!(pool_info, PoolInfo {
asset_denoms: vec!["uwhale".to_string(), "uluna".to_string()],
lp_denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
lp_denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
asset_decimals: vec![6u8, 6u8],
assets: vec![coin(999_300, "uwhale"), coin(1_001_150, "uluna")],
pool_type: PoolType::ConstantProduct,
Expand Down Expand Up @@ -4016,7 +4016,7 @@ mod multiple_pools {

assert_eq!(pool_info, PoolInfo {
asset_denoms: vec!["uluna".to_string(), "uusd".to_string()],
lp_denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
lp_denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
asset_decimals: vec![6u8, 6u8],
assets: vec![coin(1003000, "uluna"), coin(997_218, "uusd")],
pool_type: PoolType::ConstantProduct,
Expand Down Expand Up @@ -4057,7 +4057,7 @@ mod multiple_pools {

assert_eq!(pool_info, PoolInfo {
asset_denoms: vec!["uluna".to_string(), "uusd".to_string()],
lp_denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
lp_denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
asset_decimals: vec![6u8, 6u8],
assets: vec![coin(1_001_599, "uluna"), coin(998_718, "uusd")],
pool_type: PoolType::ConstantProduct,
Expand Down Expand Up @@ -4096,15 +4096,15 @@ mod multiple_pools {
let balances = result.unwrap();
assert_eq!(balances, vec![
Coin {
denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
amount: Uint128::from(1_000u128),
},
Coin {
denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
amount: Uint128::from(1_000u128),
},
Coin {
denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
amount: Uint128::from(1_000u128),
},
Coin {
Expand Down Expand Up @@ -4154,7 +4154,7 @@ mod multiple_pools {
// this should have not changed since last time, since we didn't touch this pool
assert_eq!(pool_info, PoolInfo {
asset_denoms: vec!["uwhale".to_string(), "uluna".to_string()],
lp_denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
lp_denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
asset_decimals: vec![6u8, 6u8],
assets: vec![coin(999_140, "uwhale"), coin(1_001_070, "uluna")],
pool_type: PoolType::ConstantProduct,
Expand All @@ -4172,7 +4172,7 @@ mod multiple_pools {

assert_eq!(pool_info, PoolInfo {
asset_denoms: vec!["uwhale".to_string(), "uluna".to_string()],
lp_denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
lp_denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
asset_decimals: vec![6u8, 6u8],
assets: vec![coin(1_004_300, "uwhale"), coin(996_913, "uluna")],
pool_type: PoolType::ConstantProduct,
Expand All @@ -4189,7 +4189,7 @@ mod multiple_pools {

assert_eq!(pool_info, PoolInfo {
asset_denoms: vec!["uluna".to_string(), "uusd".to_string()],
lp_denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
lp_denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
asset_decimals: vec![6u8, 6u8],
assets: vec![coin(1_005_587, "uluna"), coin(995_035, "uusd")],
pool_type: PoolType::ConstantProduct,
Expand Down Expand Up @@ -4224,15 +4224,15 @@ mod multiple_pools {
let balances = result.unwrap();
assert_eq!(balances, vec![
Coin {
denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uluna-uusd.pool.uluna-uusd-pool-1.uLP".to_string(),
amount: Uint128::from(1_000u128),
},
Coin {
denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-1.uLP".to_string(),
amount: Uint128::from(1_000u128),
},
Coin {
denom: "factory/migaloo16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580ws2xujnh/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
denom: "factory/migaloo1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqqhavvl/uwhale-uluna.pool.whale-uluna-pool-2.uLP".to_string(),
amount: Uint128::from(1_000u128),
},
Coin {
Expand Down
63 changes: 6 additions & 57 deletions contracts/liquidity_hub/pool-manager/src/tests/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ impl TestingSuite {

if !bonding_manager_addr.into_string().is_empty() {
let pool_manager_addr = self.pool_manager_addr.clone();
let epoch_manager_addr = self.epoch_manager_addr.clone();

let msg = white_whale_std::bonding_manager::ExecuteMsg::UpdateConfig {
owner: None,
epoch_manager_addr: Some(epoch_manager_addr.into_string()),
pool_manager_addr: Some(pool_manager_addr.into_string()),
unbonding_period: None,
growth_rate: None,
Expand All @@ -212,8 +213,8 @@ impl TestingSuite {

#[track_caller]
pub(crate) fn instantiate_default(&mut self) -> &mut Self {
self.create_bonding_manager();
self.create_epoch_manager();
self.create_bonding_manager();
self.create_incentive_manager();
self.add_hook(self.incentive_manager_addr.clone());
self.add_hook(self.bonding_manager_addr.clone());
Expand All @@ -230,13 +231,15 @@ impl TestingSuite {

fn create_bonding_manager(&mut self) {
let bonding_manager_id = self.app.store_code(bonding_manager_contract());
let epoch_manager_addr = self.epoch_manager_addr.to_string();

let msg = white_whale_std::bonding_manager::InstantiateMsg {
distribution_denom: "uwhale".to_string(),
unbonding_period: Uint64::new(86400u64),
unbonding_period: 86_400u64,
growth_rate: Decimal::one(),
bonding_assets: vec!["bWHALE".to_string(), "ampWHALE".to_string()],
grace_period: Default::default(),
epoch_manager_addr,
};

let creator = self.creator().clone();
Expand Down Expand Up @@ -283,8 +286,6 @@ impl TestingSuite {
}

fn add_hook(&mut self, contract: Addr) {
let epoch_manager_id = self.app.store_code(epoch_manager_contract());

let msg = white_whale_std::epoch_manager::epoch_manager::ExecuteMsg::AddHook {
contract_addr: contract.to_string(),
};
Expand Down Expand Up @@ -530,58 +531,6 @@ impl TestingSuite {
self
}

/// Adds swap routes to the pool manager contract.
#[track_caller]
pub(crate) fn add_swap_routes_default(
&mut self,
sender: Addr,
result: impl Fn(Result<AppResponse, anyhow::Error>),
) -> &mut Self {
let swap_routes = vec![
SwapRoute {
offer_asset_denom: "uluna".to_string(),
ask_asset_denom: "uwhale".to_string(),
swap_operations: vec![
SwapOperation::WhaleSwap {
token_in_denom: "uwhale".to_string(),
token_out_denom: "uluna".to_string(),
pool_identifier: "whale-uluna".to_string(),
},
SwapOperation::WhaleSwap {
token_in_denom: "uluna".to_string(),
token_out_denom: "uusd".to_string(),
pool_identifier: "uluna-uusd".to_string(),
},
],
},
SwapRoute {
offer_asset_denom: "uwhale".to_string(),
ask_asset_denom: "uusd".to_string(),
swap_operations: vec![
SwapOperation::WhaleSwap {
token_in_denom: "uwhale".to_string(),
token_out_denom: "uluna".to_string(),
pool_identifier: "whale-uluna".to_string(),
},
SwapOperation::WhaleSwap {
token_in_denom: "uluna".to_string(),
token_out_denom: "uusd".to_string(),
pool_identifier: "uluna-uusd".to_string(),
},
],
},
];

result(self.app.execute_contract(
sender,
self.pool_manager_addr.clone(),
&white_whale_std::pool_manager::ExecuteMsg::AddSwapRoutes { swap_routes },
&[],
));

self
}

/// Removes swap routes from the pool manager contract.
#[track_caller]
pub(crate) fn remove_swap_routes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ impl TestingSuite {
result: impl Fn(Result<AppResponse, anyhow::Error>),
) -> &mut Self {
let msg = white_whale_std::pool_network::incentive::ExecuteMsg::Claim {};
println!("-------------- claiming {}", sender);
result(self.app.execute_contract(sender, incentive_addr, &msg, &[]));

self
Expand Down

0 comments on commit 0a2b551

Please sign in to comment.