Skip to content

Commit

Permalink
update testing-util
Browse files Browse the repository at this point in the history
  • Loading branch information
tubackkhoa committed Aug 29, 2024
1 parent 68bd423 commit 62a1191
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cw-storage-plus = { version = "1.0.1" }
derive_more = "0.99.17"
decimal-core = { path = "./packages/decimal-core" }
decimal = { path = "./packages/decimal" }
cosmwasm-testing-util = { git = "https://github.com/oraichain/cosmwasm-testing-util.git", rev = "1461172" }
cosmwasm-testing-util = { git = "https://github.com/oraichain/cosmwasm-testing-util.git", rev = "e68faf6" }

[profile.release]
opt-level = 3
Expand Down
43 changes: 8 additions & 35 deletions contracts/oraiswap-v3/src/tests/incentive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn test_create_incentive() {
("alice", &coins(100_000_000_000, FEE_DENOM)),
("bob", &coins(100_000_000_000, FEE_DENOM)),
]);

let alice = &accounts[0];
let bob = &accounts[1];
let dex = create_dex!(app, Percentage::new(0), alice);
Expand Down Expand Up @@ -277,15 +278,11 @@ pub fn test_single_incentive_with_single_position() {
let incentives = new_incentives;
app.increase_time(1000000);
let new_incentives = get_position_incentives!(app, dex, 0, alice).unwrap();
#[cfg(not(feature = "test-tube"))]
let amount = Uint128::from(899500u128);
#[cfg(feature = "test-tube")]
let amount = Uint128::from(900000u128);
assert_eq!(
subtract_assets(&incentives, &new_incentives),
vec![Asset {
info: reward_token.clone(),
amount
amount: 900000u128.into(),
}]
);
}
Expand Down Expand Up @@ -416,16 +413,12 @@ pub fn test_multi_incentives_with_single_position() {
let incentives = new_incentives;
app.increase_time(1000000);
let new_incentives = get_position_incentives!(app, dex, 0, alice).unwrap();
#[cfg(not(feature = "test-tube"))]
let amount = Uint128::from(899500u128);
#[cfg(feature = "test-tube")]
let amount = Uint128::from(900000u128);

assert_eq!(
subtract_assets(&incentives, &new_incentives),
vec![Asset {
info: reward_token.clone(),
amount
amount: 900000u128.into(),
}]
);

Expand Down Expand Up @@ -563,47 +556,31 @@ pub fn test_multi_incentives_with_multi_positions() {
app.increase_time(1000);

let new_incentives = get_position_incentives!(app, dex, 0, alice).unwrap();
#[cfg(not(feature = "test-tube"))]
let amount = 0u128;
#[cfg(feature = "test-tube")]
let amount = 333u128;
assert_eq!(
subtract_assets(&incentives, &new_incentives),
vec![
Asset {
info: reward_token.clone(),
amount: Uint128::from(33500u128 + amount)
amount: Uint128::from(33833u128)
},
Asset {
info: reward_token_2.clone(),
amount: Uint128::from(67000u128 + 2 * amount)
amount: Uint128::from(67666u128)
}
]
);
let new_incentives_2 = get_position_incentives!(app, dex, 1, alice).unwrap();
let amount1;
let amount2;
#[cfg(not(feature = "test-tube"))]
{
amount1 = 0u128;
amount2 = 0u128;
}
#[cfg(feature = "test-tube")]
{
amount1 = 168u128;
amount2 = 334u128;
}

assert_eq!(
subtract_assets(&new_incentives_2, &incentives_2),
vec![
Asset {
info: reward_token.clone(),
amount: Uint128::from(33666u128 + amount1)
amount: Uint128::from(33834u128)
},
Asset {
info: reward_token_2.clone(),
amount: Uint128::from(67333u128 + amount2)
amount: Uint128::from(67667u128)
}
]
);
Expand Down Expand Up @@ -1416,15 +1393,11 @@ pub fn test_update_incentive_with_tick_move_left_to_right() {
let incentive = get_position_incentives!(app, dex, 0, alice).unwrap();
assert_eq!(incentive, vec![]);
let incentive = get_position_incentives!(app, dex, 1, alice).unwrap();
#[cfg(not(feature = "test-tube"))]
let amount = Uint128::from(101000u128);
#[cfg(feature = "test-tube")]
let amount = Uint128::from(100500u128);
assert_eq!(
incentive,
vec![Asset {
info: reward_token.clone(),
amount
amount: Uint128::from(100500u128)
}]
);
}
Expand Down

0 comments on commit 62a1191

Please sign in to comment.