diff --git a/.cargo/audit.toml b/.cargo/audit.toml index 80dec5a81..65c70990d 100644 --- a/.cargo/audit.toml +++ b/.cargo/audit.toml @@ -3,4 +3,4 @@ [advisories] # Ignore the following advisory IDs. # RUSTSEC-2022-0093 is reported for test-tube which is only used for testing. -ignore = ["RUSTSEC-2022-0093"] \ No newline at end of file +ignore = ["RUSTSEC-2022-0093", "RUSTSEC-2023-0052"] \ No newline at end of file diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 010df50c6..e876778b7 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -29,15 +29,11 @@ jobs: - name: Compile workspace run: cargo make build - - name: Run test - run: cargo make test - - # disabled because of "no space left" error. - # - name: Run test coverage - # run: cargo make coverage-lcov - - # - name: Upload coverage to Codecov - # uses: codecov/codecov-action@v3 - # with: - # token: ${{ secrets.CODECOV_TOKEN }} - # files: target/coverage/lcov.info + - name: Run test coverage + run: cargo make coverage-lcov + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: target/coverage/lcov.info diff --git a/contracts/address-provider/tests/all_tests.rs b/contracts/address-provider/tests/all_tests.rs new file mode 100644 index 000000000..14f00389d --- /dev/null +++ b/contracts/address-provider/tests/all_tests.rs @@ -0,0 +1 @@ +mod tests; diff --git a/contracts/address-provider/tests/helpers.rs b/contracts/address-provider/tests/tests/helpers/mod.rs similarity index 100% rename from contracts/address-provider/tests/helpers.rs rename to contracts/address-provider/tests/tests/helpers/mod.rs diff --git a/contracts/address-provider/tests/tests/mod.rs b/contracts/address-provider/tests/tests/mod.rs new file mode 100644 index 000000000..d89823fb5 --- /dev/null +++ b/contracts/address-provider/tests/tests/mod.rs @@ -0,0 +1,5 @@ +mod helpers; + +mod test_addresses; +mod test_instantiate; +mod test_update_owner; diff --git a/contracts/address-provider/tests/test_addresses.rs b/contracts/address-provider/tests/tests/test_addresses.rs similarity index 98% rename from contracts/address-provider/tests/test_addresses.rs rename to contracts/address-provider/tests/tests/test_addresses.rs index be3d1b1ae..ced40337a 100644 --- a/contracts/address-provider/tests/test_addresses.rs +++ b/contracts/address-provider/tests/tests/test_addresses.rs @@ -5,9 +5,7 @@ use mars_red_bank_types::address_provider::{ AddressResponseItem, ExecuteMsg, MarsAddressType, QueryMsg, }; -use crate::helpers::{th_query, th_setup}; - -mod helpers; +use super::helpers::{th_query, th_setup}; #[test] fn setting_address_if_unauthorized() { diff --git a/contracts/address-provider/tests/test_instantiate.rs b/contracts/address-provider/tests/tests/test_instantiate.rs similarity index 96% rename from contracts/address-provider/tests/test_instantiate.rs rename to contracts/address-provider/tests/tests/test_instantiate.rs index d075a9ce8..71c36766c 100644 --- a/contracts/address-provider/tests/test_instantiate.rs +++ b/contracts/address-provider/tests/tests/test_instantiate.rs @@ -2,9 +2,7 @@ use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use mars_address_provider::{contract::instantiate, error::ContractError}; use mars_red_bank_types::address_provider::{ConfigResponse, InstantiateMsg, QueryMsg}; -use crate::helpers::th_query; - -mod helpers; +use super::helpers::th_query; #[test] fn invalid_chain_prefix() { diff --git a/contracts/address-provider/tests/test_update_owner.rs b/contracts/address-provider/tests/tests/test_update_owner.rs similarity index 97% rename from contracts/address-provider/tests/test_update_owner.rs rename to contracts/address-provider/tests/tests/test_update_owner.rs index 511aefdca..a61716795 100644 --- a/contracts/address-provider/tests/test_update_owner.rs +++ b/contracts/address-provider/tests/tests/test_update_owner.rs @@ -3,9 +3,7 @@ use mars_address_provider::{contract::execute, error::ContractError}; use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; use mars_red_bank_types::address_provider::{ConfigResponse, ExecuteMsg, QueryMsg}; -use crate::helpers::{th_query, th_setup}; - -mod helpers; +use super::helpers::{th_query, th_setup}; #[test] fn initialized_state() { diff --git a/contracts/incentives/tests/all_tests.rs b/contracts/incentives/tests/all_tests.rs new file mode 100644 index 000000000..14f00389d --- /dev/null +++ b/contracts/incentives/tests/all_tests.rs @@ -0,0 +1 @@ +mod tests; diff --git a/contracts/incentives/tests/helpers.rs b/contracts/incentives/tests/tests/helpers/mod.rs similarity index 100% rename from contracts/incentives/tests/helpers.rs rename to contracts/incentives/tests/tests/helpers/mod.rs diff --git a/contracts/incentives/tests/tests/mod.rs b/contracts/incentives/tests/tests/mod.rs new file mode 100644 index 000000000..85b241bca --- /dev/null +++ b/contracts/incentives/tests/tests/mod.rs @@ -0,0 +1,10 @@ +mod helpers; + +mod test_admin; +mod test_balance_change; +mod test_claim_rewards; +mod test_indices_usage; +mod test_quering; +mod test_set_asset_incentive; +mod test_update_owner; +mod test_whitelist; diff --git a/contracts/incentives/tests/test_admin.rs b/contracts/incentives/tests/tests/test_admin.rs similarity index 98% rename from contracts/incentives/tests/test_admin.rs rename to contracts/incentives/tests/tests/test_admin.rs index fc0807433..628272a19 100644 --- a/contracts/incentives/tests/test_admin.rs +++ b/contracts/incentives/tests/tests/test_admin.rs @@ -10,9 +10,7 @@ use mars_owner::OwnerError::NotOwner; use mars_red_bank_types::incentives::{ConfigResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; use mars_testing::mock_dependencies; -use crate::helpers::{th_query, th_setup}; - -mod helpers; +use super::helpers::{th_query, th_setup}; #[test] fn proper_initialization() { diff --git a/contracts/incentives/tests/test_balance_change.rs b/contracts/incentives/tests/tests/test_balance_change.rs similarity index 99% rename from contracts/incentives/tests/test_balance_change.rs rename to contracts/incentives/tests/tests/test_balance_change.rs index 07b49c8e8..e68a68458 100644 --- a/contracts/incentives/tests/test_balance_change.rs +++ b/contracts/incentives/tests/tests/test_balance_change.rs @@ -15,9 +15,7 @@ use mars_red_bank_types::{ }; use mars_testing::MockEnvParams; -use crate::helpers::{th_setup, ths_setup_with_epoch_duration}; - -mod helpers; +use super::helpers::{th_setup, ths_setup_with_epoch_duration}; #[test] fn balance_change_unauthorized() { diff --git a/contracts/incentives/tests/test_claim_rewards.rs b/contracts/incentives/tests/tests/test_claim_rewards.rs similarity index 99% rename from contracts/incentives/tests/test_claim_rewards.rs rename to contracts/incentives/tests/tests/test_claim_rewards.rs index af545c28d..bb090bde1 100644 --- a/contracts/incentives/tests/test_claim_rewards.rs +++ b/contracts/incentives/tests/tests/test_claim_rewards.rs @@ -14,9 +14,7 @@ use mars_red_bank_types::{ }; use mars_testing::MockEnvParams; -use crate::helpers::{th_setup, ths_setup_with_epoch_duration}; - -mod helpers; +use super::helpers::{th_setup, ths_setup_with_epoch_duration}; #[test] fn execute_claim_rewards() { diff --git a/contracts/incentives/tests/test_indices_usage.rs b/contracts/incentives/tests/tests/test_indices_usage.rs similarity index 99% rename from contracts/incentives/tests/test_indices_usage.rs rename to contracts/incentives/tests/tests/test_indices_usage.rs index 78a2ce8e0..e57ae7026 100644 --- a/contracts/incentives/tests/test_indices_usage.rs +++ b/contracts/incentives/tests/tests/test_indices_usage.rs @@ -11,8 +11,6 @@ use mars_incentives::{ }; use mars_red_bank_types::incentives::{Config, IncentiveState}; -mod helpers; - fn store_config_with_epoch_duration(storage: &mut dyn Storage, epoch_duration: u64) { CONFIG .save( diff --git a/contracts/incentives/tests/test_quering.rs b/contracts/incentives/tests/tests/test_quering.rs similarity index 92% rename from contracts/incentives/tests/test_quering.rs rename to contracts/incentives/tests/tests/test_quering.rs index c041f5a21..ba4a12f5c 100644 --- a/contracts/incentives/tests/test_quering.rs +++ b/contracts/incentives/tests/tests/test_quering.rs @@ -6,9 +6,7 @@ use mars_red_bank_types::incentives::{ use mars_testing::{mock_env, MockEnvParams}; use test_case::test_case; -use crate::helpers::th_setup; - -mod helpers; +use super::helpers::{th_query, th_query_with_env, th_setup}; #[test] fn query_incentive_state() { @@ -31,7 +29,7 @@ fn query_incentive_state() { }; INCENTIVE_STATES.save(deps.as_mut().storage, ("uusdc", "umars"), &uusdc_incentive).unwrap(); - let res: IncentiveStateResponse = helpers::th_query( + let res: IncentiveStateResponse = th_query( deps.as_ref(), QueryMsg::IncentiveState { collateral_denom: "uatom".to_string(), @@ -66,7 +64,7 @@ fn query_incentive_states() { INCENTIVE_STATES.save(deps.as_mut().storage, ("uusdc", "umars"), &uusdc_incentive).unwrap(); // NOTE: responses are ordered alphabetically by denom - let res: Vec = helpers::th_query( + let res: Vec = th_query( deps.as_ref(), QueryMsg::IncentiveStates { start_after_collateral_denom: None, @@ -88,7 +86,7 @@ fn query_incentive_states() { ); // NOTE: responses are ordered alphabetically by denom - let res: Vec = helpers::th_query( + let res: Vec = th_query( deps.as_ref(), QueryMsg::IncentiveStates { start_after_collateral_denom: Some("uatom".to_string()), @@ -116,7 +114,7 @@ fn query_emission() { .unwrap(); // Query before emission start - let res: Uint128 = helpers::th_query( + let res: Uint128 = th_query( deps.as_ref(), QueryMsg::Emission { collateral_denom: "uosmo".to_string(), @@ -127,7 +125,7 @@ fn query_emission() { assert_eq!(res, Uint128::zero()); // Query at timestamp of first emission start - let res: Uint128 = helpers::th_query( + let res: Uint128 = th_query( deps.as_ref(), QueryMsg::Emission { collateral_denom: "uosmo".to_string(), @@ -138,7 +136,7 @@ fn query_emission() { assert_eq!(res, Uint128::new(100)); // Query at timestamp of second emission start - let res: Uint128 = helpers::th_query( + let res: Uint128 = th_query( deps.as_ref(), QueryMsg::Emission { collateral_denom: "uosmo".to_string(), @@ -149,7 +147,7 @@ fn query_emission() { assert_eq!(res, Uint128::new(50)); // Query one second before second emission start - let res: Uint128 = helpers::th_query( + let res: Uint128 = th_query( deps.as_ref(), QueryMsg::Emission { collateral_denom: "uosmo".to_string(), @@ -160,7 +158,7 @@ fn query_emission() { assert_eq!(res, Uint128::new(100)); // Query at timestamp some time into second emission start - let res: Uint128 = helpers::th_query( + let res: Uint128 = th_query( deps.as_ref(), QueryMsg::Emission { collateral_denom: "uosmo".to_string(), @@ -171,7 +169,7 @@ fn query_emission() { assert_eq!(res, Uint128::new(50)); // Query the second before emission end - let res: Uint128 = helpers::th_query( + let res: Uint128 = th_query( deps.as_ref(), QueryMsg::Emission { collateral_denom: "uosmo".to_string(), @@ -182,7 +180,7 @@ fn query_emission() { assert_eq!(res, Uint128::new(50)); // Query the second after emission end - let res: Uint128 = helpers::th_query( + let res: Uint128 = th_query( deps.as_ref(), QueryMsg::Emission { collateral_denom: "uosmo".to_string(), @@ -203,7 +201,7 @@ fn query_emissions() { .save(deps.as_mut().storage, ("uusdc", "umars", 604800 * 2), &Uint128::new(50)) .unwrap(); - let res: Vec = helpers::th_query( + let res: Vec = th_query( deps.as_ref(), QueryMsg::Emissions { collateral_denom: "uusdc".to_string(), @@ -221,7 +219,7 @@ fn query_emissions() { ] ); - let res: Vec = helpers::th_query( + let res: Vec = th_query( deps.as_ref(), QueryMsg::Emissions { collateral_denom: "uusdc".to_string(), @@ -238,7 +236,7 @@ fn query_emissions() { ] ); - let res: Vec = helpers::th_query( + let res: Vec = th_query( deps.as_ref(), QueryMsg::Emissions { collateral_denom: "uusdc".to_string(), @@ -297,7 +295,7 @@ fn query_active_emissions(query_at_time: u64) -> Vec<(String, Uint128)> { .save(deps.as_mut().storage, ("uusdc", "uosmo", 604800 * 2), &Uint128::new(100)) .unwrap(); - helpers::th_query_with_env::>( + th_query_with_env::>( deps.as_ref(), mock_env(MockEnvParams { block_time: Timestamp::from_seconds(query_at_time), diff --git a/contracts/incentives/tests/test_set_asset_incentive.rs b/contracts/incentives/tests/tests/test_set_asset_incentive.rs similarity index 99% rename from contracts/incentives/tests/test_set_asset_incentive.rs rename to contracts/incentives/tests/tests/test_set_asset_incentive.rs index a508b1706..bf24c9d07 100644 --- a/contracts/incentives/tests/test_set_asset_incentive.rs +++ b/contracts/incentives/tests/tests/test_set_asset_incentive.rs @@ -12,12 +12,10 @@ use mars_red_bank_types::{incentives::ExecuteMsg, red_bank::Market}; use mars_testing::MockEnvParams; use mars_utils::error::ValidationError; -use crate::helpers::{ +use super::helpers::{ th_setup, th_setup_with_env, th_whitelist_denom, ths_setup_with_epoch_duration, }; -mod helpers; - const ONE_WEEK_IN_SECS: u64 = 604800; #[test] diff --git a/contracts/incentives/tests/test_update_owner.rs b/contracts/incentives/tests/tests/test_update_owner.rs similarity index 97% rename from contracts/incentives/tests/test_update_owner.rs rename to contracts/incentives/tests/tests/test_update_owner.rs index 00b7dc4ba..3989240ad 100644 --- a/contracts/incentives/tests/test_update_owner.rs +++ b/contracts/incentives/tests/tests/test_update_owner.rs @@ -3,9 +3,7 @@ use mars_incentives::{contract::execute, ContractError}; use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; use mars_red_bank_types::incentives::{ConfigResponse, ExecuteMsg, QueryMsg}; -use crate::helpers::{th_query, th_setup}; - -mod helpers; +use super::helpers::{th_query, th_setup}; #[test] fn initialized_state() { diff --git a/contracts/incentives/tests/test_whitelist.rs b/contracts/incentives/tests/tests/test_whitelist.rs similarity index 99% rename from contracts/incentives/tests/test_whitelist.rs rename to contracts/incentives/tests/tests/test_whitelist.rs index 959e1d09b..120097fb3 100644 --- a/contracts/incentives/tests/test_whitelist.rs +++ b/contracts/incentives/tests/tests/test_whitelist.rs @@ -16,12 +16,10 @@ use mars_red_bank_types::{ use mars_testing::MockEnvParams; use mars_utils::error::ValidationError; -use crate::helpers::{ +use super::helpers::{ th_query, th_query_with_env, th_setup, th_setup_with_env, ths_setup_with_epoch_duration, }; -mod helpers; - #[test] fn initialized_state() { let deps = th_setup(); diff --git a/contracts/oracle/osmosis/tests/all_tests.rs b/contracts/oracle/osmosis/tests/all_tests.rs new file mode 100644 index 000000000..14f00389d --- /dev/null +++ b/contracts/oracle/osmosis/tests/all_tests.rs @@ -0,0 +1 @@ +mod tests; diff --git a/contracts/oracle/osmosis/tests/helpers.rs b/contracts/oracle/osmosis/tests/tests/helpers/mod.rs similarity index 100% rename from contracts/oracle/osmosis/tests/helpers.rs rename to contracts/oracle/osmosis/tests/tests/helpers/mod.rs diff --git a/contracts/oracle/osmosis/tests/tests/mod.rs b/contracts/oracle/osmosis/tests/tests/mod.rs new file mode 100644 index 000000000..13eec4284 --- /dev/null +++ b/contracts/oracle/osmosis/tests/tests/mod.rs @@ -0,0 +1,10 @@ +mod helpers; + +mod test_admin; +mod test_custom_execute; +mod test_price_source_fmt; +mod test_query_price; +mod test_query_price_for_pyth; +mod test_remove_price_source; +mod test_set_price_source; +mod test_update_owner; diff --git a/contracts/oracle/osmosis/tests/test_admin.rs b/contracts/oracle/osmosis/tests/tests/test_admin.rs similarity index 99% rename from contracts/oracle/osmosis/tests/test_admin.rs rename to contracts/oracle/osmosis/tests/tests/test_admin.rs index 5812bc5e8..06758b60c 100644 --- a/contracts/oracle/osmosis/tests/test_admin.rs +++ b/contracts/oracle/osmosis/tests/tests/test_admin.rs @@ -6,7 +6,7 @@ use mars_red_bank_types::oracle::{ConfigResponse, InstantiateMsg, QueryMsg}; use mars_testing::{mock_dependencies, mock_info}; use mars_utils::error::ValidationError; -mod helpers; +use super::helpers; #[test] fn instantiating() { diff --git a/contracts/oracle/osmosis/tests/test_custom_execute.rs b/contracts/oracle/osmosis/tests/tests/test_custom_execute.rs similarity index 96% rename from contracts/oracle/osmosis/tests/test_custom_execute.rs rename to contracts/oracle/osmosis/tests/tests/test_custom_execute.rs index e8405a703..a0b7e8fcc 100644 --- a/contracts/oracle/osmosis/tests/test_custom_execute.rs +++ b/contracts/oracle/osmosis/tests/tests/test_custom_execute.rs @@ -4,7 +4,7 @@ use mars_oracle_osmosis::contract::entry; use mars_red_bank_types::oracle::ExecuteMsg; use mars_testing::mock_info; -mod helpers; +use super::helpers; #[test] fn custom_execute() { diff --git a/contracts/oracle/osmosis/tests/test_price_source_fmt.rs b/contracts/oracle/osmosis/tests/tests/test_price_source_fmt.rs similarity index 99% rename from contracts/oracle/osmosis/tests/test_price_source_fmt.rs rename to contracts/oracle/osmosis/tests/tests/test_price_source_fmt.rs index 99bd613d1..0ece290c8 100644 --- a/contracts/oracle/osmosis/tests/test_price_source_fmt.rs +++ b/contracts/oracle/osmosis/tests/tests/test_price_source_fmt.rs @@ -4,8 +4,6 @@ use mars_oracle_osmosis::{ }; use pyth_sdk_cw::PriceIdentifier; -mod helpers; - #[test] fn display_downtime_detector() { let dd = DowntimeDetector { diff --git a/contracts/oracle/osmosis/tests/test_query_price.rs b/contracts/oracle/osmosis/tests/tests/test_query_price.rs similarity index 99% rename from contracts/oracle/osmosis/tests/test_query_price.rs rename to contracts/oracle/osmosis/tests/tests/test_query_price.rs index dc5a1c611..c16f18281 100644 --- a/contracts/oracle/osmosis/tests/test_query_price.rs +++ b/contracts/oracle/osmosis/tests/tests/test_query_price.rs @@ -5,6 +5,7 @@ use cosmwasm_std::{ testing::{mock_env, MockApi, MockStorage}, Decimal, OwnedDeps, StdError, }; +use helpers::prepare_query_balancer_pool_response; use mars_oracle_base::{pyth::scale_pyth_price, ContractError}; use mars_oracle_osmosis::{ contract::entry, stride::RedemptionRateResponse, Downtime, DowntimeDetector, GeometricTwap, @@ -18,9 +19,7 @@ use osmosis_std::types::osmosis::{ }; use pyth_sdk_cw::{Price, PriceFeed, PriceFeedResponse, PriceIdentifier}; -use crate::helpers::prepare_query_balancer_pool_response; - -mod helpers; +use super::helpers; #[test] fn querying_fixed_price() { diff --git a/contracts/oracle/osmosis/tests/test_query_price_for_pyth.rs b/contracts/oracle/osmosis/tests/tests/test_query_price_for_pyth.rs similarity index 99% rename from contracts/oracle/osmosis/tests/test_query_price_for_pyth.rs rename to contracts/oracle/osmosis/tests/tests/test_query_price_for_pyth.rs index 3effd960e..be8145645 100644 --- a/contracts/oracle/osmosis/tests/test_query_price_for_pyth.rs +++ b/contracts/oracle/osmosis/tests/tests/test_query_price_for_pyth.rs @@ -5,7 +5,7 @@ use mars_red_bank_types::oracle::{ActionKind, PriceResponse, QueryMsg}; use mars_testing::mock_env_at_block_time; use pyth_sdk_cw::{Price, PriceFeed, PriceFeedResponse, PriceIdentifier}; -mod helpers; +use super::helpers; #[test] fn querying_default_pyth_price_if_publish_price_too_old() { diff --git a/contracts/oracle/osmosis/tests/test_remove_price_source.rs b/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs similarity index 99% rename from contracts/oracle/osmosis/tests/test_remove_price_source.rs rename to contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs index 7e41ffc42..330622199 100644 --- a/contracts/oracle/osmosis/tests/test_remove_price_source.rs +++ b/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs @@ -9,7 +9,7 @@ use mars_owner::OwnerError::NotOwner; use mars_red_bank_types::oracle::msg::QueryMsg; use mars_testing::mock_info; -mod helpers; +use super::helpers; #[test] fn remove_price_source_by_non_owner() { diff --git a/contracts/oracle/osmosis/tests/test_set_price_source.rs b/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs similarity index 99% rename from contracts/oracle/osmosis/tests/test_set_price_source.rs rename to contracts/oracle/osmosis/tests/tests/test_set_price_source.rs index 9048dbab6..e47d703ec 100644 --- a/contracts/oracle/osmosis/tests/test_set_price_source.rs +++ b/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs @@ -14,7 +14,7 @@ use mars_testing::mock_info; use mars_utils::error::ValidationError; use pyth_sdk_cw::PriceIdentifier; -mod helpers; +use super::helpers; #[test] fn setting_price_source_by_non_owner() { diff --git a/contracts/oracle/osmosis/tests/test_update_owner.rs b/contracts/oracle/osmosis/tests/tests/test_update_owner.rs similarity index 97% rename from contracts/oracle/osmosis/tests/test_update_owner.rs rename to contracts/oracle/osmosis/tests/tests/test_update_owner.rs index 21130aa84..c56f49c64 100644 --- a/contracts/oracle/osmosis/tests/test_update_owner.rs +++ b/contracts/oracle/osmosis/tests/tests/test_update_owner.rs @@ -1,12 +1,11 @@ use cosmwasm_std::testing::{mock_env, mock_info}; +use helpers::{query, setup_test_with_pools}; use mars_oracle_base::ContractError; use mars_oracle_osmosis::contract::entry::execute; use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; use mars_red_bank_types::oracle::msg::{ConfigResponse, ExecuteMsg, QueryMsg}; -use crate::helpers::{query, setup_test_with_pools}; - -mod helpers; +use super::helpers; #[test] fn initialized_state() { diff --git a/contracts/oracle/wasm/tests/all_tests.rs b/contracts/oracle/wasm/tests/all_tests.rs new file mode 100644 index 000000000..14f00389d --- /dev/null +++ b/contracts/oracle/wasm/tests/all_tests.rs @@ -0,0 +1 @@ +mod tests; diff --git a/contracts/oracle/wasm/tests/helpers.rs b/contracts/oracle/wasm/tests/tests/helpers/mod.rs similarity index 100% rename from contracts/oracle/wasm/tests/helpers.rs rename to contracts/oracle/wasm/tests/tests/helpers/mod.rs diff --git a/contracts/oracle/wasm/tests/tests/mod.rs b/contracts/oracle/wasm/tests/tests/mod.rs new file mode 100644 index 000000000..2d3303374 --- /dev/null +++ b/contracts/oracle/wasm/tests/tests/mod.rs @@ -0,0 +1,6 @@ +mod helpers; + +mod prop_tests; +mod test_migrate; +mod test_price_source; +mod test_update_admin; diff --git a/contracts/oracle/wasm/tests/prop_tests.proptest-regressions b/contracts/oracle/wasm/tests/tests/prop_tests.proptest-regressions similarity index 100% rename from contracts/oracle/wasm/tests/prop_tests.proptest-regressions rename to contracts/oracle/wasm/tests/tests/prop_tests.proptest-regressions diff --git a/contracts/oracle/wasm/tests/prop_tests.rs b/contracts/oracle/wasm/tests/tests/prop_tests.rs similarity index 100% rename from contracts/oracle/wasm/tests/prop_tests.rs rename to contracts/oracle/wasm/tests/tests/prop_tests.rs diff --git a/contracts/oracle/wasm/tests/test_migrate.rs b/contracts/oracle/wasm/tests/tests/test_migrate.rs similarity index 100% rename from contracts/oracle/wasm/tests/test_migrate.rs rename to contracts/oracle/wasm/tests/tests/test_migrate.rs diff --git a/contracts/oracle/wasm/tests/test_price_source.rs b/contracts/oracle/wasm/tests/tests/test_price_source.rs similarity index 99% rename from contracts/oracle/wasm/tests/test_price_source.rs rename to contracts/oracle/wasm/tests/tests/test_price_source.rs index 4c5b4f5f6..18e0353ee 100644 --- a/contracts/oracle/wasm/tests/test_price_source.rs +++ b/contracts/oracle/wasm/tests/tests/test_price_source.rs @@ -40,7 +40,7 @@ use mars_testing::{ use pyth_sdk_cw::{Price, PriceFeed, PriceFeedResponse}; use test_case::test_case; -mod helpers; +use super::helpers; #[test] fn test_contract_initialization() { diff --git a/contracts/oracle/wasm/tests/test_update_admin.rs b/contracts/oracle/wasm/tests/tests/test_update_admin.rs similarity index 100% rename from contracts/oracle/wasm/tests/test_update_admin.rs rename to contracts/oracle/wasm/tests/tests/test_update_admin.rs diff --git a/contracts/params/tests/all_tests.rs b/contracts/params/tests/all_tests.rs new file mode 100644 index 000000000..14f00389d --- /dev/null +++ b/contracts/params/tests/all_tests.rs @@ -0,0 +1 @@ +mod tests; diff --git a/contracts/params/tests/helpers/assertions.rs b/contracts/params/tests/tests/helpers/assertions.rs similarity index 100% rename from contracts/params/tests/helpers/assertions.rs rename to contracts/params/tests/tests/helpers/assertions.rs diff --git a/contracts/params/tests/helpers/contracts.rs b/contracts/params/tests/tests/helpers/contracts.rs similarity index 100% rename from contracts/params/tests/helpers/contracts.rs rename to contracts/params/tests/tests/helpers/contracts.rs diff --git a/contracts/params/tests/helpers/generator.rs b/contracts/params/tests/tests/helpers/generator.rs similarity index 100% rename from contracts/params/tests/helpers/generator.rs rename to contracts/params/tests/tests/helpers/generator.rs diff --git a/contracts/params/tests/helpers/mock_env.rs b/contracts/params/tests/tests/helpers/mock_env.rs similarity index 99% rename from contracts/params/tests/helpers/mock_env.rs rename to contracts/params/tests/tests/helpers/mock_env.rs index 729a9d331..f812739ba 100644 --- a/contracts/params/tests/helpers/mock_env.rs +++ b/contracts/params/tests/tests/helpers/mock_env.rs @@ -11,7 +11,7 @@ use mars_params::{ types::{asset::AssetParams, vault::VaultConfig}, }; -use crate::helpers::mock_params_contract; +use super::contracts::mock_params_contract; pub struct MockEnv { pub app: BasicApp, diff --git a/contracts/params/tests/helpers/mod.rs b/contracts/params/tests/tests/helpers/mod.rs similarity index 100% rename from contracts/params/tests/helpers/mod.rs rename to contracts/params/tests/tests/helpers/mod.rs diff --git a/contracts/params/tests/tests/mod.rs b/contracts/params/tests/tests/mod.rs new file mode 100644 index 000000000..bdfca4340 --- /dev/null +++ b/contracts/params/tests/tests/mod.rs @@ -0,0 +1,10 @@ +mod helpers; + +mod test_asset_validation; +mod test_deposit_cap; +mod test_emergency_powers; +mod test_owner; +mod test_target_health_factor; +mod test_update_asset_params; +mod test_vault_validation; +mod test_vaults; diff --git a/contracts/params/tests/test_asset_validation.rs b/contracts/params/tests/tests/test_asset_validation.rs similarity index 99% rename from contracts/params/tests/test_asset_validation.rs rename to contracts/params/tests/tests/test_asset_validation.rs index 0c7f7b352..5dd216883 100644 --- a/contracts/params/tests/test_asset_validation.rs +++ b/contracts/params/tests/tests/test_asset_validation.rs @@ -8,9 +8,7 @@ use mars_params::{ }; use mars_utils::error::ValidationError::{InvalidDenom, InvalidParam}; -use crate::helpers::{assert_err, default_asset_params, MockEnv}; - -pub mod helpers; +use super::helpers::{assert_err, default_asset_params, MockEnv}; #[test] fn denom_must_be_native() { diff --git a/contracts/params/tests/test_deposit_cap.rs b/contracts/params/tests/tests/test_deposit_cap.rs similarity index 97% rename from contracts/params/tests/test_deposit_cap.rs rename to contracts/params/tests/tests/test_deposit_cap.rs index 7da5648af..63a51a60c 100644 --- a/contracts/params/tests/test_deposit_cap.rs +++ b/contracts/params/tests/tests/test_deposit_cap.rs @@ -1,5 +1,3 @@ -pub mod helpers; - use std::str::FromStr; use cosmwasm_std::{coins, Addr, Decimal, Uint128}; @@ -13,7 +11,7 @@ use mars_red_bank_types::red_bank::{Market, UserDebtResponse}; use mars_testing::{mock_dependencies, mock_env_at_block_time}; use test_case::test_case; -use crate::helpers::default_asset_params; +use super::helpers::default_asset_params; const CREDIT_MANAGER: &str = "credit_manager"; const MOCK_DENOM: &str = "utoken"; diff --git a/contracts/params/tests/test_emergency_powers.rs b/contracts/params/tests/tests/test_emergency_powers.rs similarity index 98% rename from contracts/params/tests/test_emergency_powers.rs rename to contracts/params/tests/tests/test_emergency_powers.rs index 748c972e0..5e4c08ac8 100644 --- a/contracts/params/tests/test_emergency_powers.rs +++ b/contracts/params/tests/tests/test_emergency_powers.rs @@ -8,9 +8,7 @@ use mars_params::{ }, }; -use crate::helpers::{assert_err, default_asset_params, default_vault_config, MockEnv}; - -pub mod helpers; +use super::helpers::{assert_err, default_asset_params, default_vault_config, MockEnv}; #[test] fn only_owner_can_invoke_emergency_powers() { diff --git a/contracts/params/tests/test_owner.rs b/contracts/params/tests/tests/test_owner.rs similarity index 94% rename from contracts/params/tests/test_owner.rs rename to contracts/params/tests/tests/test_owner.rs index df525b854..79ca8aaa6 100644 --- a/contracts/params/tests/test_owner.rs +++ b/contracts/params/tests/tests/test_owner.rs @@ -2,9 +2,7 @@ use cosmwasm_std::Addr; use mars_owner::{OwnerError, OwnerUpdate}; use mars_params::error::ContractError::Owner; -use crate::helpers::{assert_err, MockEnv}; - -pub mod helpers; +use super::helpers::{assert_err, MockEnv}; #[test] fn owner_set_on_init() { diff --git a/contracts/params/tests/test_target_health_factor.rs b/contracts/params/tests/tests/test_target_health_factor.rs similarity index 97% rename from contracts/params/tests/test_target_health_factor.rs rename to contracts/params/tests/tests/test_target_health_factor.rs index 47c2cf2a6..9eaa6f1ee 100644 --- a/contracts/params/tests/test_target_health_factor.rs +++ b/contracts/params/tests/tests/test_target_health_factor.rs @@ -5,9 +5,7 @@ use mars_owner::OwnerError; use mars_params::error::ContractError::{Owner, Validation}; use mars_utils::error::ValidationError::InvalidParam; -use crate::helpers::{assert_err, MockEnv}; - -pub mod helpers; +use super::helpers::{assert_err, MockEnv}; #[test] fn thf_set_on_init() { diff --git a/contracts/params/tests/test_update_asset_params.rs b/contracts/params/tests/tests/test_update_asset_params.rs similarity index 98% rename from contracts/params/tests/test_update_asset_params.rs rename to contracts/params/tests/tests/test_update_asset_params.rs index f62b2792c..ee0601045 100644 --- a/contracts/params/tests/test_update_asset_params.rs +++ b/contracts/params/tests/tests/test_update_asset_params.rs @@ -2,9 +2,7 @@ use cosmwasm_std::Addr; use mars_owner::OwnerError; use mars_params::{error::ContractError::Owner, msg::AssetParamsUpdate}; -use crate::helpers::{assert_contents_equal, assert_err, default_asset_params, MockEnv}; - -pub mod helpers; +use super::helpers::{assert_contents_equal, assert_err, default_asset_params, MockEnv}; #[test] fn initial_state_of_params() { diff --git a/contracts/params/tests/test_vault_validation.rs b/contracts/params/tests/tests/test_vault_validation.rs similarity index 98% rename from contracts/params/tests/test_vault_validation.rs rename to contracts/params/tests/tests/test_vault_validation.rs index d1b29a8d9..ecf4021bf 100644 --- a/contracts/params/tests/test_vault_validation.rs +++ b/contracts/params/tests/tests/test_vault_validation.rs @@ -8,9 +8,7 @@ use mars_params::{ }; use mars_utils::error::ValidationError::InvalidParam; -use crate::helpers::{assert_err, default_vault_config, MockEnv}; - -pub mod helpers; +use super::helpers::{assert_err, default_vault_config, MockEnv}; #[test] fn vault_addr_must_be_valid() { diff --git a/contracts/params/tests/test_vaults.rs b/contracts/params/tests/tests/test_vaults.rs similarity index 98% rename from contracts/params/tests/test_vaults.rs rename to contracts/params/tests/tests/test_vaults.rs index 84d0ab4d2..2f87735ae 100644 --- a/contracts/params/tests/test_vaults.rs +++ b/contracts/params/tests/tests/test_vaults.rs @@ -6,9 +6,7 @@ use mars_params::{ error::ContractError::Owner, msg::VaultConfigUpdate, types::vault::VaultConfigUnchecked, }; -use crate::helpers::{assert_contents_equal, assert_err, default_vault_config, MockEnv}; - -pub mod helpers; +use super::helpers::{assert_contents_equal, assert_err, default_vault_config, MockEnv}; #[test] fn initial_state_of_vault_configs() { diff --git a/contracts/red-bank/tests/all_tests.rs b/contracts/red-bank/tests/all_tests.rs new file mode 100644 index 000000000..14f00389d --- /dev/null +++ b/contracts/red-bank/tests/all_tests.rs @@ -0,0 +1 @@ +mod tests; diff --git a/contracts/red-bank/tests/helpers.rs b/contracts/red-bank/tests/tests/helpers/mod.rs similarity index 100% rename from contracts/red-bank/tests/helpers.rs rename to contracts/red-bank/tests/tests/helpers/mod.rs diff --git a/contracts/red-bank/tests/tests/mod.rs b/contracts/red-bank/tests/tests/mod.rs new file mode 100644 index 000000000..63cccf890 --- /dev/null +++ b/contracts/red-bank/tests/tests/mod.rs @@ -0,0 +1,13 @@ +mod helpers; + +mod test_admin; +mod test_borrow; +mod test_credit_accounts; +mod test_deposit; +mod test_health; +mod test_liquidate; +mod test_misc; +mod test_payment; +mod test_query; +mod test_update_owner; +mod test_withdraw; diff --git a/contracts/red-bank/tests/test_admin.rs b/contracts/red-bank/tests/tests/test_admin.rs similarity index 99% rename from contracts/red-bank/tests/test_admin.rs rename to contracts/red-bank/tests/tests/test_admin.rs index ae6a9b162..2fb396789 100644 --- a/contracts/red-bank/tests/test_admin.rs +++ b/contracts/red-bank/tests/tests/test_admin.rs @@ -17,9 +17,7 @@ use mars_red_bank_types::{ use mars_testing::{mock_dependencies, mock_env, mock_env_at_block_time, MockEnvParams}; use mars_utils::error::ValidationError; -use crate::helpers::{th_get_expected_indices, th_init_market, th_setup}; - -mod helpers; +use super::helpers::{th_get_expected_indices, th_init_market, th_setup}; #[test] fn proper_initialization() { diff --git a/contracts/red-bank/tests/test_borrow.rs b/contracts/red-bank/tests/tests/test_borrow.rs similarity index 99% rename from contracts/red-bank/tests/test_borrow.rs rename to contracts/red-bank/tests/tests/test_borrow.rs index 7daa4ba90..6c56c2985 100644 --- a/contracts/red-bank/tests/test_borrow.rs +++ b/contracts/red-bank/tests/tests/test_borrow.rs @@ -2,10 +2,6 @@ use cosmwasm_std::{ attr, coin, coins, testing::mock_info, Addr, BankMsg, CosmosMsg, Decimal, SubMsg, Uint128, }; use cw_utils::PaymentError; -use helpers::{ - has_collateral_position, has_debt_position, set_collateral, th_build_interests_updated_event, - th_get_expected_indices_and_rates, th_init_market, th_setup, TestUtilizationDeltaInfo, -}; use mars_interest_rate::{ calculate_applied_linear_interest_rate, compute_scaled_amount, compute_underlying_amount, ScalingOperation, SCALING_FACTOR, @@ -19,9 +15,11 @@ use mars_red_bank::{ use mars_red_bank_types::red_bank::{ExecuteMsg, Market}; use mars_testing::{mock_env, mock_env_at_block_time, MockEnvParams}; -use crate::helpers::th_default_asset_params; - -mod helpers; +use super::helpers::{ + has_collateral_position, has_debt_position, set_collateral, th_build_interests_updated_event, + th_default_asset_params, th_get_expected_indices_and_rates, th_init_market, th_setup, + TestUtilizationDeltaInfo, +}; #[test] fn borrow_and_repay() { diff --git a/contracts/red-bank/tests/test_credit_accounts.rs b/contracts/red-bank/tests/tests/test_credit_accounts.rs similarity index 99% rename from contracts/red-bank/tests/test_credit_accounts.rs rename to contracts/red-bank/tests/tests/test_credit_accounts.rs index 84ae85caa..d8ef269ea 100644 --- a/contracts/red-bank/tests/test_credit_accounts.rs +++ b/contracts/red-bank/tests/tests/test_credit_accounts.rs @@ -1,13 +1,12 @@ use std::str::FromStr; use cosmwasm_std::{coin, Addr, Decimal, Uint128}; -use helpers::assert_err; use mars_params::types::asset::{AssetParams, CmSettings, LiquidationBonus, RedBankSettings}; use mars_red_bank::error::ContractError; use mars_red_bank_types::red_bank::{InitOrUpdateAssetParams, InterestRateModel, UserHealthStatus}; use mars_testing::integration::mock_env::MockEnvBuilder; -mod helpers; +use super::helpers::assert_err; #[test] fn deposit_and_withdraw_for_credit_account_works() { diff --git a/contracts/red-bank/tests/test_deposit.rs b/contracts/red-bank/tests/tests/test_deposit.rs similarity index 98% rename from contracts/red-bank/tests/test_deposit.rs rename to contracts/red-bank/tests/tests/test_deposit.rs index a10f508af..6593a5363 100644 --- a/contracts/red-bank/tests/test_deposit.rs +++ b/contracts/red-bank/tests/tests/test_deposit.rs @@ -6,9 +6,6 @@ use cosmwasm_std::{ to_binary, Addr, Decimal, OwnedDeps, StdError, SubMsg, Uint128, WasmMsg, }; use cw_utils::PaymentError; -use helpers::{ - set_collateral, th_build_interests_updated_event, th_get_expected_indices_and_rates, th_setup, -}; use mars_interest_rate::{ compute_scaled_amount, get_underlying_liquidity_amount, ScalingOperation, SCALING_FACTOR, }; @@ -26,9 +23,10 @@ use mars_red_bank_types::{ use mars_testing::{mock_env_at_block_time, MarsMockQuerier}; use test_case::test_case; -use crate::helpers::th_default_asset_params; - -mod helpers; +use super::helpers::{ + set_collateral, th_build_interests_updated_event, th_default_asset_params, + th_get_expected_indices_and_rates, th_setup, +}; struct TestSuite { deps: OwnedDeps, diff --git a/contracts/red-bank/tests/test_health.rs b/contracts/red-bank/tests/tests/test_health.rs similarity index 100% rename from contracts/red-bank/tests/test_health.rs rename to contracts/red-bank/tests/tests/test_health.rs diff --git a/contracts/red-bank/tests/test_liquidate.rs b/contracts/red-bank/tests/tests/test_liquidate.rs similarity index 99% rename from contracts/red-bank/tests/test_liquidate.rs rename to contracts/red-bank/tests/tests/test_liquidate.rs index 6dd854671..d20976e86 100644 --- a/contracts/red-bank/tests/test_liquidate.rs +++ b/contracts/red-bank/tests/tests/test_liquidate.rs @@ -6,7 +6,6 @@ use cosmwasm_std::{ to_binary, Addr, Decimal, SubMsg, Uint128, WasmMsg, }; use cw_utils::PaymentError; -use helpers::{th_get_expected_indices_and_rates, th_query, th_setup, TestUtilizationDeltaInfo}; use mars_params::types::asset::{AssetParams, CmSettings, LiquidationBonus, RedBankSettings}; use mars_red_bank::{contract::execute, error::ContractError}; use mars_red_bank_types::{ @@ -22,13 +21,12 @@ use mars_testing::{ mock_env_at_block_time, }; -use crate::helpers::{ +use super::helpers::{ assert_err, liq_threshold_hf, merge_collaterals_and_debts, th_build_interests_updated_event, - th_get_scaled_liquidity_amount, + th_get_expected_indices_and_rates, th_get_scaled_liquidity_amount, th_query, th_setup, + TestUtilizationDeltaInfo, }; -mod helpers; - // NOTE: See spreadsheet with liquidation numbers for reference: // contracts/red-bank/tests/files/Red Bank - Dynamic LB & CF test cases v1.1.xlsx diff --git a/contracts/red-bank/tests/test_misc.rs b/contracts/red-bank/tests/tests/test_misc.rs similarity index 98% rename from contracts/red-bank/tests/test_misc.rs rename to contracts/red-bank/tests/tests/test_misc.rs index bdee41932..a8b37f3e4 100644 --- a/contracts/red-bank/tests/test_misc.rs +++ b/contracts/red-bank/tests/tests/test_misc.rs @@ -1,11 +1,6 @@ use cosmwasm_std::{ attr, coin, coins, testing::mock_info, Addr, BankMsg, CosmosMsg, Decimal, SubMsg, Uint128, }; -use helpers::{ - has_collateral_enabled, has_collateral_position, has_debt_position, set_collateral, set_debt, - th_build_interests_updated_event, th_get_expected_indices_and_rates, th_init_market, th_setup, - TestUtilizationDeltaInfo, -}; use mars_interest_rate::{ compute_scaled_amount, compute_underlying_amount, get_scaled_debt_amount, get_updated_liquidity_index, ScalingOperation, SCALING_FACTOR, @@ -21,9 +16,11 @@ use mars_red_bank::{ use mars_red_bank_types::red_bank::{Debt, ExecuteMsg, Market}; use mars_testing::{mock_env, mock_env_at_block_time, MockEnvParams}; -use crate::helpers::th_default_asset_params; - -mod helpers; +use super::helpers::{ + has_collateral_enabled, has_collateral_position, has_debt_position, set_collateral, set_debt, + th_build_interests_updated_event, th_default_asset_params, th_get_expected_indices_and_rates, + th_init_market, th_setup, TestUtilizationDeltaInfo, +}; #[test] fn uncollateralized_loan_limits() { diff --git a/contracts/red-bank/tests/test_payment.rs b/contracts/red-bank/tests/tests/test_payment.rs similarity index 98% rename from contracts/red-bank/tests/test_payment.rs rename to contracts/red-bank/tests/tests/test_payment.rs index b3ef8dde7..454283f29 100644 --- a/contracts/red-bank/tests/test_payment.rs +++ b/contracts/red-bank/tests/tests/test_payment.rs @@ -1,15 +1,14 @@ -mod helpers; - use cosmwasm_std::{ coins, testing::{mock_env, mock_info}, Uint128, }; use cw_utils::PaymentError; -use helpers::th_setup; use mars_red_bank::contract; use mars_red_bank_types::red_bank::ExecuteMsg; +use super::helpers::th_setup; + /// The Red Bank contract has 6 user-facing functions: deposit, withdraw, borrow, /// repay, liquidate, and update_asset_collateral_status; amount these, 3 do not /// expect the user to send any payment. This test verifies that they properly diff --git a/contracts/red-bank/tests/test_query.rs b/contracts/red-bank/tests/tests/test_query.rs similarity index 99% rename from contracts/red-bank/tests/test_query.rs rename to contracts/red-bank/tests/tests/test_query.rs index 6547db7c2..1aa27173c 100644 --- a/contracts/red-bank/tests/test_query.rs +++ b/contracts/red-bank/tests/tests/test_query.rs @@ -1,5 +1,4 @@ use cosmwasm_std::{testing::mock_env, Addr, Decimal, Uint128}; -use helpers::{set_collateral, th_init_market, th_setup}; use mars_interest_rate::{get_scaled_debt_amount, get_underlying_debt_amount, SCALING_FACTOR}; use mars_red_bank::{ query::{query_user_collaterals, query_user_debt, query_user_debts}, @@ -7,7 +6,7 @@ use mars_red_bank::{ }; use mars_red_bank_types::red_bank::{Debt, Market, UserCollateralResponse, UserDebtResponse}; -mod helpers; +use super::helpers::{set_collateral, th_init_market, th_setup}; #[test] fn query_collateral() { diff --git a/contracts/red-bank/tests/test_update_owner.rs b/contracts/red-bank/tests/tests/test_update_owner.rs similarity index 97% rename from contracts/red-bank/tests/test_update_owner.rs rename to contracts/red-bank/tests/tests/test_update_owner.rs index 6960a59ba..8cd8975f5 100644 --- a/contracts/red-bank/tests/test_update_owner.rs +++ b/contracts/red-bank/tests/tests/test_update_owner.rs @@ -3,9 +3,7 @@ use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; use mars_red_bank::{contract::execute, error::ContractError}; use mars_red_bank_types::red_bank::{ConfigResponse, ExecuteMsg, QueryMsg}; -use crate::helpers::{th_query, th_setup}; - -mod helpers; +use super::helpers::{th_query, th_setup}; #[test] fn initialized_state() { diff --git a/contracts/red-bank/tests/test_withdraw.rs b/contracts/red-bank/tests/tests/test_withdraw.rs similarity index 99% rename from contracts/red-bank/tests/test_withdraw.rs rename to contracts/red-bank/tests/tests/test_withdraw.rs index 4496a9c86..30180c77a 100644 --- a/contracts/red-bank/tests/test_withdraw.rs +++ b/contracts/red-bank/tests/tests/test_withdraw.rs @@ -3,10 +3,6 @@ use cosmwasm_std::{ testing::{mock_env, mock_info, MockApi, MockStorage}, to_binary, Addr, BankMsg, CosmosMsg, Decimal, OwnedDeps, SubMsg, Uint128, WasmMsg, }; -use helpers::{ - has_collateral_position, set_collateral, th_build_interests_updated_event, - th_get_expected_indices_and_rates, th_setup, TestUtilizationDeltaInfo, -}; use mars_interest_rate::{ compute_scaled_amount, compute_underlying_amount, get_scaled_liquidity_amount, get_updated_borrow_index, get_updated_liquidity_index, ScalingOperation, SCALING_FACTOR, @@ -24,9 +20,10 @@ use mars_red_bank_types::{ }; use mars_testing::{mock_env_at_block_time, MarsMockQuerier}; -use crate::helpers::th_default_asset_params; - -mod helpers; +use super::helpers::{ + has_collateral_position, set_collateral, th_build_interests_updated_event, + th_default_asset_params, th_get_expected_indices_and_rates, th_setup, TestUtilizationDeltaInfo, +}; struct TestSuite { deps: OwnedDeps, diff --git a/contracts/rewards-collector/osmosis/tests/all_tests.rs b/contracts/rewards-collector/osmosis/tests/all_tests.rs new file mode 100644 index 000000000..14f00389d --- /dev/null +++ b/contracts/rewards-collector/osmosis/tests/all_tests.rs @@ -0,0 +1 @@ +mod tests; diff --git a/contracts/rewards-collector/osmosis/tests/helpers.rs b/contracts/rewards-collector/osmosis/tests/tests/helpers/mod.rs similarity index 100% rename from contracts/rewards-collector/osmosis/tests/helpers.rs rename to contracts/rewards-collector/osmosis/tests/tests/helpers/mod.rs diff --git a/contracts/rewards-collector/osmosis/tests/tests/mod.rs b/contracts/rewards-collector/osmosis/tests/tests/mod.rs new file mode 100644 index 000000000..9bf248c6c --- /dev/null +++ b/contracts/rewards-collector/osmosis/tests/tests/mod.rs @@ -0,0 +1,7 @@ +mod helpers; + +mod test_admin; +mod test_distribute_rewards; +mod test_swap; +mod test_update_owner; +mod test_withdraw; diff --git a/contracts/rewards-collector/osmosis/tests/test_admin.rs b/contracts/rewards-collector/osmosis/tests/tests/test_admin.rs similarity index 98% rename from contracts/rewards-collector/osmosis/tests/test_admin.rs rename to contracts/rewards-collector/osmosis/tests/tests/test_admin.rs index 9fff2f58e..8cbe282b0 100644 --- a/contracts/rewards-collector/osmosis/tests/test_admin.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_admin.rs @@ -6,9 +6,10 @@ use mars_rewards_collector_osmosis::entry::{execute, instantiate}; use mars_testing::mock_info; use mars_utils::error::ValidationError; -use crate::helpers::{mock_config, mock_instantiate_msg}; - -mod helpers; +use super::{ + helpers, + helpers::{mock_config, mock_instantiate_msg}, +}; #[test] fn instantiating() { diff --git a/contracts/rewards-collector/osmosis/tests/test_distribute_rewards.rs b/contracts/rewards-collector/osmosis/tests/tests/test_distribute_rewards.rs similarity index 99% rename from contracts/rewards-collector/osmosis/tests/test_distribute_rewards.rs rename to contracts/rewards-collector/osmosis/tests/tests/test_distribute_rewards.rs index 0334c8ea3..fd7373b68 100644 --- a/contracts/rewards-collector/osmosis/tests/test_distribute_rewards.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_distribute_rewards.rs @@ -6,7 +6,7 @@ use mars_rewards_collector_base::ContractError; use mars_rewards_collector_osmosis::entry::execute; use mars_testing::{mock_env as mock_env_at_height_and_time, mock_info, MockEnvParams}; -mod helpers; +use super::helpers; #[test] fn distributing_rewards() { diff --git a/contracts/rewards-collector/osmosis/tests/test_swap.rs b/contracts/rewards-collector/osmosis/tests/tests/test_swap.rs similarity index 98% rename from contracts/rewards-collector/osmosis/tests/test_swap.rs rename to contracts/rewards-collector/osmosis/tests/tests/test_swap.rs index 331d67ab8..3bbaa7e38 100644 --- a/contracts/rewards-collector/osmosis/tests/test_swap.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_swap.rs @@ -9,9 +9,7 @@ use mars_rewards_collector_osmosis::entry::execute; use mars_testing::mock_info; use osmosis_std::types::osmosis::twap::v1beta1::ArithmeticTwapToNowResponse; -use crate::helpers::mock_instantiate_msg; - -mod helpers; +use super::{helpers, helpers::mock_instantiate_msg}; #[test] fn swapping_asset() { diff --git a/contracts/rewards-collector/osmosis/tests/test_update_owner.rs b/contracts/rewards-collector/osmosis/tests/tests/test_update_owner.rs similarity index 97% rename from contracts/rewards-collector/osmosis/tests/test_update_owner.rs rename to contracts/rewards-collector/osmosis/tests/tests/test_update_owner.rs index 7b41394c5..102b46a91 100644 --- a/contracts/rewards-collector/osmosis/tests/test_update_owner.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_update_owner.rs @@ -4,9 +4,7 @@ use mars_red_bank_types::rewards_collector::{ConfigResponse, ExecuteMsg, QueryMs use mars_rewards_collector_base::ContractError; use mars_rewards_collector_osmosis::entry::execute; -use crate::helpers::{query, setup_test}; - -mod helpers; +use super::helpers::{query, setup_test}; #[test] fn initialized_state() { diff --git a/contracts/rewards-collector/osmosis/tests/test_withdraw.rs b/contracts/rewards-collector/osmosis/tests/tests/test_withdraw.rs similarity index 99% rename from contracts/rewards-collector/osmosis/tests/test_withdraw.rs rename to contracts/rewards-collector/osmosis/tests/tests/test_withdraw.rs index 48d4b3662..df085fdcd 100644 --- a/contracts/rewards-collector/osmosis/tests/test_withdraw.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_withdraw.rs @@ -7,7 +7,7 @@ use mars_rewards_collector_base::ContractError; use mars_rewards_collector_osmosis::entry::execute; use mars_testing::mock_info; -mod helpers; +use super::helpers; #[test] fn withdrawing_from_red_bank() { diff --git a/contracts/swapper/astroport/tests/all_tests.rs b/contracts/swapper/astroport/tests/all_tests.rs new file mode 100644 index 000000000..14f00389d --- /dev/null +++ b/contracts/swapper/astroport/tests/all_tests.rs @@ -0,0 +1 @@ +mod tests; diff --git a/contracts/swapper/astroport/tests/tests/mod.rs b/contracts/swapper/astroport/tests/tests/mod.rs new file mode 100644 index 000000000..1d69d56e7 --- /dev/null +++ b/contracts/swapper/astroport/tests/tests/mod.rs @@ -0,0 +1,4 @@ +mod test_queries; +mod test_routes; +mod test_swap; +mod test_transfer_result; diff --git a/contracts/swapper/astroport/tests/test_queries.rs b/contracts/swapper/astroport/tests/tests/test_queries.rs similarity index 100% rename from contracts/swapper/astroport/tests/test_queries.rs rename to contracts/swapper/astroport/tests/tests/test_queries.rs diff --git a/contracts/swapper/astroport/tests/test_routes.rs b/contracts/swapper/astroport/tests/tests/test_routes.rs similarity index 100% rename from contracts/swapper/astroport/tests/test_routes.rs rename to contracts/swapper/astroport/tests/tests/test_routes.rs diff --git a/contracts/swapper/astroport/tests/test_swap.rs b/contracts/swapper/astroport/tests/tests/test_swap.rs similarity index 100% rename from contracts/swapper/astroport/tests/test_swap.rs rename to contracts/swapper/astroport/tests/tests/test_swap.rs diff --git a/contracts/swapper/astroport/tests/test_transfer_result.rs b/contracts/swapper/astroport/tests/tests/test_transfer_result.rs similarity index 100% rename from contracts/swapper/astroport/tests/test_transfer_result.rs rename to contracts/swapper/astroport/tests/tests/test_transfer_result.rs diff --git a/contracts/swapper/osmosis/tests/all_tests.rs b/contracts/swapper/osmosis/tests/all_tests.rs new file mode 100644 index 000000000..14f00389d --- /dev/null +++ b/contracts/swapper/osmosis/tests/all_tests.rs @@ -0,0 +1 @@ +mod tests; diff --git a/contracts/swapper/osmosis/tests/helpers.rs b/contracts/swapper/osmosis/tests/tests/helpers/mod.rs similarity index 100% rename from contracts/swapper/osmosis/tests/helpers.rs rename to contracts/swapper/osmosis/tests/tests/helpers/mod.rs diff --git a/contracts/swapper/osmosis/tests/tests/mod.rs b/contracts/swapper/osmosis/tests/tests/mod.rs new file mode 100644 index 000000000..51ee89c92 --- /dev/null +++ b/contracts/swapper/osmosis/tests/tests/mod.rs @@ -0,0 +1,8 @@ +mod helpers; + +mod test_enumerate_routes; +mod test_estimate; +mod test_instantiate; +mod test_set_route; +mod test_swap; +mod test_update_admin; diff --git a/contracts/swapper/osmosis/tests/test_enumerate_routes.rs b/contracts/swapper/osmosis/tests/tests/test_enumerate_routes.rs similarity index 98% rename from contracts/swapper/osmosis/tests/test_enumerate_routes.rs rename to contracts/swapper/osmosis/tests/tests/test_enumerate_routes.rs index c9a679a99..fa55a4fa5 100644 --- a/contracts/swapper/osmosis/tests/test_enumerate_routes.rs +++ b/contracts/swapper/osmosis/tests/tests/test_enumerate_routes.rs @@ -7,9 +7,7 @@ use cw_it::osmosis_test_tube::{Gamm, Module, OsmosisTestApp, SigningAccount, Was use mars_red_bank_types::swapper::{ExecuteMsg, QueryMsg, RouteResponse}; use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; -use crate::helpers::instantiate_contract; - -pub mod helpers; +use super::helpers::instantiate_contract; #[test] fn enumerating_routes() { diff --git a/contracts/swapper/osmosis/tests/test_estimate.rs b/contracts/swapper/osmosis/tests/tests/test_estimate.rs similarity index 99% rename from contracts/swapper/osmosis/tests/test_estimate.rs rename to contracts/swapper/osmosis/tests/tests/test_estimate.rs index 8ac107320..42aeff7d8 100644 --- a/contracts/swapper/osmosis/tests/test_estimate.rs +++ b/contracts/swapper/osmosis/tests/tests/test_estimate.rs @@ -3,12 +3,10 @@ use cw_it::osmosis_test_tube::{Gamm, Module, OsmosisTestApp, RunnerResult, Wasm} use mars_red_bank_types::swapper::{EstimateExactInSwapResponse, ExecuteMsg, QueryMsg}; use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; -use crate::helpers::{ +use super::helpers::{ assert_err, instantiate_contract, query_price_from_pool, swap_to_create_twap_records, }; -pub mod helpers; - #[test] fn error_on_route_not_found() { let app = OsmosisTestApp::new(); diff --git a/contracts/swapper/osmosis/tests/test_instantiate.rs b/contracts/swapper/osmosis/tests/tests/test_instantiate.rs similarity index 94% rename from contracts/swapper/osmosis/tests/test_instantiate.rs rename to contracts/swapper/osmosis/tests/tests/test_instantiate.rs index 3c0008aa8..684230e7d 100644 --- a/contracts/swapper/osmosis/tests/test_instantiate.rs +++ b/contracts/swapper/osmosis/tests/tests/test_instantiate.rs @@ -3,9 +3,7 @@ use cw_it::osmosis_test_tube::{Account, Module, OsmosisTestApp, Wasm}; use mars_owner::OwnerResponse; use mars_red_bank_types::swapper::{InstantiateMsg, QueryMsg}; -use crate::helpers::{instantiate_contract, wasm_file}; - -pub mod helpers; +use super::helpers::{instantiate_contract, wasm_file}; #[test] fn owner_set_on_instantiate() { diff --git a/contracts/swapper/osmosis/tests/test_set_route.rs b/contracts/swapper/osmosis/tests/tests/test_set_route.rs similarity index 99% rename from contracts/swapper/osmosis/tests/test_set_route.rs rename to contracts/swapper/osmosis/tests/tests/test_set_route.rs index 83cdcbf85..150d23325 100644 --- a/contracts/swapper/osmosis/tests/test_set_route.rs +++ b/contracts/swapper/osmosis/tests/tests/test_set_route.rs @@ -5,9 +5,7 @@ use mars_red_bank_types::swapper::{ExecuteMsg, QueryMsg, RouteResponse}; use mars_swapper_base::ContractError; use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; -use crate::helpers::{assert_err, instantiate_contract}; - -pub mod helpers; +use super::helpers::{assert_err, instantiate_contract}; #[test] fn only_owner_can_set_routes() { diff --git a/contracts/swapper/osmosis/tests/test_swap.rs b/contracts/swapper/osmosis/tests/tests/test_swap.rs similarity index 99% rename from contracts/swapper/osmosis/tests/test_swap.rs rename to contracts/swapper/osmosis/tests/tests/test_swap.rs index 713209ad6..9f39206ca 100644 --- a/contracts/swapper/osmosis/tests/test_swap.rs +++ b/contracts/swapper/osmosis/tests/tests/test_swap.rs @@ -7,12 +7,10 @@ use mars_red_bank_types::swapper::ExecuteMsg; use mars_swapper_base::ContractError; use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; -use crate::helpers::{ +use super::helpers::{ assert_err, instantiate_contract, query_balance, swap_to_create_twap_records, }; -pub mod helpers; - #[test] fn transfer_callback_only_internal() { let app = OsmosisTestApp::new(); diff --git a/contracts/swapper/osmosis/tests/test_update_admin.rs b/contracts/swapper/osmosis/tests/tests/test_update_admin.rs similarity index 98% rename from contracts/swapper/osmosis/tests/test_update_admin.rs rename to contracts/swapper/osmosis/tests/tests/test_update_admin.rs index 84abb85e0..a47e7ba8e 100644 --- a/contracts/swapper/osmosis/tests/test_update_admin.rs +++ b/contracts/swapper/osmosis/tests/tests/test_update_admin.rs @@ -4,9 +4,7 @@ use mars_owner::{OwnerResponse, OwnerUpdate}; use mars_red_bank_types::swapper::{ExecuteMsg, QueryMsg}; use mars_swapper_osmosis::route::OsmosisRoute; -use crate::helpers::instantiate_contract; - -pub mod helpers; +use super::helpers::instantiate_contract; #[test] fn initial_state() {