Skip to content

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoplavkov committed Aug 26, 2024
1 parent 24fc174 commit e7a3ed3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 27 deletions.
2 changes: 1 addition & 1 deletion scripts/remove_liquidity_script/tests/cases/revert.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use fuels::prelude::VariableOutputPolicy;
use crate::utils::setup;
use fuels::prelude::VariableOutputPolicy;
use test_harness::interface::scripts::get_transaction_inputs_outputs;
use test_harness::utils::common::MINIMUM_LIQUIDITY;

Expand Down
2 changes: 1 addition & 1 deletion scripts/remove_liquidity_script/tests/cases/success.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use fuels::prelude::VariableOutputPolicy;
use crate::utils::setup;
use fuels::prelude::VariableOutputPolicy;
use test_harness::interface::amm::pool_metadata;
use test_harness::interface::scripts::get_transaction_inputs_outputs;
use test_harness::interface::{Asset, BurnEvent};
Expand Down
52 changes: 34 additions & 18 deletions scripts/swap_exact_input_script/tests/cases/success.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use fuels::prelude::VariableOutputPolicy;
use crate::utils::setup;
use fuels::prelude::VariableOutputPolicy;
use test_harness::interface::amm::pool_metadata;
use test_harness::interface::scripts::get_transaction_inputs_outputs;
use test_harness::utils::common::{pool_assets_balance, MINIMUM_LIQUIDITY};
Expand All @@ -14,7 +14,7 @@ async fn swap_between_two_volatile_tokens() {
_,
wallet,
deadline,
(token_0_id, token_1_id, token_2_id)
(token_0_id, token_1_id, token_2_id),
) = setup().await;

