Use MAX associated const (#9196)

* Use MAX associated const
This commit is contained in:
Squirrel
2021-06-24 11:53:49 +01:00
committed by GitHub
parent 09d9c2c9f6
commit ea1f21a904
56 changed files with 178 additions and 178 deletions
+7 -7
View File
@@ -79,9 +79,9 @@ pub fn create_validator_with_nominators<T: Config>(
// Give the validator n nominators, but keep total users in the system the same.
for i in 0 .. upper_bound {
let (n_stash, n_controller) = if !dead {
create_stash_controller::<T>(u32::max_value() - i, 100, destination.clone())?
create_stash_controller::<T>(u32::MAX - i, 100, destination.clone())?
} else {
create_stash_and_dead_controller::<T>(u32::max_value() - i, 100, destination.clone())?
create_stash_and_dead_controller::<T>(u32::MAX - i, 100, destination.clone())?
};
if i < n {
Staking::<T>::nominate(RawOrigin::Signed(n_controller.clone()).into(), vec![stash_lookup.clone()])?;
@@ -456,7 +456,7 @@ benchmarks! {
<ErasTotalStake<T>>::insert(i, BalanceOf::<T>::one());
ErasStartSessionIndex::<T>::insert(i, i);
}
}: _(RawOrigin::Root, EraIndex::zero(), u32::max_value())
}: _(RawOrigin::Root, EraIndex::zero(), u32::MAX)
verify {
assert_eq!(HistoryDepth::<T>::get(), 0);
}
@@ -607,13 +607,13 @@ benchmarks! {
RawOrigin::Root,
BalanceOf::<T>::max_value(),
BalanceOf::<T>::max_value(),
Some(u32::max_value()),
Some(u32::max_value())
Some(u32::MAX),
Some(u32::MAX)
) verify {
assert_eq!(MinNominatorBond::<T>::get(), BalanceOf::<T>::max_value());
assert_eq!(MinValidatorBond::<T>::get(), BalanceOf::<T>::max_value());
assert_eq!(MaxNominatorsCount::<T>::get(), Some(u32::max_value()));
assert_eq!(MaxValidatorsCount::<T>::get(), Some(u32::max_value()));
assert_eq!(MaxNominatorsCount::<T>::get(), Some(u32::MAX));
assert_eq!(MaxValidatorsCount::<T>::get(), Some(u32::MAX));
}
chill_other {
+1 -1
View File
@@ -150,7 +150,7 @@ pub fn create_validators_with_nominators_for_era<T: Config>(
for j in 0 .. nominators {
let balance_factor = if randomize_stake { rng.next_u32() % 255 + 10 } else { 100u32 };
let (_n_stash, n_controller) = create_stash_controller::<T>(
u32::max_value() - j,
u32::MAX - j,
balance_factor,
RewardDestination::Staked,
)?;
+3 -3
View File
@@ -1960,8 +1960,8 @@ fn phragmen_should_not_overflow() {
#[test]
fn reward_validator_slashing_validator_does_not_overflow() {
ExtBuilder::default().build_and_execute(|| {
let stake = u64::max_value() as Balance * 2;
let reward_slash = u64::max_value() as Balance * 2;
let stake = u64::MAX as Balance * 2;
let reward_slash = u64::MAX as Balance * 2;
// Assert multiplication overflows in balance arithmetic.
assert!(stake.checked_mul(reward_slash).is_none());
@@ -3995,7 +3995,7 @@ mod election_data_provider {
);
Staking::force_no_eras(Origin::root()).unwrap();
assert_eq!(Staking::next_election_prediction(System::block_number()), u64::max_value());
assert_eq!(Staking::next_election_prediction(System::block_number()), u64::MAX);
Staking::force_new_era_always(Origin::root()).unwrap();
assert_eq!(Staking::next_election_prediction(System::block_number()), 45 + 5);