Skip to content

Commit

Permalink
Use new constructors in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Nov 6, 2023
1 parent 63f9b2a commit afe59e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
28 changes: 13 additions & 15 deletions contracts/staking/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,24 +412,22 @@ mod tests {
use std::str::FromStr;

fn sample_validator(addr: &str) -> Validator {
serde_json::from_value(serde_json::json!({
"address": addr.to_owned(),
"commission": Decimal::percent(3),
"max_commission": Decimal::percent(10),
"max_change_rate": Decimal::percent(1),
}))
.unwrap()
Validator::create(
addr.to_owned(),
Decimal::percent(3),
Decimal::percent(10),
Decimal::percent(1),
)
}

fn sample_delegation(validator_addr: &str, amount: Coin) -> FullDelegation {
serde_json::from_value(serde_json::json!({
"validator": validator_addr.to_owned(),
"delegator": Addr::unchecked(MOCK_CONTRACT_ADDR),
"amount": amount,
"can_redelegate": amount,
"accumulated_rewards": Vec::<Coin>::new(),
}))
.unwrap()
FullDelegation::create(
Addr::unchecked(MOCK_CONTRACT_ADDR),
validator_addr.to_owned(),
amount.clone(),
amount,
vec![],
)
}

fn set_validator(querier: &mut MockQuerier) {
Expand Down
13 changes: 6 additions & 7 deletions contracts/staking/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ static WASM: &[u8] = include_bytes!("../target/wasm32-unknown-unknown/release/st
// static WASM: &[u8] = include_bytes!("../contract.wasm");

fn sample_validator(addr: &str) -> Validator {
serde_json::from_value(serde_json::json!({
"address": addr.to_owned(),
"commission": Decimal::percent(3),
"max_commission": Decimal::percent(10),
"max_change_rate": Decimal::percent(1),
}))
.unwrap()
Validator::create(
addr.to_owned(),
Decimal::percent(3),
Decimal::percent(10),
Decimal::percent(1),
)
}

#[test]
Expand Down

0 comments on commit afe59e0

Please sign in to comment.