mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 06:37:56 +00:00
Minimum commission for validators (#10347)
* Minimum commission for validators * rename * Fix benchmakrs * cargo run --quiet --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/pallet/mod.rs * cargo run --quiet --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 Co-authored-by: Parity Bot <admin@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -4350,7 +4350,15 @@ fn chill_other_works() {
|
||||
);
|
||||
|
||||
// Change the minimum bond... but no limits.
|
||||
assert_ok!(Staking::set_staking_limits(Origin::root(), 1_500, 2_000, None, None, None));
|
||||
assert_ok!(Staking::set_staking_configs(
|
||||
Origin::root(),
|
||||
1_500,
|
||||
2_000,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Zero::zero()
|
||||
));
|
||||
|
||||
// Still can't chill these users
|
||||
assert_noop!(
|
||||
@@ -4363,13 +4371,14 @@ fn chill_other_works() {
|
||||
);
|
||||
|
||||
// Add limits, but no threshold
|
||||
assert_ok!(Staking::set_staking_limits(
|
||||
assert_ok!(Staking::set_staking_configs(
|
||||
Origin::root(),
|
||||
1_500,
|
||||
2_000,
|
||||
Some(10),
|
||||
Some(10),
|
||||
None
|
||||
None,
|
||||
Zero::zero()
|
||||
));
|
||||
|
||||
// Still can't chill these users
|
||||
@@ -4383,13 +4392,14 @@ fn chill_other_works() {
|
||||
);
|
||||
|
||||
// Add threshold, but no limits
|
||||
assert_ok!(Staking::set_staking_limits(
|
||||
assert_ok!(Staking::set_staking_configs(
|
||||
Origin::root(),
|
||||
1_500,
|
||||
2_000,
|
||||
None,
|
||||
None,
|
||||
Some(Percent::from_percent(0))
|
||||
Some(Percent::from_percent(0)),
|
||||
Zero::zero()
|
||||
));
|
||||
|
||||
// Still can't chill these users
|
||||
@@ -4403,13 +4413,14 @@ fn chill_other_works() {
|
||||
);
|
||||
|
||||
// Add threshold and limits
|
||||
assert_ok!(Staking::set_staking_limits(
|
||||
assert_ok!(Staking::set_staking_configs(
|
||||
Origin::root(),
|
||||
1_500,
|
||||
2_000,
|
||||
Some(10),
|
||||
Some(10),
|
||||
Some(Percent::from_percent(75))
|
||||
Some(Percent::from_percent(75)),
|
||||
Zero::zero()
|
||||
));
|
||||
|
||||
// 16 people total because tests start with 2 active one
|
||||
@@ -4447,13 +4458,14 @@ fn capped_stakers_works() {
|
||||
|
||||
// Change the maximums
|
||||
let max = 10;
|
||||
assert_ok!(Staking::set_staking_limits(
|
||||
assert_ok!(Staking::set_staking_configs(
|
||||
Origin::root(),
|
||||
10,
|
||||
10,
|
||||
Some(max),
|
||||
Some(max),
|
||||
Some(Percent::from_percent(0))
|
||||
Some(Percent::from_percent(0)),
|
||||
Zero::zero(),
|
||||
));
|
||||
|
||||
// can create `max - validator_count` validators
|
||||
@@ -4516,12 +4528,60 @@ fn capped_stakers_works() {
|
||||
));
|
||||
|
||||
// No problem when we set to `None` again
|
||||
assert_ok!(Staking::set_staking_limits(Origin::root(), 10, 10, None, None, None));
|
||||
assert_ok!(Staking::set_staking_configs(
|
||||
Origin::root(),
|
||||
10,
|
||||
10,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Zero::zero(),
|
||||
));
|
||||
assert_ok!(Staking::nominate(Origin::signed(last_nominator), vec![1]));
|
||||
assert_ok!(Staking::validate(Origin::signed(last_validator), ValidatorPrefs::default()));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn min_commission_works() {
|
||||
ExtBuilder::default().build_and_execute(|| {
|
||||
assert_ok!(Staking::validate(
|
||||
Origin::signed(10),
|
||||
ValidatorPrefs { commission: Perbill::from_percent(5), blocked: false }
|
||||
));
|
||||
|
||||
assert_ok!(Staking::set_staking_configs(
|
||||
Origin::root(),
|
||||
0,
|
||||
0,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Perbill::from_percent(10),
|
||||
));
|
||||
|
||||
// can't make it less than 10 now
|
||||
assert_noop!(
|
||||
Staking::validate(
|
||||
Origin::signed(10),
|
||||
ValidatorPrefs { commission: Perbill::from_percent(5), blocked: false }
|
||||
),
|
||||
Error::<Test>::CommissionTooLow
|
||||
);
|
||||
|
||||
// can only change to higher.
|
||||
assert_ok!(Staking::validate(
|
||||
Origin::signed(10),
|
||||
ValidatorPrefs { commission: Perbill::from_percent(10), blocked: false }
|
||||
));
|
||||
|
||||
assert_ok!(Staking::validate(
|
||||
Origin::signed(10),
|
||||
ValidatorPrefs { commission: Perbill::from_percent(15), blocked: false }
|
||||
));
|
||||
})
|
||||
}
|
||||
|
||||
mod sorted_list_provider {
|
||||
use super::*;
|
||||
use frame_election_provider_support::SortedListProvider;
|
||||
|
||||
Reference in New Issue
Block a user