Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
PFC-developer committed Apr 24, 2024
1 parent 3cec058 commit a0d9e47
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 32 deletions.
4 changes: 2 additions & 2 deletions contracts/hub-tf/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::convert::TryInto;

use cosmwasm_std::{
entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError,
StdResult,
entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response,
StdError, StdResult,
};
use cw2::{get_contract_version, set_contract_version, ContractVersion};
use pfc_steak::{
Expand Down
3 changes: 2 additions & 1 deletion contracts/hub-tf/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ pub(crate) fn reconcile_batches(batches: &mut [Batch], native_to_deduct: Uint128

if !remaining_underflow.is_zero() {
// the remaining underflow will be applied by oldest batch first.
for batch in batches.iter_mut() {//} .enumerate() {
for batch in batches.iter_mut() {
//} .enumerate() {
if !batch.amount_unclaimed.is_zero() && !remaining_underflow.is_zero() {
if batch.amount_unclaimed >= remaining_underflow {
batch.amount_unclaimed -= remaining_underflow;
Expand Down
7 changes: 6 additions & 1 deletion contracts/hub-tf/src/testing/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use cosmwasm_std::{ testing::{mock_env, MockApi, MockStorage, MOCK_CONTRACT_ADDR}, Addr, BlockInfo, ContractInfo, Deps, Env, OwnedDeps, QuerierResult, SystemError, SystemResult, Timestamp, from_json};
use cosmwasm_std::{
from_json,
testing::{mock_env, MockApi, MockStorage, MOCK_CONTRACT_ADDR},
Addr, BlockInfo, ContractInfo, Deps, Env, OwnedDeps, QuerierResult, SystemError, SystemResult,
Timestamp,
};
use pfc_steak::hub::QueryMsg;
use serde::de::DeserializeOwned;

Expand Down
66 changes: 45 additions & 21 deletions contracts/hub-tf/src/testing/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::str::FromStr;

use cosmwasm_std::{testing::{mock_env, mock_info, MockApi, MockStorage, MOCK_CONTRACT_ADDR}, Addr, BankMsg, Coin, CosmosMsg, Decimal, DistributionMsg, Order, OwnedDeps, ReplyOn, StdError, SubMsg, Uint128, WasmMsg, to_json_binary};
use cosmwasm_std::{
testing::{mock_env, mock_info, MockApi, MockStorage, MOCK_CONTRACT_ADDR},
to_json_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, DistributionMsg, Order, OwnedDeps,
ReplyOn, StdError, SubMsg, Uint128, WasmMsg,
};
use pfc_steak::{
hub::{
Batch, CallbackMsg, ConfigResponse, PendingBatch, QueryMsg, StateResponse, UnbondRequest,
Expand Down Expand Up @@ -1064,11 +1068,14 @@ fn withdrawing_unbonded() {
);

let err = previous_batches().load(deps.as_ref().storage, 2u64.into()).unwrap_err();
match err { StdError::NotFound {..} => {}, _=> {
panic!("Should have been not found")
} };


match err {
StdError::NotFound {
..
} => {},
_ => {
panic!("Should have been not found")
},
};

// User 1's unbond requests in batches 1 and 2 should have been deleted
let err1 = unbond_requests()
Expand All @@ -1078,14 +1085,23 @@ fn withdrawing_unbonded() {
.load(deps.as_ref().storage, (1u64.into(), &Addr::unchecked("user_1").as_str()))
.unwrap_err();

match err1 { StdError::NotFound {..} => {}, _=> {
panic!("Should have been not found")
} };

match err2 { StdError::NotFound {..} => {}, _=> {
panic!("Should have been not found")
} };
match err1 {
StdError::NotFound {
..
} => {},
_ => {
panic!("Should have been not found")
},
};

match err2 {
StdError::NotFound {
..
} => {},
_ => {
panic!("Should have been not found")
},
};

// User 3 attempt to withdraw; also specifying a receiver
let res = execute(
Expand Down Expand Up @@ -1114,19 +1130,27 @@ fn withdrawing_unbonded() {

// Batch 1 and user 2's unbonding request should have been purged from storage
let err = previous_batches().load(deps.as_ref().storage, 1u64.into()).unwrap_err();
match err { StdError::NotFound {..} => {}, _=> {
panic!("Should have been not found")
} };

match err {
StdError::NotFound {
..
} => {},
_ => {
panic!("Should have been not found")
},
};

let err = unbond_requests()
.load(deps.as_ref().storage, (1u64.into(), &Addr::unchecked("user_3").as_str()))
.unwrap_err();

match err { StdError::NotFound {..} => {}, _=> {
panic!("Should have been not found")
} };

match err {
StdError::NotFound {
..
} => {},
_ => {
panic!("Should have been not found")
},
};
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions contracts/hub/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::convert::TryInto;

use cosmwasm_std::{
entry_point, from_json, to_json_binary, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Reply,
Response, StdError, StdResult,
entry_point, from_json, to_json_binary, Binary, Decimal, Deps, DepsMut, Env, MessageInfo,
Reply, Response, StdError, StdResult,
};
use cw2::{get_contract_version, set_contract_version, ContractVersion};
use cw20::Cw20ReceiveMsg;
Expand Down
3 changes: 2 additions & 1 deletion contracts/hub/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ pub(crate) fn reconcile_batches(batches: &mut [Batch], native_to_deduct: Uint128

if !remaining_underflow.is_zero() {
// the remaining underflow will be applied by oldest batch first.
for batch in batches.iter_mut(){//.enumerate() {
for batch in batches.iter_mut() {
//.enumerate() {
if !batch.amount_unclaimed.is_zero() && !remaining_underflow.is_zero() {
if batch.amount_unclaimed >= remaining_underflow {
batch.amount_unclaimed -= remaining_underflow;
Expand Down
6 changes: 3 additions & 3 deletions contracts/hub/src/testing/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::str::FromStr;

use cosmwasm_std::{
testing::{mock_env, mock_info, MockApi, MockStorage, MOCK_CONTRACT_ADDR},
to_json_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, DistributionMsg, Event, Order, OwnedDeps,
Reply, ReplyOn, StdError, SubMsg, SubMsgResponse, Uint128, WasmMsg,
to_json_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, DistributionMsg, Event, Order,
OwnedDeps, Reply, ReplyOn, StdError, SubMsg, SubMsgResponse, Uint128, WasmMsg,
};
use cw20::{Cw20ExecuteMsg, MinterResponse};
use cw20_base::msg::InstantiateMsg as Cw20InstantiateMsg;
Expand Down Expand Up @@ -1234,7 +1234,7 @@ fn withdrawing_unbonded() {
assert_eq!(
err,
StdError::NotFound {
kind: "pfc_steak::hub::Batch".to_string()
kind: "pfc_steak::hub::Batch".to_string(),
}
);

Expand Down
1 change: 0 additions & 1 deletion contracts/hub/src/types/coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ impl Coins {
.iter()
.find(|coin| coin.denom == denom)
.cloned()

.unwrap_or_else(|| Coin::new(0, denom))
}
}

0 comments on commit a0d9e47

Please sign in to comment.