diff --git a/contracts/liquidity_book/router/Cargo.toml b/contracts/liquidity_book/router/Cargo.toml index 3414a325..e386126d 100644 --- a/contracts/liquidity_book/router/Cargo.toml +++ b/contracts/liquidity_book/router/Cargo.toml @@ -30,3 +30,4 @@ cosmwasm-schema = "1.5" [dev-dependencies] secret-multi-test = { git = "https://github.com/securesecrets/secret-plus-utils", version = "0.13.4", features=["iterator"] } +serial_test = "2.0.0" diff --git a/contracts/liquidity_book/router/src/test.rs b/contracts/liquidity_book/router/src/test.rs index 37f644e7..b10cf022 100644 --- a/contracts/liquidity_book/router/src/test.rs +++ b/contracts/liquidity_book/router/src/test.rs @@ -5,6 +5,7 @@ pub mod tests { state::{config_r, epheral_storage_r, epheral_storage_w, Config, CurrentSwapInfo}, }; use serde::{Deserialize, Serialize}; + use serial_test::serial; use shade_protocol::{ admin::ValidateAdminPermissionResponse, c_std::{ @@ -14,6 +15,7 @@ pub mod tests { Addr, Api, Coin, + ContractResult, Empty, Env, OwnedDeps, @@ -50,6 +52,7 @@ pub mod tests { pub const CUSTOM_TOKEN_1: &str = "secret1h92kweqxaxwwf3wny8qmcalsxe366s940eqd54"; #[test] + #[serial] fn ok_init() -> StdResult<()> { let ref mut deps = mkdeps(); let env = mock_env(); @@ -61,6 +64,7 @@ pub mod tests { } #[test] + #[serial] fn swap_native_for_snip20_tokens_ok() -> StdResult<()> { let (init_result, mut deps) = init_helper(); assert!( @@ -117,6 +121,7 @@ pub mod tests { } #[test] + #[serial] fn swap_snip20_native_for_tokens_ok() -> StdResult<()> { let (init_result, mut deps) = init_helper(); let env = mock_env(); @@ -175,6 +180,7 @@ pub mod tests { } #[test] + #[serial] fn snip20_swap() -> StdResult<()> { let mock_info = mock_info("admin", &[Coin { denom: "uscrt".to_string(), @@ -250,6 +256,7 @@ pub mod tests { } #[test] + #[serial] fn first_swap_callback_with_one_more_ok() -> StdResult<()> { let (init_result, mut deps) = init_helper(); let env = mock_env(); @@ -342,6 +349,7 @@ pub mod tests { } #[test] + #[serial] fn first_swap_callback_with_no_more_ok() -> StdResult<()> { let (init_result, mut deps) = init_helper(); let env = mock_env(); @@ -427,6 +435,7 @@ pub mod tests { } #[test] + #[serial] fn first_swap_callback_with_no_more_not_enough_return() -> StdResult<()> { let (init_result, mut deps) = init_helper(); let env = mock_env(); @@ -579,7 +588,7 @@ pub mod tests { } => { println!("{}", contract_addr); match contract_addr.as_str() { - FACTORY_ADDRESS => QuerierResult::Ok(cosmwasm_std::ContractResult::Ok( + FACTORY_ADDRESS => QuerierResult::Ok(ContractResult::Ok( to_binary(&FactoryQueryResponse::GetConfig { pair_contract: ContractInstantiationInfo { code_hash: "".to_string(), @@ -607,13 +616,13 @@ pub mod tests { }) .unwrap(), )), - "admin_auth" => QuerierResult::Ok(cosmwasm_std::ContractResult::Ok( + "admin_auth" => QuerierResult::Ok(ContractResult::Ok( to_binary(&ValidateAdminPermissionResponse { has_permission: true, }) .unwrap(), )), - PAIR_CONTRACT_1 => QuerierResult::Ok(cosmwasm_std::ContractResult::Ok( + PAIR_CONTRACT_1 => QuerierResult::Ok(ContractResult::Ok( to_binary(&AMMPairQueryMsgResponse::GetPairInfo { liquidity_token: Contract { address: Addr::unchecked("asd"), @@ -662,7 +671,7 @@ pub mod tests { }) .unwrap(), )), - CUSTOM_TOKEN_1 => QuerierResult::Ok(cosmwasm_std::ContractResult::Ok( + CUSTOM_TOKEN_1 => QuerierResult::Ok(ContractResult::Ok( to_binary(&IntBalanceResponse { balance: Balance(Uint128::new(100)), }) diff --git a/contracts/liquidity_book/tests/Cargo.toml b/contracts/liquidity_book/tests/Cargo.toml index 70b6b750..97c2c1cd 100644 --- a/contracts/liquidity_book/tests/Cargo.toml +++ b/contracts/liquidity_book/tests/Cargo.toml @@ -37,3 +37,4 @@ shade-multi-test = { path = "../../../packages/multi_test", features = [ "router", "lb_factory" ] } +serial_test = "2.0.0" diff --git a/contracts/liquidity_book/tests/src/multitests/lb_factory.rs b/contracts/liquidity_book/tests/src/multitests/lb_factory.rs index 44bc3005..3b63fac2 100644 --- a/contracts/liquidity_book/tests/src/multitests/lb_factory.rs +++ b/contracts/liquidity_book/tests/src/multitests/lb_factory.rs @@ -1,10 +1,11 @@ use anyhow::Ok; -use cosmwasm_std::{ContractInfo, StdError}; +use serial_test::serial; use shade_multi_test::{ interfaces::{lb_factory, lb_pair, snip20}, multi::{admin::init_admin_auth, lb_pair::LbPair, lb_token::LbToken}, }; use shade_protocol::{ + c_std::{ContractInfo, StdError}, lb_libraries::{ constants::BASIS_POINT_MAX, math::{ @@ -20,6 +21,7 @@ use shade_protocol::{ use crate::multitests::test_helper::*; #[test] +#[serial] pub fn test_setup() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, _deployed_contracts) = setup(None)?; @@ -42,6 +44,7 @@ pub fn test_setup() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_set_lb_pair_implementation() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, _deployed_contracts) = setup(None)?; @@ -61,6 +64,7 @@ pub fn test_set_lb_pair_implementation() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_set_lb_pair_implementation() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, _deployed_contracts) = setup(None)?; @@ -93,6 +97,7 @@ pub fn test_revert_set_lb_pair_implementation() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_set_lb_token_implementation() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, _deployed_contracts) = setup(None)?; @@ -111,6 +116,7 @@ pub fn test_set_lb_token_implementation() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_create_lb_pair() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, deployed_contracts) = setup(None)?; @@ -199,6 +205,7 @@ pub fn test_create_lb_pair() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_create_lb_pair_factory_unlocked() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, deployed_contracts) = setup(None)?; @@ -290,6 +297,7 @@ pub fn test_create_lb_pair_factory_unlocked() -> Result<(), anyhow::Error> { } #[test] +#[serial] fn test_revert_create_lb_pair() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, deployed_contracts) = setup(None)?; @@ -500,6 +508,7 @@ fn test_revert_create_lb_pair() -> Result<(), anyhow::Error> { } #[test] +#[serial] fn test_fuzz_set_preset() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, _deployed_contracts) = setup(None)?; @@ -575,6 +584,7 @@ fn test_fuzz_set_preset() -> Result<(), anyhow::Error> { } #[test] +#[serial] fn test_remove_preset() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, _deployed_contracts) = setup(None)?; @@ -656,6 +666,7 @@ fn test_remove_preset() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_set_fees_parameters_on_pair() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, deployed_contracts) = setup(None)?; @@ -778,6 +789,7 @@ pub fn test_set_fees_parameters_on_pair() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_set_fee_recipient() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, _deployed_contracts) = setup(None)?; @@ -818,6 +830,7 @@ pub fn test_set_fee_recipient() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_open_presets() -> Result<(), anyhow::Error> { let addrs = init_addrs(); // Initialize addresses let (mut app, lb_factory, _deployed_contracts) = setup(None)?; // Setup @@ -916,6 +929,7 @@ pub fn test_fuzz_open_presets() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_add_quote_asset() -> Result<(), anyhow::Error> { let addrs = init_addrs(); // Initialize addresses let (mut app, lb_factory, mut deployed_contracts) = setup(None)?; // Setup @@ -1032,6 +1046,7 @@ pub fn test_add_quote_asset() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_remove_quote_asset() -> Result<(), anyhow::Error> { let addrs = init_addrs(); // Initialize addresses let (mut app, lb_factory, mut deployed_contracts) = setup(None)?; // Setup @@ -1126,6 +1141,7 @@ pub fn test_remove_quote_asset() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_force_decay() -> Result<(), anyhow::Error> { let addrs = init_addrs(); // Initialize addresses let (mut app, lb_factory, deployed_contracts) = setup(None)?; // Setup @@ -1175,6 +1191,7 @@ pub fn test_force_decay() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_get_all_lb_pair() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, deployed_contracts) = setup(None)?; diff --git a/contracts/liquidity_book/tests/src/multitests/lb_pair_fees.rs b/contracts/liquidity_book/tests/src/multitests/lb_pair_fees.rs index 8f6aeaef..0eccdc04 100644 --- a/contracts/liquidity_book/tests/src/multitests/lb_pair_fees.rs +++ b/contracts/liquidity_book/tests/src/multitests/lb_pair_fees.rs @@ -1,6 +1,5 @@ use anyhow::Ok; -use cosmwasm_std::{ContractInfo, StdError, Uint128, Uint256}; -use ethnum::U256; +use serial_test::serial; use shade_multi_test::interfaces::{ lb_factory, lb_pair, @@ -9,6 +8,7 @@ use shade_multi_test::interfaces::{ utils::DeployedContracts, }; use shade_protocol::{ + c_std::{ContractInfo, StdError, Uint128, Uint256}, lb_libraries::{ math::{encoded_sample::MASK_UINT20, u24::U24}, types::LBPairInformation, @@ -20,7 +20,6 @@ use shade_protocol::{ use crate::multitests::test_helper::*; pub const DEPOSIT_AMOUNT: u128 = 1_000_000_000_000_000_000; - pub const ACTIVE_ID: u32 = ID_ONE; pub fn lb_pair_setup() -> Result< @@ -152,6 +151,7 @@ pub fn lb_pair_setup() -> Result< } #[test] +#[serial] pub fn test_fuzz_swap_in_x() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -268,6 +268,7 @@ pub fn test_fuzz_swap_in_x() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_in_y() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -384,6 +385,7 @@ pub fn test_fuzz_swap_in_y() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_out_for_x() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -501,6 +503,7 @@ pub fn test_fuzz_swap_out_for_x() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_out_for_y() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -619,6 +622,7 @@ pub fn test_fuzz_swap_out_for_y() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_in_x_and_y() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -807,6 +811,7 @@ pub fn test_fuzz_swap_in_x_and_y() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_in_y_and_x() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -996,6 +1001,7 @@ pub fn test_fuzz_swap_in_y_and_x() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_out_x_and_y() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -1183,6 +1189,7 @@ pub fn test_fuzz_swap_out_x_and_y() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_out_y_and_x() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -1369,6 +1376,7 @@ pub fn test_fuzz_swap_out_y_and_x() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fee_x_2_lp() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -1553,6 +1561,7 @@ pub fn test_fee_x_2_lp() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fee_y_2_lp() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -1738,9 +1747,11 @@ pub fn test_fee_y_2_lp() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fees_2lp_flash_loan() {} #[test] +#[serial] pub fn test_collect_protocol_fees_x_tokens() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -1805,6 +1816,7 @@ pub fn test_collect_protocol_fees_x_tokens() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_collect_protocol_fees_y_tokens() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -1869,6 +1881,7 @@ pub fn test_collect_protocol_fees_y_tokens() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_collect_protocol_fees_both_tokens() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -1980,6 +1993,7 @@ pub fn test_collect_protocol_fees_both_tokens() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_collect_protocol_fees_after_swap() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -2157,7 +2171,7 @@ pub fn test_collect_protocol_fees_after_swap() -> Result<(), anyhow::Error> { } #[test] - +#[serial] pub fn test_revert_total_fee_exceeded() -> Result<(), anyhow::Error> { let addrs = init_addrs(); @@ -2217,6 +2231,7 @@ pub fn test_revert_total_fee_exceeded() -> Result<(), anyhow::Error> { } // #[test] +// #[serial] // pub fn test_fuzz_user_fee_swap_in_x() -> Result<(), anyhow::Error> { // let addrs = init_addrs(); // let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; diff --git a/contracts/liquidity_book/tests/src/multitests/lb_pair_initial_state.rs b/contracts/liquidity_book/tests/src/multitests/lb_pair_initial_state.rs index 957b10c9..a04a3cb9 100644 --- a/contracts/liquidity_book/tests/src/multitests/lb_pair_initial_state.rs +++ b/contracts/liquidity_book/tests/src/multitests/lb_pair_initial_state.rs @@ -1,7 +1,8 @@ use anyhow::Ok; -use cosmwasm_std::{ContractInfo, Uint128, Uint256}; +use serial_test::serial; use shade_multi_test::interfaces::{lb_factory, lb_pair, utils::DeployedContracts}; use shade_protocol::{ + c_std::{ContractInfo, Uint128, Uint256}, lb_libraries::{math::u24::U24, oracle_helper::MAX_SAMPLE_LIFETIME, types::LBPairInformation}, multi_test::App, }; @@ -38,6 +39,7 @@ pub fn lb_pair_setup() } #[test] +#[serial] pub fn test_query_factory() -> Result<(), anyhow::Error> { let (app, lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -49,6 +51,7 @@ pub fn test_query_factory() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_token_x() -> Result<(), anyhow::Error> { let (app, _lb_factory, deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -62,6 +65,7 @@ pub fn test_query_token_x() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_token_y() -> Result<(), anyhow::Error> { let (app, _lb_factory, deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -75,6 +79,7 @@ pub fn test_query_token_y() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_bin_step() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -86,6 +91,7 @@ pub fn test_query_bin_step() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_bin_reserves() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -98,6 +104,7 @@ pub fn test_query_bin_reserves() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_active_id() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -109,6 +116,7 @@ pub fn test_query_active_id() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_query_bin() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -122,6 +130,7 @@ pub fn test_fuzz_query_bin() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_next_non_empty_bin() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -140,6 +149,7 @@ pub fn test_query_next_non_empty_bin() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_protocol_fees() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -152,6 +162,7 @@ pub fn test_query_protocol_fees() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_static_fee_parameters() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -180,6 +191,7 @@ pub fn test_query_static_fee_parameters() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_variable_fee_parameters() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -195,6 +207,7 @@ pub fn test_query_variable_fee_parameters() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_oracle_parameters() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -211,6 +224,7 @@ pub fn test_query_oracle_parameters() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_oracle_sample_at() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -225,6 +239,7 @@ pub fn test_query_oracle_sample_at() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_price_from_id() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; let delta = Uint256::from(DEFAULT_BIN_STEP).checked_mul(Uint256::from((5 * 10) ^ 13_u128))?; @@ -295,6 +310,7 @@ pub fn test_query_price_from_id() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_id_from_price() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; let delta = Uint256::from(1u128); @@ -393,6 +409,7 @@ pub fn test_query_id_from_price() -> Result<(), anyhow::Error> { } #[test] +#[serial] fn test_fuzz_query_swap_out() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; @@ -410,6 +427,7 @@ fn test_fuzz_query_swap_out() -> Result<(), anyhow::Error> { } #[test] +#[serial] fn test_fuzz_query_swap_in() -> Result<(), anyhow::Error> { let (app, _lb_factory, _deployed_contracts, lb_pair) = lb_pair_setup()?; diff --git a/contracts/liquidity_book/tests/src/multitests/lb_pair_liquidity.rs b/contracts/liquidity_book/tests/src/multitests/lb_pair_liquidity.rs index c6c219e6..5c050ce4 100644 --- a/contracts/liquidity_book/tests/src/multitests/lb_pair_liquidity.rs +++ b/contracts/liquidity_book/tests/src/multitests/lb_pair_liquidity.rs @@ -1,5 +1,5 @@ use anyhow::Ok; -use cosmwasm_std::{ContractInfo, StdError, Uint128, Uint256}; +use serial_test::serial; use shade_multi_test::interfaces::{ lb_factory, lb_pair, @@ -8,6 +8,7 @@ use shade_multi_test::interfaces::{ utils::DeployedContracts, }; use shade_protocol::{ + c_std::{ContractInfo, StdError, Uint128, Uint256}, lb_libraries::{math::u24::U24, types::LBPairInformation}, liquidity_book::lb_pair::RemoveLiquidity, multi_test::App, @@ -17,7 +18,6 @@ use std::{cmp::Ordering, ops::Add}; use crate::multitests::test_helper::*; pub const PRECISION: u128 = 1_000_000_000_000_000_000; - pub const ACTIVE_ID: u32 = ID_ONE - 24647; pub fn lb_pair_setup() -> Result< @@ -71,6 +71,7 @@ pub fn lb_pair_setup() -> Result< } #[test] +#[serial] pub fn test_simple_mint() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -214,6 +215,7 @@ pub fn test_simple_mint() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_mint_twice() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -354,6 +356,7 @@ pub fn test_mint_twice() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_mint_with_different_bins() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -485,6 +488,7 @@ pub fn test_mint_with_different_bins() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_simple_burn() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -611,6 +615,7 @@ pub fn test_simple_burn() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_burn_half_twice() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -787,6 +792,7 @@ pub fn test_burn_half_twice() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_query_next_non_empty_bin() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -901,6 +907,7 @@ pub fn test_query_next_non_empty_bin() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_mint_zero_shares() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -961,6 +968,7 @@ pub fn test_revert_mint_zero_shares() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_burn_empty_array() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -1111,6 +1119,7 @@ pub fn test_revert_burn_empty_array() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_burn_more_than_balance() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = lb_pair_setup()?; @@ -1197,6 +1206,7 @@ pub fn test_revert_burn_more_than_balance() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_burn_zero() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; diff --git a/contracts/liquidity_book/tests/src/multitests/lb_pair_swap.rs b/contracts/liquidity_book/tests/src/multitests/lb_pair_swap.rs index b6b9002d..2e8efc6d 100644 --- a/contracts/liquidity_book/tests/src/multitests/lb_pair_swap.rs +++ b/contracts/liquidity_book/tests/src/multitests/lb_pair_swap.rs @@ -9,6 +9,7 @@ use super::test_helper::{ ID_ONE, }; use anyhow::Ok; +use serial_test::serial; use cosmwasm_std::{ContractInfo, StdError, Uint128}; use shade_multi_test::interfaces::{ lb_factory, @@ -120,6 +121,7 @@ pub fn lb_pair_setup() -> Result< } #[test] +#[serial] pub fn test_fuzz_swap_in_x() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -182,6 +184,7 @@ pub fn test_fuzz_swap_in_x() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_in_y() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -235,6 +238,7 @@ pub fn test_fuzz_swap_in_y() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_out_for_y() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -290,6 +294,7 @@ pub fn test_fuzz_swap_out_for_y() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_fuzz_swap_out_for_x() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -345,6 +350,7 @@ pub fn test_fuzz_swap_out_for_x() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_swap_insufficient_amount_in() -> Result<(), anyhow::Error> { let addrs = init_addrs(); @@ -390,6 +396,7 @@ pub fn test_revert_swap_insufficient_amount_in() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_swap_insufficient_amount_out() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; @@ -457,6 +464,7 @@ pub fn test_revert_swap_insufficient_amount_out() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_swap_out_of_liquidity() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = lb_pair_setup()?; diff --git a/contracts/liquidity_book/tests/src/multitests/lb_router_integration.rs b/contracts/liquidity_book/tests/src/multitests/lb_router_integration.rs index bc93dabe..914dc51b 100644 --- a/contracts/liquidity_book/tests/src/multitests/lb_router_integration.rs +++ b/contracts/liquidity_book/tests/src/multitests/lb_router_integration.rs @@ -1,4 +1,5 @@ use anyhow::Ok; +use serial_test::serial; use cosmwasm_std::{to_binary, BalanceResponse, BankQuery, Coin, QueryRequest, StdError, Uint128}; use shade_multi_test::interfaces::{ lb_factory, @@ -18,6 +19,7 @@ use crate::multitests::test_helper::*; const SWAP_AMOUNT: u128 = 1000; #[test] +#[serial] pub fn router_integration() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, lb_factory, mut deployed_contracts) = setup(None)?; diff --git a/contracts/liquidity_book/tests/src/multitests/lb_router_register_tokens.rs b/contracts/liquidity_book/tests/src/multitests/lb_router_register_tokens.rs index 29971331..b66ffb76 100644 --- a/contracts/liquidity_book/tests/src/multitests/lb_router_register_tokens.rs +++ b/contracts/liquidity_book/tests/src/multitests/lb_router_register_tokens.rs @@ -1,4 +1,5 @@ use anyhow::Ok; +use serial_test::serial; use cosmwasm_std::Addr; use crate::multitests::test_helper::{SHADE, SILK}; @@ -10,6 +11,7 @@ use shade_multi_test::interfaces::{ }; #[test] +#[serial] pub fn router_registered_tokens() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, mut deployed_contracts) = setup(None)?; diff --git a/contracts/liquidity_book/tests/src/multitests/lb_token.rs b/contracts/liquidity_book/tests/src/multitests/lb_token.rs index da815115..e53f3903 100644 --- a/contracts/liquidity_book/tests/src/multitests/lb_token.rs +++ b/contracts/liquidity_book/tests/src/multitests/lb_token.rs @@ -1,4 +1,5 @@ use std::ops::{Add, Mul}; +use serial_test::serial; use crate::multitests::test_helper::*; @@ -79,6 +80,7 @@ pub fn init_setup() -> Result< } #[test] +#[serial] pub fn test_simple_mint() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = init_setup()?; @@ -158,6 +160,7 @@ pub fn test_simple_mint() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_mint_twice() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = init_setup()?; @@ -269,6 +272,7 @@ pub fn test_mint_twice() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_mint_with_different_bins() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = init_setup()?; @@ -426,6 +430,7 @@ pub fn test_mint_with_different_bins() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_simple_burn() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = init_setup()?; @@ -559,6 +564,7 @@ pub fn test_simple_burn() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_burn_half_twice() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = init_setup()?; @@ -699,6 +705,7 @@ pub fn test_burn_half_twice() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_mint_zero_tokens() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = init_setup()?; @@ -759,6 +766,7 @@ pub fn test_revert_mint_zero_tokens() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_burn_empty_array() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = init_setup()?; @@ -909,6 +917,7 @@ pub fn test_revert_burn_empty_array() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_burn_more_than_balance() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, lb_token) = init_setup()?; @@ -995,6 +1004,7 @@ pub fn test_revert_burn_more_than_balance() -> Result<(), anyhow::Error> { } #[test] +#[serial] pub fn test_revert_burn_zero() -> Result<(), anyhow::Error> { let addrs = init_addrs(); let (mut app, _lb_factory, deployed_contracts, lb_pair, _lb_token) = init_setup()?; diff --git a/packages/shade_protocol/src/contract_interfaces/liquidity_book/lb_libraries/bin_helper.rs b/packages/shade_protocol/src/contract_interfaces/liquidity_book/lb_libraries/bin_helper.rs index 11e93f10..0fd1b23c 100644 --- a/packages/shade_protocol/src/contract_interfaces/liquidity_book/lb_libraries/bin_helper.rs +++ b/packages/shade_protocol/src/contract_interfaces/liquidity_book/lb_libraries/bin_helper.rs @@ -564,15 +564,16 @@ impl BinHelper { #[cfg(test)] mod tests { - use crate::utils::liquidity_book::{ + use super::*; + + use crate::c_std::StdResult; + use ethnum::U256; + use super::super::{ math::encoded_sample::EncodedSample, types::StaticFeeParameters, }; - use cosmwasm_std::StdResult; - use ethnum::U256; use std::str::FromStr; - use super::*; fn assert_approxeq_abs(a: U256, b: U256, max_diff: U256, msg: &str) { let diff = if a > b { a - b } else { b - a }; diff --git a/packages/shade_protocol/src/contract_interfaces/liquidity_book/lb_libraries/math/tree_math.rs b/packages/shade_protocol/src/contract_interfaces/liquidity_book/lb_libraries/math/tree_math.rs index d2d1aaad..0b59ebbc 100644 --- a/packages/shade_protocol/src/contract_interfaces/liquidity_book/lb_libraries/math/tree_math.rs +++ b/packages/shade_protocol/src/contract_interfaces/liquidity_book/lb_libraries/math/tree_math.rs @@ -276,8 +276,6 @@ impl TreeUint24 { #[cfg(test)] mod tests { - use crate::utils::liquidity_book::math::u24::U24; - use super::*; #[test]