Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/audit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
ignore = ["RUSTSEC-2022-0093", "RUSTSEC-2023-0052"]
20 changes: 8 additions & 12 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions contracts/address-provider/tests/all_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod tests;
5 changes: 5 additions & 0 deletions contracts/address-provider/tests/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod helpers;

mod test_addresses;
mod test_instantiate;
mod test_update_owner;
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions contracts/incentives/tests/all_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod tests;
10 changes: 10 additions & 0 deletions contracts/incentives/tests/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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(),
Expand Down Expand Up @@ -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<IncentiveStateResponse> = helpers::th_query(
let res: Vec<IncentiveStateResponse> = th_query(
deps.as_ref(),
QueryMsg::IncentiveStates {
start_after_collateral_denom: None,
Expand All @@ -88,7 +86,7 @@ fn query_incentive_states() {
);

// NOTE: responses are ordered alphabetically by denom
let res: Vec<IncentiveStateResponse> = helpers::th_query(
let res: Vec<IncentiveStateResponse> = th_query(
deps.as_ref(),
QueryMsg::IncentiveStates {
start_after_collateral_denom: Some("uatom".to_string()),
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -203,7 +201,7 @@ fn query_emissions() {
.save(deps.as_mut().storage, ("uusdc", "umars", 604800 * 2), &Uint128::new(50))
.unwrap();

let res: Vec<EmissionResponse> = helpers::th_query(
let res: Vec<EmissionResponse> = th_query(
deps.as_ref(),
QueryMsg::Emissions {
collateral_denom: "uusdc".to_string(),
Expand All @@ -221,7 +219,7 @@ fn query_emissions() {
]
);

let res: Vec<EmissionResponse> = helpers::th_query(
let res: Vec<EmissionResponse> = th_query(
deps.as_ref(),
QueryMsg::Emissions {
collateral_denom: "uusdc".to_string(),
Expand All @@ -238,7 +236,7 @@ fn query_emissions() {
]
);

let res: Vec<EmissionResponse> = helpers::th_query(
let res: Vec<EmissionResponse> = th_query(
deps.as_ref(),
QueryMsg::Emissions {
collateral_denom: "uusdc".to_string(),
Expand Down Expand Up @@ -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::<Vec<ActiveEmission>>(
th_query_with_env::<Vec<ActiveEmission>>(
deps.as_ref(),
mock_env(MockEnvParams {
block_time: Timestamp::from_seconds(query_at_time),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions contracts/oracle/osmosis/tests/all_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod tests;
10 changes: 10 additions & 0 deletions contracts/oracle/osmosis/tests/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use mars_oracle_osmosis::{
};
use pyth_sdk_cw::PriceIdentifier;

mod helpers;

#[test]
fn display_downtime_detector() {
let dd = DowntimeDetector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading