From 159db8b8eb2dc2333213eeb7cf8a9548c205ca1a Mon Sep 17 00:00:00 2001 From: lubkoll <11710767+lubkoll@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:35:06 +0200 Subject: [PATCH] Add position and tick params to mock_deps_with_querier_with_balance (#832) --- .../osmosis/contracts/cl-vault/src/test_helpers.rs | 9 ++++++--- .../osmosis/contracts/cl-vault/src/vault/range.rs | 13 +++++++++---- .../contracts/cl-vault/src/vault/withdraw.rs | 13 +++++++++---- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/test_helpers.rs b/smart-contracts/osmosis/contracts/cl-vault/src/test_helpers.rs index cd7992c59..fca9fc6fa 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/test_helpers.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/test_helpers.rs @@ -165,6 +165,9 @@ impl Querier for QuasarQuerier { } pub fn mock_deps_with_querier_with_balance( + position_base_amount: u128, + position_quote_amount: u128, + current_tick: i64, balances: &[(&str, &[Coin])], ) -> OwnedDeps { OwnedDeps { @@ -183,11 +186,11 @@ pub fn mock_deps_with_querier_with_balance( }), asset0: Some(OsmoCoin { denom: BASE_DENOM.to_string(), - amount: "1000000".to_string(), + amount: position_base_amount.to_string(), }), asset1: Some(OsmoCoin { denom: QUOTE_DENOM.to_string(), - amount: "1000000".to_string(), + amount: position_quote_amount.to_string(), }), claimable_spread_rewards: vec![ OsmoCoin { @@ -202,7 +205,7 @@ pub fn mock_deps_with_querier_with_balance( claimable_incentives: vec![], forfeited_incentives: vec![], }, - 0, + current_tick, balances, ), custom_query_type: PhantomData, diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs b/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs index 346a01c88..d816ac1a5 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs @@ -372,10 +372,15 @@ mod tests { let info = mock_info("addr0000", &[]); let env = mock_env(); - let mut deps = mock_deps_with_querier_with_balance(&[( - MOCK_CONTRACT_ADDR, - &[coin(11000, BASE_DENOM), coin(11234, QUOTE_DENOM)], - )]); + let mut deps = mock_deps_with_querier_with_balance( + 100_000, + 100_000, + 0, + &[( + MOCK_CONTRACT_ADDR, + &[coin(11000, BASE_DENOM), coin(11234, QUOTE_DENOM)], + )], + ); instantiate_contract(deps.as_mut(), env.clone(), info.sender.as_str()); MODIFY_RANGE_STATE diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/vault/withdraw.rs b/smart-contracts/osmosis/contracts/cl-vault/src/vault/withdraw.rs index e2436b317..cefab1a9b 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/vault/withdraw.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/vault/withdraw.rs @@ -175,10 +175,15 @@ mod tests { #[test] fn execute_withdraw_works_no_rewards() { let info = mock_info("bolice", &[]); - let mut deps = mock_deps_with_querier_with_balance(&[( - MOCK_CONTRACT_ADDR, - &[coin(2000, BASE_DENOM), coin(3000, QUOTE_DENOM)], - )]); + let mut deps = mock_deps_with_querier_with_balance( + 100_000, + 100_000, + 0, + &[( + MOCK_CONTRACT_ADDR, + &[coin(2000, BASE_DENOM), coin(3000, QUOTE_DENOM)], + )], + ); let env = mock_env(); instantiate_contract(deps.as_mut(), env.clone(), info.sender.as_str());