mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-10 17:11:03 +00:00
Use parameter_types instead of thread_local for test-setup (#12036)
* Edit to Assets. parameter_types * fixes * Test Fixes. WIP * Edits to pallet-aura * Camel Case Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Implementation of mutate fn * update to pallet-aura * Update to frame-system. Fixes * Update to frame-support-test. CamelCases * Updates to frame- contracts, offences, staking, bounties, child bounties * Edit to mutate fn. Changes to frame-contracts. CamelCase pallet-aura * Edits to frame-contracts & executive * cargo +nightly fmt * unused import removed * unused import removed * cargo +nightly fmt * minor adjustment * updates * updates * cargo +nightly fmt * cargo +nightly fmt * take fn implemented * update * update * Fixes to CallFilter * cargo +nightly fmt * final fixes * Default changed to $value * Update frame/support/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -37,7 +37,6 @@ use sp_runtime::{
|
||||
traits::{IdentityLookup, Zero},
|
||||
};
|
||||
use sp_staking::offence::{DisableStrategy, OffenceDetails, OnOffenceHandler};
|
||||
use std::cell::RefCell;
|
||||
|
||||
pub const INIT_TIMESTAMP: u64 = 30_000;
|
||||
pub const BLOCK_TIME: u64 = 1000;
|
||||
@@ -216,16 +215,16 @@ parameter_types! {
|
||||
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(75);
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
pub static REWARD_REMAINDER_UNBALANCED: RefCell<u128> = RefCell::new(0);
|
||||
parameter_types! {
|
||||
pub static RewardRemainderUnbalanced: u128 = 0;
|
||||
}
|
||||
|
||||
pub struct RewardRemainderMock;
|
||||
|
||||
impl OnUnbalanced<NegativeImbalanceOf<Test>> for RewardRemainderMock {
|
||||
fn on_nonzero_unbalanced(amount: NegativeImbalanceOf<Test>) {
|
||||
REWARD_REMAINDER_UNBALANCED.with(|v| {
|
||||
*v.borrow_mut() += amount.peek();
|
||||
RewardRemainderUnbalanced::mutate(|v| {
|
||||
*v += amount.peek();
|
||||
});
|
||||
drop(amount);
|
||||
}
|
||||
|
||||
@@ -301,10 +301,7 @@ fn rewards_should_work() {
|
||||
start_session(3);
|
||||
|
||||
assert_eq!(active_era(), 1);
|
||||
assert_eq!(
|
||||
mock::REWARD_REMAINDER_UNBALANCED.with(|v| *v.borrow()),
|
||||
maximum_payout - total_payout_0,
|
||||
);
|
||||
assert_eq!(mock::RewardRemainderUnbalanced::get(), maximum_payout - total_payout_0,);
|
||||
assert_eq!(
|
||||
*mock::staking_events().last().unwrap(),
|
||||
Event::EraPaid(0, total_payout_0, maximum_payout - total_payout_0)
|
||||
@@ -340,7 +337,7 @@ fn rewards_should_work() {
|
||||
|
||||
mock::start_active_era(2);
|
||||
assert_eq!(
|
||||
mock::REWARD_REMAINDER_UNBALANCED.with(|v| *v.borrow()),
|
||||
mock::RewardRemainderUnbalanced::get(),
|
||||
maximum_payout * 2 - total_payout_0 - total_payout_1,
|
||||
);
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user