Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/v2_contracts' into pool-…
Browse files Browse the repository at this point in the history
…manager-update-config
  • Loading branch information
kaimen-sano committed Apr 16, 2024
2 parents f5d12b9 + ac0184f commit 1ce915b
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 99 deletions.
2 changes: 2 additions & 0 deletions contracts/liquidity_hub/epoch-manager/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use white_whale_std::epoch_manager::epoch_manager::{
};

/// Mocks contract instantiation.
#[allow(dead_code)]
pub(crate) fn mock_instantiation(
deps: DepsMut,
info: MessageInfo,
Expand All @@ -28,6 +29,7 @@ pub(crate) fn mock_instantiation(
}

/// Mocks hook addition.
#[allow(dead_code)]
pub(crate) fn mock_add_hook(deps: DepsMut, info: MessageInfo) -> Result<Response, ContractError> {
let msg = ExecuteMsg::AddHook {
contract_addr: "hook_contract_1".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl TestingSuite {
.unwrap();
}

#[allow(clippy::inconsistent_digit_grouping)]
fn create_epoch_manager(&mut self) {
let epoch_manager_contract = self.app.store_code(epoch_manager_contract());

Expand Down Expand Up @@ -197,6 +198,7 @@ impl TestingSuite {
}

#[track_caller]
#[allow(clippy::too_many_arguments)]
pub(crate) fn instantiate(
&mut self,
whale_lair_addr: String,
Expand Down Expand Up @@ -239,6 +241,7 @@ impl TestingSuite {
}

#[track_caller]
#[allow(clippy::too_many_arguments)]
pub(crate) fn instantiate_err(
&mut self,
whale_lair_addr: String,
Expand Down Expand Up @@ -300,6 +303,7 @@ impl TestingSuite {
}

#[track_caller]
#[allow(clippy::too_many_arguments)]
pub(crate) fn update_config(
&mut self,
sender: Addr,
Expand Down Expand Up @@ -555,7 +559,7 @@ impl TestingSuite {

result(
self.app
.execute_contract(sender, self.epoch_manager_addr.clone(), &msg, &vec![]),
.execute_contract(sender, self.epoch_manager_addr.clone(), &msg, &[]),
);

self
Expand Down Expand Up @@ -584,7 +588,7 @@ impl TestingSuite {
#[track_caller]
pub(crate) fn query_current_epoch(
&mut self,
result: impl Fn(StdResult<EpochResponse>),
mut result: impl FnMut(StdResult<EpochResponse>),
) -> &mut Self {
let current_epoch_response: StdResult<EpochResponse> = self.app.wrap().query_wasm_smart(
&self.epoch_manager_addr,
Expand Down
46 changes: 23 additions & 23 deletions contracts/liquidity_hub/incentive-manager/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
extern crate core;

use std::cell::RefCell;

use cosmwasm_std::{coin, Addr, Coin, Decimal, Uint128};

use incentive_manager::ContractError;
use white_whale_std::incentive_manager::{
Config, Curve, EpochId, Incentive, IncentiveAction, IncentiveParams, IncentivesBy,
LpWeightResponse, Position, PositionAction, RewardsResponse,
Config, Curve, Incentive, IncentiveAction, IncentiveParams, IncentivesBy, LpWeightResponse,
Position, PositionAction, RewardsResponse,
};

use crate::common::suite::TestingSuite;
Expand Down Expand Up @@ -707,6 +705,7 @@ fn expand_incentives() {
}

#[test]
#[allow(clippy::inconsistent_digit_grouping)]
fn close_incentives() {
let lp_denom = "factory/pool/uLP".to_string();

Expand Down Expand Up @@ -790,7 +789,7 @@ fn close_incentives() {
},
)
.query_balance("ulab".to_string(), other.clone(), |balance| {
assert_eq!(balance, Uint128::new(99_999_6000));
assert_eq!(balance, Uint128::new(999_996_000));
})
.manage_incentive(
other.clone(),
Expand All @@ -803,7 +802,7 @@ fn close_incentives() {
},
)
.query_balance("ulab".to_string(), other.clone(), |balance| {
assert_eq!(balance, Uint128::new(100_000_0000));
assert_eq!(balance, Uint128::new(1000_000_000));
});

suite
Expand All @@ -829,7 +828,7 @@ fn close_incentives() {
},
)
.query_balance("ulab".to_string(), other.clone(), |balance| {
assert_eq!(balance, Uint128::new(99_999_6000));
assert_eq!(balance, Uint128::new(999_996_000));
})
// the owner of the contract can also close incentives
.manage_incentive(
Expand All @@ -843,7 +842,7 @@ fn close_incentives() {
},
)
.query_balance("ulab".to_string(), other.clone(), |balance| {
assert_eq!(balance, Uint128::new(100_000_0000));
assert_eq!(balance, Uint128::new(1000_000_000));
});
}

Expand Down Expand Up @@ -1115,15 +1114,16 @@ pub fn update_config() {
}

#[test]
#[allow(clippy::inconsistent_digit_grouping)]
pub fn test_manage_position() {
let lp_denom = "factory/pool/uLP".to_string();

let mut suite = TestingSuite::default_with_balances(vec![
coin(1_000_000_000u128, "uwhale".to_string()),
coin(1_000_000_000u128, "ulab".to_string()),
coin(1_000_000_000u128, "uosmo".to_string()),
coin(1_000_000_000u128, "uwhale"),
coin(1_000_000_000u128, "ulab"),
coin(1_000_000_000u128, "uosmo"),
coin(1_000_000_000u128, lp_denom.clone()),
coin(1_000_000_000u128, "invalid_lp".clone()),
coin(1_000_000_000u128, "invalid_lp"),
]);

let creator = suite.creator();
Expand Down Expand Up @@ -1990,11 +1990,11 @@ fn claim_expired_incentive_returns_nothing() {
let lp_denom = "factory/pool/uLP".to_string();

let mut suite = TestingSuite::default_with_balances(vec![
coin(1_000_000_000u128, "uwhale".to_string()),
coin(1_000_000_000u128, "ulab".to_string()),
coin(1_000_000_000u128, "uosmo".to_string()),
coin(1_000_000_000u128, "uwhale"),
coin(1_000_000_000u128, "ulab"),
coin(1_000_000_000u128, "uosmo"),
coin(1_000_000_000u128, lp_denom.clone()),
coin(1_000_000_000u128, "invalid_lp".clone()),
coin(1_000_000_000u128, "invalid_lp"),
]);

let creator = suite.creator();
Expand Down Expand Up @@ -2136,11 +2136,11 @@ fn test_close_expired_incentives() {
let lp_denom = "factory/pool/uLP".to_string();

let mut suite = TestingSuite::default_with_balances(vec![
coin(1_000_000_000u128, "uwhale".to_string()),
coin(1_000_000_000u128, "ulab".to_string()),
coin(1_000_000_000u128, "uosmo".to_string()),
coin(1_000_000_000u128, "uwhale"),
coin(1_000_000_000u128, "ulab"),
coin(1_000_000_000u128, "uosmo"),
coin(1_000_000_000u128, lp_denom.clone()),
coin(1_000_000_000u128, "invalid_lp".clone()),
coin(1_000_000_000u128, "invalid_lp"),
]);

let creator = suite.creator();
Expand Down Expand Up @@ -2182,18 +2182,18 @@ fn test_close_expired_incentives() {
});
}

let current_id: RefCell<EpochId> = RefCell::new(0u64);
let mut current_id = 0;

// try opening another incentive for the same lp denom, the expired incentive should get closed
suite
.query_current_epoch(|result| {
let epoch_response = result.unwrap();
*current_id.borrow_mut() = epoch_response.epoch.id;
current_id = epoch_response.epoch.id;
})
.query_incentives(None, None, None, |result| {
let incentives_response = result.unwrap();
assert_eq!(incentives_response.incentives.len(), 1);
assert!(incentives_response.incentives[0].is_expired(current_id.borrow().clone()));
assert!(incentives_response.incentives[0].is_expired(current_id));
})
.manage_incentive(
other.clone(),
Expand Down
3 changes: 3 additions & 0 deletions contracts/liquidity_hub/pool-manager/src/tests/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ impl TestingSuite {
}

#[track_caller]
#[allow(clippy::too_many_arguments)]
pub(crate) fn swap(
&mut self,
sender: Addr,
Expand Down Expand Up @@ -289,6 +290,7 @@ impl TestingSuite {
}

#[track_caller]
#[allow(clippy::too_many_arguments)]
pub(crate) fn execute_swap_operations(
&mut self,
sender: Addr,
Expand All @@ -315,6 +317,7 @@ impl TestingSuite {
}

#[track_caller]
#[allow(clippy::too_many_arguments)]
pub(crate) fn create_pair(
&mut self,
sender: Addr,
Expand Down
Loading

0 comments on commit 1ce915b

Please sign in to comment.