From e7a3ed3ea56d40100e13a0bc3bbf5cac8ce6239c Mon Sep 17 00:00:00 2001 From: mpoplavkov Date: Mon, 26 Aug 2024 14:52:38 +0100 Subject: [PATCH] Cargo fmt --- .../tests/cases/revert.rs | 2 +- .../tests/cases/success.rs | 2 +- .../tests/cases/success.rs | 52 ++++++++++++------- .../tests/utils/mod.rs | 11 ++-- test-harness/src/interface.rs | 2 +- test-harness/src/setup.rs | 4 +- 6 files changed, 46 insertions(+), 27 deletions(-) diff --git a/scripts/remove_liquidity_script/tests/cases/revert.rs b/scripts/remove_liquidity_script/tests/cases/revert.rs index 82e6d03..c332b77 100644 --- a/scripts/remove_liquidity_script/tests/cases/revert.rs +++ b/scripts/remove_liquidity_script/tests/cases/revert.rs @@ -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; diff --git a/scripts/remove_liquidity_script/tests/cases/success.rs b/scripts/remove_liquidity_script/tests/cases/success.rs index 5b376c8..af4af1a 100644 --- a/scripts/remove_liquidity_script/tests/cases/success.rs +++ b/scripts/remove_liquidity_script/tests/cases/success.rs @@ -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}; diff --git a/scripts/swap_exact_input_script/tests/cases/success.rs b/scripts/swap_exact_input_script/tests/cases/success.rs index 295b4a5..91c4373 100644 --- a/scripts/swap_exact_input_script/tests/cases/success.rs +++ b/scripts/swap_exact_input_script/tests/cases/success.rs @@ -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}; @@ -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; @@ -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; @@ -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(); @@ -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(); @@ -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; @@ -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; @@ -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; @@ -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; @@ -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, diff --git a/scripts/swap_exact_input_script/tests/utils/mod.rs b/scripts/swap_exact_input_script/tests/utils/mod.rs index ed258ec..77a60b2 100644 --- a/scripts/swap_exact_input_script/tests/utils/mod.rs +++ b/scripts/swap_exact_input_script/tests/utils/mod.rs @@ -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}; @@ -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; @@ -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(); @@ -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), ) } diff --git a/test-harness/src/interface.rs b/test-harness/src/interface.rs index d82f2f3..478779f 100644 --- a/test-harness/src/interface.rs +++ b/test-harness/src/interface.rs @@ -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, diff --git a/test-harness/src/setup.rs b/test-harness/src/setup.rs index 2b81462..27f076f 100644 --- a/test-harness/src/setup.rs +++ b/test-harness/src/setup.rs @@ -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()