Skip to content

Commit

Permalink
Adapt slash test method helper
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolacy committed Dec 4, 2023
1 parent 246c7bb commit ebf1785
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
12 changes: 6 additions & 6 deletions contracts/provider/external-staking/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ fn slashing() {
// But now validators[0] slashing happens
contract
.test_methods_proxy()
.test_handle_slashing(validators[0].to_string())
.test_handle_slashing(validators[0].to_string(), Uint128::new(8))
.call("test")
.unwrap();

Expand Down Expand Up @@ -1444,7 +1444,7 @@ fn slashing_pending_tx_partial_unbond() {
// Now validators[0] slashing happens
contract
.test_methods_proxy()
.test_handle_slashing(validators[0].to_string())
.test_handle_slashing(validators[0].to_string(), Uint128::new(20))
.call("test")
.unwrap();

Expand Down Expand Up @@ -1527,7 +1527,7 @@ fn slashing_pending_tx_full_unbond() {
// Now validators[0] slashing happens
contract
.test_methods_proxy()
.test_handle_slashing(validators[0].to_string())
.test_handle_slashing(validators[0].to_string(), Uint128::new(20))
.call("test")
.unwrap();

Expand Down Expand Up @@ -1612,7 +1612,7 @@ fn slashing_pending_tx_full_unbond_rolled_back() {
// Now validators[0] slashing happens
contract
.test_methods_proxy()
.test_handle_slashing(validators[0].to_string())
.test_handle_slashing(validators[0].to_string(), Uint128::new(20))
.call("test")
.unwrap();

Expand Down Expand Up @@ -1717,7 +1717,7 @@ fn slashing_pending_tx_bond() {
// Now validators[0] slashing happens
contract
.test_methods_proxy()
.test_handle_slashing(validators[0].to_string())
.test_handle_slashing(validators[0].to_string(), Uint128::new(20))
.call("test")
.unwrap();

Expand Down Expand Up @@ -1804,7 +1804,7 @@ fn slashing_pending_tx_bond_rolled_back() {
// Now validators[0] slashing happens
contract
.test_methods_proxy()
.test_handle_slashing(validators[0].to_string())
.test_handle_slashing(validators[0].to_string(), Uint128::new(20))
.call("test")
.unwrap();

Expand Down
3 changes: 2 additions & 1 deletion contracts/provider/external-staking/src/test_methods.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{Coin, Response, StdError};
use cosmwasm_std::{Coin, Response, StdError, Uint128};
use mesh_apis::converter_api::RewardInfo;
use mesh_apis::ibc::AddValidator;
use sylvia::interface;
Expand Down Expand Up @@ -97,5 +97,6 @@ pub trait TestMethods {
&self,
ctx: ExecCtx,
validator: String,
slash_amount: Uint128,
) -> Result<Response, Self::Error>;
}
7 changes: 5 additions & 2 deletions contracts/provider/external-staking/src/test_methods_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::contract::ExternalStakingContract;
use crate::error::ContractError;
use crate::test_methods::TestMethods;

use cosmwasm_std::{Coin, Response};
use cosmwasm_std::{Coin, Response, Uint128};
use mesh_apis::converter_api::RewardInfo;
use mesh_apis::ibc::AddValidator;
use sylvia::contract;
Expand Down Expand Up @@ -225,6 +225,7 @@ impl TestMethods for ExternalStakingContract<'_> {
&self,
ctx: ExecCtx,
validator: String,
slash_amount: Uint128,
) -> Result<Response, ContractError> {
#[cfg(any(test, feature = "mt"))]
{
Expand All @@ -235,6 +236,8 @@ impl TestMethods for ExternalStakingContract<'_> {
&cfg,
&validator,
cfg.slash_ratio.double_sign,
slash_amount,
ctx.env.block.time.seconds(),
)?;
match slash_msg {
Some(msg) => Ok(Response::new().add_message(msg)),
Expand All @@ -243,7 +246,7 @@ impl TestMethods for ExternalStakingContract<'_> {
}
#[cfg(not(any(test, feature = "mt")))]
{
let _ = (ctx, validator);
let _ = (ctx, validator, slash_amount);
Err(ContractError::Unauthorized {})
}
}
Expand Down

0 comments on commit ebf1785

Please sign in to comment.