Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x committed May 11, 2022
1 parent b829d0d commit 252ca11
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 1,040 deletions.
1 change: 1 addition & 0 deletions contracts/luna-vault/src/flashloan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pub fn before_trade(deps: DepsMut, env: Env) -> Result<Vec<(&str, String)>, Luna
}

/// Checks if balance increased after the trade
#[allow(unreachable_code)]
pub fn after_trade(
deps: DepsMut,
env: Env,
Expand Down
1 change: 1 addition & 0 deletions contracts/luna-vault/src/tests/anchor_mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub enum Cw20HookMsg {
RedeemStable {},
}

#[allow(dead_code)]
pub fn contract_anchor_mock() -> Box<dyn Contract<Empty>> {
let contract = ContractWrapper::new(
|deps, _, info, msg: MockExecuteMsg| -> VaultResult<Response> {
Expand Down
36 changes: 2 additions & 34 deletions contracts/luna-vault/src/tests/callback.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use cosmwasm_std::testing::{mock_env, mock_info, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{coin, Uint128};
use white_whale::denom::LUNA_DENOM;
use cosmwasm_std::testing::{mock_env, mock_info};
use cosmwasm_std::Uint128;

use white_whale::luna_vault::msg::{CallbackMsg, ExecuteMsg};

Expand All @@ -25,34 +24,3 @@ fn unsuccessful_handle_callback_not_same_contract() {
_ => panic!("Must return StableVaultError::NotCallback"),
}
}

#[test]
fn successful_handle_callback_without_anchor_deposit() {
let mut deps = mock_dependencies(&[coin(100u128, LUNA_DENOM)]);
mock_instantiate(deps.as_mut());

let msg = ExecuteMsg::Callback(CallbackMsg::AfterTrade {
loan_fee: Uint128::zero(),
});
let info = mock_info(MOCK_CONTRACT_ADDR, &[]);

let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap();
// 1 msg (commission)
assert_eq!(4, res.messages.len());
}
// TODO: TEST is Broken with error
// called `Result::unwrap()` on an `Err` value: Std(ParseErr { target_type: "astroport::pair::SimulationResponse", msg: "missing field `return_amount`" })
// #[test]
fn successful_handle_callback_with_anchor_deposit() {
let mut deps = mock_dependencies(&[coin(15000000000000001u128, LUNA_DENOM)]);
mock_instantiate(deps.as_mut());

let msg = ExecuteMsg::Callback(CallbackMsg::AfterTrade {
loan_fee: Uint128::zero(),
});
let info = mock_info(MOCK_CONTRACT_ADDR, &[]);

let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap();
// 2msgs, anchor and commission
assert_eq!(2, res.messages.len());
}
2 changes: 1 addition & 1 deletion contracts/luna-vault/src/tests/common_integration.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::contract::{execute, instantiate, query, reply};
use cosmwasm_std::testing::{mock_env, MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{Decimal, Empty, Uint128};
use cosmwasm_std::{Decimal, Empty};
use terra_mocks::TerraMockQuerier;
use terra_multi_test::{App, BankKeeper, Contract, ContractWrapper};
use terraswap::asset::AssetInfo;
Expand Down
1 change: 0 additions & 1 deletion contracts/luna-vault/src/tests/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use cw20::MinterResponse;
use terraswap::asset::AssetInfo;
use white_whale::luna_vault::msg::InstantiateMsg as VaultInstantiateMsg;

use crate::tests::common_integration::instantiate_msg as vault_msg;
use terraswap::token::InstantiateMsg as TokenInstantiateMsg;
use white_whale::fee::*;
use white_whale::luna_vault::msg::VaultQueryMsg as QueryMsg;
Expand Down
Loading

0 comments on commit 252ca11

Please sign in to comment.