Skip to content
Closed
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: 2 additions & 0 deletions contracts/account-nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ pub mod execute;
pub mod migrations;
pub mod query;
pub mod state;
#[cfg(test)]
mod tests;
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ use std::ops::Add;
use cosmwasm_std::{Addr, Empty, StdResult, Uint128};
use cw721::NftInfoResponse;
use cw721_base::{ContractError::Ownership, OwnershipError::NotOwner};
use mars_account_nft::error::{
use mars_types::{account_nft::QueryMsg::NftInfo, health::AccountKind};

use super::helpers::{below_max_for_burn, generate_health_response, MockEnv, MAX_VALUE_FOR_BURN};
use crate::error::{
ContractError,
ContractError::{BaseError, BurnNotAllowed, HealthContractNotSet},
};
use mars_types::{account_nft::QueryMsg::NftInfo, health::AccountKind};

use crate::helpers::{below_max_for_burn, generate_health_response, MockEnv, MAX_VALUE_FOR_BURN};

pub mod helpers;

#[test]
fn only_token_owner_can_burn() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use cosmwasm_std::{Addr, StdError};
use mars_account_nft::error::{ContractError, ContractError::HealthContractNotSet};
use mars_types::{
account_nft::QueryMsg::{AllTokens, NumTokens, Tokens},
health::AccountKind,
};

use crate::helpers::{generate_health_response, MockEnv};

pub mod helpers;
use super::helpers::{generate_health_response, MockEnv};
use crate::error::{ContractError, ContractError::HealthContractNotSet};

#[test]
fn burning_empty_accounts_not_allowed_if_no_health_contract_set() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use cw_multi_test::{Contract, ContractWrapper};

pub fn mock_nft_contract() -> Box<dyn Contract<Empty>> {
let contract = ContractWrapper::new(
mars_account_nft::contract::execute,
mars_account_nft::contract::instantiate,
mars_account_nft::contract::query,
crate::contract::execute,
crate::contract::instantiate,
crate::contract::query,
);
Box::new(contract)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use mars_types::{
health::{AccountKind, HealthValuesResponse},
};

use crate::helpers::MockEnvBuilder;
use super::MockEnvBuilder;

pub struct MockEnv {
pub app: BasicApp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ use mars_mock_credit_manager::msg::InstantiateMsg as CmMockInstantiateMsg;
use mars_owner::OwnerResponse;
use mars_types::{account_nft::InstantiateMsg, credit_manager::ConfigResponse};

use super::mock_credit_manager_contract;
use crate::helpers::{mock_health_contract, mock_nft_contract, MockEnv, MAX_VALUE_FOR_BURN};
use super::{
mock_credit_manager_contract, mock_health_contract, mock_nft_contract, MockEnv,
MAX_VALUE_FOR_BURN,
};

pub struct MockEnvBuilder {
pub app: BasicApp,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use self::{health_responses::*, mock_contracts::*, mock_env::*, mock_env_builder::*};

mod health_responses;
mod mock_contracts;
mod mock_env;
mod mock_env_builder;

pub use self::{health_responses::*, mock_contracts::*, mock_env::*, mock_env_builder::*};
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::helpers::{MockEnv, MAX_VALUE_FOR_BURN};

pub mod helpers;
use super::helpers::{MockEnv, MAX_VALUE_FOR_BURN};

#[test]
fn instantiated_storage_vars() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ use cw721_base::{Cw721Contract, Ownership, QueryMsg};
use cw721_base_v16::{
msg::InstantiateMsg as Cw721v16InstantiateMsg, Cw721Contract as Cw721ContractV16,
};
use mars_account_nft::{
contract::migrate, error::ContractError, migrations::v2_0_0::v1_state, state::CONFIG,
};
use mars_types::account_nft::NftConfig;

pub mod helpers;
use crate::{contract::migrate, error::ContractError, migrations::v2_0_0::v1_state, state::CONFIG};

#[test]
fn invalid_contract_name() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ use cosmwasm_std::Addr;
use cw721::OwnerOfResponse;
use cw721_base::{ContractError::Ownership, OwnershipError::NotOwner};
use cw_multi_test::Executor;
use mars_account_nft::error::{ContractError, ContractError::BaseError};
use mars_types::{
account_nft::{ExecuteMsg, QueryMsg::OwnerOf},
health::AccountKind,
};

use crate::helpers::{below_max_for_burn, MockEnv};

pub mod helpers;
use super::helpers::{below_max_for_burn, MockEnv};
use crate::error::{ContractError, ContractError::BaseError};

#[test]
fn id_incrementer() {
Expand Down
8 changes: 8 additions & 0 deletions contracts/account-nft/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mod burn_allowance;
mod burn_empty_accounts;
mod helpers;
mod instantiate;
mod migration;
mod mint;
mod proposed_minter;
mod update_config;
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use cosmwasm_std::Addr;
use cw721_base::MinterResponse;
use mars_types::account_nft::QueryMsg;

use crate::helpers::MockEnv;

pub mod helpers;
use super::helpers::MockEnv;

#[test]
fn only_minter_can_propose_new_minter() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use cosmwasm_std::{Addr, Uint128};
use mars_types::account_nft::NftConfigUpdates;

use crate::helpers::MockEnv;

pub mod helpers;
use super::helpers::MockEnv;

#[test]
fn only_minter_can_update_config() {
Expand Down
2 changes: 2 additions & 0 deletions contracts/address-provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ mod helpers;
mod key;
pub mod migrations;
pub mod state;
#[cfg(test)]
mod tests;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use cosmwasm_std::testing::{mock_env, mock_info};
use mars_address_provider::{contract::execute, error::ContractError, state::ADDRESSES};
use mars_owner::OwnerError;
use mars_types::address_provider::{AddressResponseItem, ExecuteMsg, MarsAddressType, QueryMsg};

use super::helpers::{th_query, th_setup};
use crate::{contract::execute, error::ContractError, state::ADDRESSES};

#[test]
fn setting_address_if_unauthorized() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#![allow(dead_code)]

use cosmwasm_std::{
from_binary,
testing::{
mock_dependencies_with_balance, mock_env, mock_info, MockApi, MockQuerier, MockStorage,
},
Deps, OwnedDeps,
};
use mars_address_provider::contract::{instantiate, query};
use mars_types::address_provider::{InstantiateMsg, QueryMsg};

use crate::contract::{instantiate, query};

pub fn th_setup() -> OwnedDeps<MockStorage, MockApi, MockQuerier> {
let mut deps = mock_dependencies_with_balance(&[]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
use mars_address_provider::{contract::instantiate, error::ContractError};
use mars_types::address_provider::{ConfigResponse, InstantiateMsg, QueryMsg};

use super::helpers::th_query;
use crate::{contract::instantiate, error::ContractError};

#[test]
fn invalid_chain_prefix() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use cosmwasm_std::{attr, testing::mock_env, Addr, Empty, Event};
use cw2::{ContractVersion, VersionError};
use mars_address_provider::{
use mars_testing::mock_dependencies;

use crate::{
contract::migrate,
error::ContractError,
migrations::v2_0_0::v1_state::{self, OwnerSetNoneProposed},
state::OWNER,
};
use mars_testing::mock_dependencies;

#[test]
fn wrong_contract_name() {
Expand Down
5 changes: 5 additions & 0 deletions contracts/address-provider/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod addresses;
mod helpers;
mod instantiate;
mod migration_v2;
mod update_owner;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use cosmwasm_std::testing::{mock_env, mock_info};
use mars_address_provider::{contract::execute, error::ContractError};
use mars_owner::{OwnerError::NotOwner, OwnerUpdate};
use mars_types::address_provider::{ConfigResponse, ExecuteMsg, QueryMsg};

use super::helpers::{th_query, th_setup};
use crate::{contract::execute, error::ContractError};

#[test]
fn initialized_state() {
Expand Down
1 change: 0 additions & 1 deletion contracts/address-provider/tests/all_tests.rs

This file was deleted.

6 changes: 0 additions & 6 deletions contracts/address-provider/tests/tests/mod.rs

This file was deleted.

2 changes: 2 additions & 0 deletions contracts/credit-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub mod refund;
pub mod repay;
pub mod state;
pub mod swap;
#[cfg(test)]
mod tests;
pub mod update_coin_balances;
pub mod update_config;
pub mod utils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use std::ops::{Mul, Sub};

use cosmwasm_std::{coin, coins, Addr, Uint128};
use mars_credit_manager::{borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED, error::ContractError};
use mars_types::credit_manager::Action::{Borrow, Deposit};

use crate::helpers::{
use super::helpers::{
assert_err, blacklisted_coin, uosmo_info, AccountToFund, MockEnv, DEFAULT_RED_BANK_COIN_BALANCE,
};

pub mod helpers;
use crate::{borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED, error::ContractError};

#[test]
fn only_token_owner_can_borrow() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use cosmwasm_std::{Addr, Uint128};
use mars_credit_manager::error::ContractError;
use mars_types::{
credit_manager::Action::{Borrow, ClaimRewards, Deposit},
params::{AssetParamsUpdate::AddOrUpdate, HlsAssetType},
};

use crate::helpers::{
use super::helpers::{
assert_err, get_coin, lp_token_info, uatom_info, ujake_info, uosmo_info, AccountToFund, MockEnv,
};

pub mod helpers;
use crate::error::ContractError;

#[test]
fn claiming_rewards_when_having_none() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use cosmwasm_std::{coin, coins, Addr, Uint128};
use cw_multi_test::{BankSudo, SudoMsg};
use mars_credit_manager::error::ContractError;
use mars_types::credit_manager::{Action::Deposit, CallbackMsg, ChangeExpected};

use crate::helpers::{assert_err, uosmo_info, AccountToFund, MockEnv};

pub mod helpers;
use super::helpers::{assert_err, uosmo_info, AccountToFund, MockEnv};
use crate::error::ContractError;

#[test]
fn only_rover_can_call_update_coin_balances() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use cosmwasm_std::{Addr, Empty};
use cw721::OwnerOfResponse;
use cw721_base::QueryMsg as NftQueryMsg;

use crate::helpers::MockEnv;

pub mod helpers;
use super::helpers::MockEnv;

#[test]
fn create_credit_account_fails_without_nft_contract_set() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use cosmwasm_std::{coin, coins, Addr, Coin, Coins, Uint128};
use mars_credit_manager::error::ContractError::{
ExtraFundsReceived, FundsMismatch, NotTokenOwner, NotWhitelisted,
};
use mars_types::credit_manager::{Action, Positions};

use crate::helpers::{
use super::helpers::{
assert_err, blacklisted_coin, uatom_info, ujake_info, uosmo_info, AccountToFund, CoinInfo,
MockEnv,
};

pub mod helpers;
use crate::error::ContractError::{
ExtraFundsReceived, FundsMismatch, NotTokenOwner, NotWhitelisted,
};

#[test]
fn only_owner_of_token_can_deposit() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// must be public module so that clippy doesn't complain "dead code"
pub mod helpers;

use std::collections::HashMap;

use cosmwasm_std::{Addr, Coin, Coins, Decimal, StdResult, Uint128};
use mars_credit_manager::error::ContractError;
use mars_types::{
credit_manager::{Action, ActionAmount, ActionCoin},
params::{AssetParams, AssetParamsUpdate},
};
use test_case::test_case;

use crate::helpers::{uatom_info, uosmo_info, AccountToFund, MockEnv};
use super::helpers::{uatom_info, uosmo_info, AccountToFund, MockEnv};
use crate::error::ContractError;

#[test_case(
[].into(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use cosmwasm_std::{coin, Addr};
use helpers::assert_err;
use mars_credit_manager::error::{ContractError, ContractError::NotTokenOwner};
use mars_types::credit_manager::CallbackMsg;

use crate::helpers::MockEnv;

pub mod helpers;
use super::helpers::{assert_err, MockEnv};
use crate::error::{ContractError, ContractError::NotTokenOwner};

#[test]
fn dispatch_only_allowed_for_token_owner() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use cosmwasm_std::Addr;
use mars_types::{credit_manager::Account, health::AccountKind};

use crate::helpers::MockEnv;

pub mod helpers;
use super::helpers::MockEnv;

fn account_default(id: &str) -> Account {
Account {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use cosmwasm_std::{coin, Addr, Uint128};
use mars_types::credit_manager::{Action, CoinBalanceResponseItem};

use crate::helpers::{build_mock_coin_infos, AccountToFund, MockEnv};

pub mod helpers;
use super::helpers::{build_mock_coin_infos, AccountToFund, MockEnv};

#[test]
fn pagination_on_all_coin_balances_query_works() {
Expand Down
Loading