Skip to content

Commit

Permalink
fix test dependencies, run some tests in serial
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-3 committed Nov 27, 2023
1 parent bf8cc25 commit a8409f5
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 18 deletions.
1 change: 1 addition & 0 deletions contracts/liquidity_book/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 13 additions & 4 deletions contracts/liquidity_book/router/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -14,6 +15,7 @@ pub mod tests {
Addr,
Api,
Coin,
ContractResult,
Empty,
Env,
OwnedDeps,
Expand Down Expand Up @@ -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();
Expand All @@ -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!(
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -175,6 +180,7 @@ pub mod tests {
}

#[test]
#[serial]
fn snip20_swap() -> StdResult<()> {
let mock_info = mock_info("admin", &[Coin {
denom: "uscrt".to_string(),
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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)),
})
Expand Down
1 change: 1 addition & 0 deletions contracts/liquidity_book/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ shade-multi-test = { path = "../../../packages/multi_test", features = [
"router",
"lb_factory"
] }
serial_test = "2.0.0"
19 changes: 18 additions & 1 deletion contracts/liquidity_book/tests/src/multitests/lb_factory.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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)?;
Expand All @@ -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)?;
Expand All @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand All @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)?;
Expand Down
Loading

0 comments on commit a8409f5

Please sign in to comment.