mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 18:37:59 +00:00
Add some tests to demonstrate an estimate of the nominator limit (#2724)
* Add some tests to demonstrate an estimate of the nominator limit * Update runtime/kusama/src/lib.rs * Update runtime/polkadot/src/lib.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Fix build * remove max Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -1484,4 +1484,30 @@ mod test_fees {
|
||||
test_with_multiplier(Multiplier::saturating_from_rational(1, 1_000_000u128));
|
||||
test_with_multiplier(Multiplier::saturating_from_rational(1, 1_000_000_000u128));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nominator_limit() {
|
||||
use pallet_election_provider_multi_phase::WeightInfo;
|
||||
// starting point of the nominators.
|
||||
let all_voters: u32 = 10_000;
|
||||
|
||||
// assuming we want around 5k candidates and 1k active validators.
|
||||
let all_targets: u32 = 5_000;
|
||||
let desired: u32 = 1_000;
|
||||
let weight_with = |active| {
|
||||
<Runtime as pallet_election_provider_multi_phase::Config>::WeightInfo::submit_unsigned(
|
||||
all_voters.max(active),
|
||||
all_targets,
|
||||
active,
|
||||
desired,
|
||||
)
|
||||
};
|
||||
|
||||
let mut active = 1;
|
||||
while weight_with(active) <= OffchainSolutionWeightLimit::get() || active == all_voters {
|
||||
active += 1;
|
||||
}
|
||||
|
||||
println!("can support {} nominators to yield a weight of {}", active, weight_with(active));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1510,4 +1510,31 @@ mod test_fees {
|
||||
test_with_multiplier(Multiplier::saturating_from_rational(1, 1_000_000u128));
|
||||
test_with_multiplier(Multiplier::saturating_from_rational(1, 1_000_000_000u128));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nominator_limit() {
|
||||
use pallet_election_provider_multi_phase::WeightInfo;
|
||||
// starting point of the nominators.
|
||||
let target_voters: u32 = 50_000;
|
||||
|
||||
// assuming we want around 5k candidates and 1k active validators. (March 31, 2021)
|
||||
let all_targets: u32 = 5_000;
|
||||
let desired: u32 = 1_000;
|
||||
let weight_with = |active| {
|
||||
<Runtime as pallet_election_provider_multi_phase::Config>::WeightInfo::submit_unsigned(
|
||||
active,
|
||||
all_targets,
|
||||
active,
|
||||
desired,
|
||||
)
|
||||
};
|
||||
|
||||
let mut active = target_voters;
|
||||
while weight_with(active) <= OffchainSolutionWeightLimit::get() || active == target_voters {
|
||||
active += 1;
|
||||
}
|
||||
|
||||
println!("can support {} nominators to yield a weight of {}", active, weight_with(active));
|
||||
assert!(active > target_voters, "we need to reevaluate the weight of the election system");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user