Skip to content

Commit

Permalink
lints and removes unnecessary testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
gangov committed Jul 31, 2024
1 parent 54568ee commit 5150791
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 97 deletions.
7 changes: 2 additions & 5 deletions contracts/pool_stable/src/tests/config.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
extern crate std;
use soroban_sdk::{testutils::Address as _, Address, Env, IntoVal};
use soroban_sdk::{testutils::Address as _, Address, Env};

use super::setup::{deploy_stable_liquidity_pool_contract, deploy_token_contract};
use crate::{
storage::{Config, PairType},
token_contract,
};
use crate::storage::{Config, PairType};

#[test]
fn update_config() {
Expand Down
93 changes: 1 addition & 92 deletions contracts/pool_stable/src/tests/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ fn simple_swap_with_two_tokens_both_with_7_decimals() {
&None,
&Some(spread),
&None::<u64>,
&None,
);
//
// let share_token_address = pool.query_share_token_address();
Expand All @@ -651,95 +652,3 @@ fn simple_swap_with_two_tokens_both_with_7_decimals() {
// assert_eq!(token1.balance(&user), 99);
// assert_eq!(token2.balance(&user), 101);
}

#[test]
fn simple_swap_with_tokens_with_6_8_decimals() {
let env = Env::default();
env.mock_all_auths();
env.budget().reset_unlimited();

let admin = Address::generate(&env);
let manager = Address::generate(&env);
let factory = Address::generate(&env);
let user = Address::generate(&env);

let mut token1 = token_contract::Client::new(
&env,
&env.register_contract_wasm(None, token_contract::WASM),
);

token1.initialize(
&admin,
&6,
&"name1".into_val(&env),
&"symbol1".into_val(&env),
);

let mut token2 = token_contract::Client::new(
&env,
&env.register_contract_wasm(None, token_contract::WASM),
);

token2.initialize(
&admin,
&8,
&"name2".into_val(&env),
&"symbol2".into_val(&env),
);

if token2.address < token1.address {
std::mem::swap(&mut token1, &mut token2);
}

let swap_fees = 0i64;
let pool = deploy_stable_liquidity_pool_contract(
&env,
None,
(&token1.address, &token2.address),
swap_fees,
None,
None,
None,
manager,
factory,
None,
);

token1.mint(&user, &1_100);
token2.mint(&user, &1_100);
pool.provide_liquidity(&user, &1_000, &1_000, &None, &None::<u64>, &None);

let spread = 100i64; // 1% maximum spread allowed
pool.swap(
&user,
&token1.address,
&1,
&None,
&Some(spread),
&None::<u64>,
);

let share_token_address = pool.query_share_token_address();
let result = pool.query_pool_info();

assert_eq!(
result,
PoolResponse {
asset_a: Asset {
address: token1.address.clone(),
amount: 1_001i128,
},
asset_b: Asset {
address: token2.address.clone(),
amount: 999i128,
},
asset_lp_share: Asset {
address: share_token_address.clone(),
amount: 1_000i128,
},
stake_address: pool.query_stake_contract_address(),
}
);
assert_eq!(token1.balance(&user), 99);
assert_eq!(token2.balance(&user), 101);
}

0 comments on commit 5150791

Please sign in to comment.