mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 05:05:41 +00:00
@@ -275,7 +275,7 @@ impl INPoS {
|
||||
// See web3 docs for the details
|
||||
fn compute_opposite_after_x_ideal(&self, y: u32) -> u32 {
|
||||
if y == self.i_0 {
|
||||
return u32::max_value();
|
||||
return u32::MAX;
|
||||
}
|
||||
// Note: the log term calculated here represents a per_million value
|
||||
let log = log2(self.i_ideal_times_x_ideal - self.i_0, y - self.i_0);
|
||||
@@ -408,7 +408,7 @@ fn generate_test_module(input: &INposInput) -> TokenStream2 {
|
||||
|
||||
#[test]
|
||||
fn reward_curve_precision() {
|
||||
for &base in [MILLION, u32::max_value()].iter() {
|
||||
for &base in [MILLION, u32::MAX].iter() {
|
||||
let number_of_check = 100_000.min(base);
|
||||
for check_index in 0..=number_of_check {
|
||||
let i = (check_index as u64 * base as u64 / number_of_check as u64) as u32;
|
||||
|
||||
@@ -33,7 +33,7 @@ fn taylor_term(k: u32, y_num: u128, y_den: u128) -> u32 {
|
||||
/// * result represents a per-million output of log2
|
||||
pub fn log2(p: u32, q: u32) -> u32 {
|
||||
assert!(p >= q); // keep p/q bound to [1, inf)
|
||||
assert!(p <= u32::max_value()/2);
|
||||
assert!(p <= u32::MAX/2);
|
||||
|
||||
// This restriction should not be mandatory. But function is only tested and used for this.
|
||||
assert!(p <= 1_000_000);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
)?;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user