From ebf1785bec1e4efd4859be220d9b4f7475e0b479 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 4 Dec 2023 19:57:28 +0100 Subject: [PATCH] Adapt slash test method helper --- contracts/provider/external-staking/src/multitest.rs | 12 ++++++------ .../provider/external-staking/src/test_methods.rs | 3 ++- .../external-staking/src/test_methods_impl.rs | 7 +++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/contracts/provider/external-staking/src/multitest.rs b/contracts/provider/external-staking/src/multitest.rs index 254c35e1..010dac67 100644 --- a/contracts/provider/external-staking/src/multitest.rs +++ b/contracts/provider/external-staking/src/multitest.rs @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); diff --git a/contracts/provider/external-staking/src/test_methods.rs b/contracts/provider/external-staking/src/test_methods.rs index 7049e798..d6b7e638 100644 --- a/contracts/provider/external-staking/src/test_methods.rs +++ b/contracts/provider/external-staking/src/test_methods.rs @@ -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; @@ -97,5 +97,6 @@ pub trait TestMethods { &self, ctx: ExecCtx, validator: String, + slash_amount: Uint128, ) -> Result; } diff --git a/contracts/provider/external-staking/src/test_methods_impl.rs b/contracts/provider/external-staking/src/test_methods_impl.rs index 8eb6b74e..2df3a3b6 100644 --- a/contracts/provider/external-staking/src/test_methods_impl.rs +++ b/contracts/provider/external-staking/src/test_methods_impl.rs @@ -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; @@ -225,6 +225,7 @@ impl TestMethods for ExternalStakingContract<'_> { &self, ctx: ExecCtx, validator: String, + slash_amount: Uint128, ) -> Result { #[cfg(any(test, feature = "mt"))] { @@ -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)), @@ -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 {}) } }