mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 13:48:00 +00:00
Allow validators to block and kick their nominator set. (#7930)
* Allow validators to block and kick their nominator set. * migration * Test * Better migration * Fixes * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Update frame/staking/src/lib.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Parity Benchmarking Bot <admin@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -364,6 +364,30 @@ fn staking_should_work() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blocking_and_kicking_works() {
|
||||
ExtBuilder::default()
|
||||
.minimum_validator_count(1)
|
||||
.validator_count(4)
|
||||
.nominate(true)
|
||||
.num_validators(3)
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
// block validator 10/11
|
||||
assert_ok!(Staking::validate(Origin::signed(10), ValidatorPrefs { blocked: true, .. Default::default() }));
|
||||
// attempt to nominate from 100/101...
|
||||
assert_ok!(Staking::nominate(Origin::signed(100), vec![11]));
|
||||
// should have worked since we're already nominated them
|
||||
assert_eq!(Nominators::<Test>::get(&101).unwrap().targets, vec![11]);
|
||||
// kick the nominator
|
||||
assert_ok!(Staking::kick(Origin::signed(10), vec![101]));
|
||||
// should have been kicked now
|
||||
assert!(Nominators::<Test>::get(&101).unwrap().targets.is_empty());
|
||||
// attempt to nominate from 100/101...
|
||||
assert_noop!(Staking::nominate(Origin::signed(100), vec![11]), Error::<Test>::BadTarget);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn less_than_needed_candidates_works() {
|
||||
ExtBuilder::default()
|
||||
@@ -403,7 +427,7 @@ fn no_candidate_emergency_condition() {
|
||||
.execute_with(|| {
|
||||
// initial validators
|
||||
assert_eq_uvec!(validator_controllers(), vec![10, 20, 30, 40]);
|
||||
let prefs = ValidatorPrefs { commission: Perbill::one() };
|
||||
let prefs = ValidatorPrefs { commission: Perbill::one(), .. Default::default() };
|
||||
<Staking as crate::Store>::Validators::insert(11, prefs.clone());
|
||||
|
||||
// set the minimum validator count.
|
||||
@@ -971,6 +995,7 @@ fn validator_payment_prefs_work() {
|
||||
let commission = Perbill::from_percent(40);
|
||||
<Validators<Test>>::insert(&11, ValidatorPrefs {
|
||||
commission: commission.clone(),
|
||||
.. Default::default()
|
||||
});
|
||||
|
||||
// Reward controller so staked ratio doesn't change.
|
||||
|
||||
Reference in New Issue
Block a user