let amount_0_desired: u64 = 1_000_000;
Expand All @@ -23,7 +23,10 @@ async fn swap_between_two_volatile_tokens() {

let (inputs, outputs) = get_transaction_inputs_outputs(
&wallet,
&vec![(token_0_id, amount_0_desired), (token_1_id, amount_1_desired)],
&vec![
(token_0_id, amount_0_desired),
(token_1_id, amount_1_desired),
],
)
.await;

Expand Down Expand Up @@ -52,11 +55,8 @@ async fn swap_between_two_volatile_tokens() {
let token_0_to_swap = 1_000;
let token_1_expected = 996;

let (inputs, outputs) = get_transaction_inputs_outputs(
&wallet,
&vec![(token_0_id, token_0_to_swap)],
)
.await;
let (inputs, outputs) =
get_transaction_inputs_outputs(&wallet, &vec![(token_0_id, token_0_to_swap)]).await;

let wallet_balances_before = pool_assets_balance(&wallet, &pool_id, amm.id).await;
let pool_metadata_before = pool_metadata(&amm.instance, pool_id).await.value.unwrap();
Expand All @@ -78,7 +78,13 @@ async fn swap_between_two_volatile_tokens() {
.unwrap()
.value;

assert_eq!(amounts_out, vec![(token_0_to_swap, token_0_id), (token_1_expected, token_1_id)]);
assert_eq!(
amounts_out,
vec![
(token_0_to_swap, token_0_id),
(token_1_expected, token_1_id)
]
);
let wallet_balances_after = pool_assets_balance(&wallet, &pool_id, amm.id).await;
let pool_metadata_after = pool_metadata(&amm.instance, pool_id).await.value.unwrap();

Expand Down Expand Up @@ -110,7 +116,7 @@ async fn swap_between_three_volatile_tokens() {
pool_id_1,
wallet,
deadline,
(token_0_id, token_1_id, token_2_id)
(token_0_id, token_1_id, token_2_id),
) = setup().await;

let amount_0_desired: u64 = 1_000_000;
Expand All @@ -119,7 +125,10 @@ async fn swap_between_three_volatile_tokens() {

let (inputs, outputs) = get_transaction_inputs_outputs(
&wallet,
&vec![(token_0_id, amount_0_desired), (token_1_id, amount_1_desired)],
&vec![
(token_0_id, amount_0_desired),
(token_1_id, amount_1_desired),
],
)
.await;

Expand Down Expand Up @@ -147,7 +156,10 @@ async fn swap_between_three_volatile_tokens() {

let (inputs, outputs) = get_transaction_inputs_outputs(
&wallet,
&vec![(token_1_id, amount_0_desired), (token_2_id, amount_1_desired)],
&vec![
(token_1_id, amount_0_desired),
(token_2_id, amount_1_desired),
],
)
.await;

Expand Down Expand Up @@ -177,11 +189,8 @@ async fn swap_between_three_volatile_tokens() {
let token_1_expected = 996;
let token_2_expected = 992;

let (inputs, outputs) = get_transaction_inputs_outputs(
&wallet,
&vec![(token_0_id, token_0_to_swap)],
)
.await;
let (inputs, outputs) =
get_transaction_inputs_outputs(&wallet, &vec![(token_0_id, token_0_to_swap)]).await;

let wallet_balances_0_before = pool_assets_balance(&wallet, &pool_id_0, amm.id).await;
let wallet_balances_1_before = pool_assets_balance(&wallet, &pool_id_1, amm.id).await;
Expand Down Expand Up @@ -209,7 +218,14 @@ async fn swap_between_three_volatile_tokens() {
let wallet_balances_0_after = pool_assets_balance(&wallet, &pool_id_0, amm.id).await;
let wallet_balances_1_after = pool_assets_balance(&wallet, &pool_id_1, amm.id).await;

assert_eq!(amounts_out, vec![(token_0_to_swap, pool_id_0.0), (token_1_expected, pool_id_0.1), (token_2_expected, token_2_id)]);
assert_eq!(
amounts_out,
vec![
(token_0_to_swap, pool_id_0.0),
(token_1_expected, pool_id_0.1),
(token_2_expected, token_2_id)
]
);

assert_eq!(
wallet_balances_0_after.asset_a,
Expand Down
11 changes: 7 additions & 4 deletions scripts/swap_exact_input_script/tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use test_harness::interface::mock::{
add_token, deploy_mock_token_contract, get_sub_id, mint_tokens,
};
use test_harness::interface::{
AddLiquidityScript, AddLiquidityScriptConfigurables, SwapExactInputScript, SwapExactInputScriptConfigurables,
AddLiquidityScript, AddLiquidityScriptConfigurables, SwapExactInputScript,
SwapExactInputScriptConfigurables,
};
use test_harness::paths::{ADD_LIQUIDITY_SCRIPT_BINARY_PATH, SWAP_EXACT_INPUT_SCRIPT_BINARY_PATH};
use test_harness::setup::common::{deploy_amm, setup_wallet_and_provider};
Expand All @@ -23,7 +24,7 @@ pub async fn setup() -> (
PoolId,
WalletUnlocked,
u32,
(AssetId, AssetId, AssetId)
(AssetId, AssetId, AssetId),
) {
let (wallet, _asset_ids, provider) =
setup_wallet_and_provider(&WalletAssetConfiguration::default()).await;
Expand All @@ -42,7 +43,9 @@ pub async fn setup() -> (
.value;
let mut all_assets = vec![token_0_id, token_1_id, token_2_id];
all_assets.sort();
let [token_0_id, token_1_id, token_2_id] = all_assets[..] else { todo!() };
let [token_0_id, token_1_id, token_2_id] = all_assets[..] else {
todo!()
};

let token_0_sub_id = get_sub_id(&token_contract, token_0_id).await.value.unwrap();
let token_1_sub_id = get_sub_id(&token_contract, token_1_id).await.value.unwrap();
Expand Down Expand Up @@ -106,6 +109,6 @@ pub async fn setup() -> (
pool_id_1,
wallet,
deadline,
(token_0_id, token_1_id, token_2_id)
(token_0_id, token_1_id, token_2_id),
)
}
2 changes: 1 addition & 1 deletion test-harness/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ abigen!(
);

pub mod amm {
use fuels::types::Identity;
use super::*;
use fuels::types::Identity;

pub async fn initialize_ownership(
contract: &MiraAMM<WalletUnlocked>,
Expand Down
4 changes: 2 additions & 2 deletions test-harness/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub mod common {
};

pub async fn deploy_amm(wallet: &WalletUnlocked) -> MiraAMMContract {
let configuration =
LoadConfiguration::default().with_storage_configuration(StorageConfiguration::default());
let configuration = LoadConfiguration::default()
.with_storage_configuration(StorageConfiguration::default());

let contract_id = Contract::load_from(AMM_CONTRACT_BINARY_PATH, configuration)
.unwrap()
Expand Down

0 comments on commit e7a3ed3

Please sign in to comment.