mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 21:55:45 +00:00
@@ -310,7 +310,7 @@ fn querying_total_supply_should_work() {
|
||||
assert_eq!(Assets::balance(0, 1), 50);
|
||||
assert_eq!(Assets::balance(0, 2), 19);
|
||||
assert_eq!(Assets::balance(0, 3), 31);
|
||||
assert_ok!(Assets::burn(Origin::signed(1), 0, 3, u64::max_value()));
|
||||
assert_ok!(Assets::burn(Origin::signed(1), 0, 3, u64::MAX));
|
||||
assert_eq!(Assets::total_supply(0), 69);
|
||||
});
|
||||
}
|
||||
@@ -457,7 +457,7 @@ fn transferring_amount_more_than_available_balance_should_not_work() {
|
||||
assert_ok!(Assets::transfer(Origin::signed(1), 0, 2, 50));
|
||||
assert_eq!(Assets::balance(0, 1), 50);
|
||||
assert_eq!(Assets::balance(0, 2), 50);
|
||||
assert_ok!(Assets::burn(Origin::signed(1), 0, 1, u64::max_value()));
|
||||
assert_ok!(Assets::burn(Origin::signed(1), 0, 1, u64::MAX));
|
||||
assert_eq!(Assets::balance(0, 1), 0);
|
||||
assert_noop!(Assets::transfer(Origin::signed(1), 0, 1, 50), Error::<Test>::BalanceLow);
|
||||
assert_noop!(Assets::transfer(Origin::signed(2), 0, 1, 51), Error::<Test>::BalanceLow);
|
||||
@@ -491,7 +491,7 @@ fn burning_asset_balance_with_positive_balance_should_work() {
|
||||
assert_ok!(Assets::force_create(Origin::root(), 0, 1, true, 1));
|
||||
assert_ok!(Assets::mint(Origin::signed(1), 0, 1, 100));
|
||||
assert_eq!(Assets::balance(0, 1), 100);
|
||||
assert_ok!(Assets::burn(Origin::signed(1), 0, 1, u64::max_value()));
|
||||
assert_ok!(Assets::burn(Origin::signed(1), 0, 1, u64::MAX));
|
||||
assert_eq!(Assets::balance(0, 1), 0);
|
||||
});
|
||||
}
|
||||
@@ -502,7 +502,7 @@ fn burning_asset_balance_with_zero_balance_does_nothing() {
|
||||
assert_ok!(Assets::force_create(Origin::root(), 0, 1, true, 1));
|
||||
assert_ok!(Assets::mint(Origin::signed(1), 0, 1, 100));
|
||||
assert_eq!(Assets::balance(0, 2), 0);
|
||||
assert_ok!(Assets::burn(Origin::signed(1), 0, 2, u64::max_value()));
|
||||
assert_ok!(Assets::burn(Origin::signed(1), 0, 2, u64::MAX));
|
||||
assert_eq!(Assets::balance(0, 2), 0);
|
||||
assert_eq!(Assets::total_supply(0), 100);
|
||||
});
|
||||
|
||||
@@ -184,7 +184,7 @@ parameter_types! {
|
||||
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
|
||||
pub const MaxNominatorRewardedPerValidator: u32 = 64;
|
||||
pub const ElectionLookahead: u64 = 0;
|
||||
pub const StakingUnsignedPriority: u64 = u64::max_value() / 2;
|
||||
pub const StakingUnsignedPriority: u64 = u64::MAX / 2;
|
||||
}
|
||||
|
||||
impl onchain::Config for Test {
|
||||
|
||||
@@ -87,7 +87,7 @@ macro_rules! decl_tests {
|
||||
#[test]
|
||||
fn lock_removal_should_work() {
|
||||
<$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| {
|
||||
Balances::set_lock(ID_1, &1, u64::max_value(), WithdrawReasons::all());
|
||||
Balances::set_lock(ID_1, &1, u64::MAX, WithdrawReasons::all());
|
||||
Balances::remove_lock(ID_1, &1);
|
||||
assert_ok!(<Balances as Currency<_>>::transfer(&1, &2, 1, AllowDeath));
|
||||
});
|
||||
@@ -96,7 +96,7 @@ macro_rules! decl_tests {
|
||||
#[test]
|
||||
fn lock_replacement_should_work() {
|
||||
<$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| {
|
||||
Balances::set_lock(ID_1, &1, u64::max_value(), WithdrawReasons::all());
|
||||
Balances::set_lock(ID_1, &1, u64::MAX, WithdrawReasons::all());
|
||||
Balances::set_lock(ID_1, &1, 5, WithdrawReasons::all());
|
||||
assert_ok!(<Balances as Currency<_>>::transfer(&1, &2, 1, AllowDeath));
|
||||
});
|
||||
@@ -114,7 +114,7 @@ macro_rules! decl_tests {
|
||||
#[test]
|
||||
fn combination_locking_should_work() {
|
||||
<$ext_builder>::default().existential_deposit(1).monied(true).build().execute_with(|| {
|
||||
Balances::set_lock(ID_1, &1, u64::max_value(), WithdrawReasons::empty());
|
||||
Balances::set_lock(ID_1, &1, u64::MAX, WithdrawReasons::empty());
|
||||
Balances::set_lock(ID_2, &1, 0, WithdrawReasons::all());
|
||||
assert_ok!(<Balances as Currency<_>>::transfer(&1, &2, 1, AllowDeath));
|
||||
});
|
||||
@@ -513,15 +513,15 @@ macro_rules! decl_tests {
|
||||
#[test]
|
||||
fn transferring_too_high_value_should_not_panic() {
|
||||
<$ext_builder>::default().build().execute_with(|| {
|
||||
Balances::make_free_balance_be(&1, u64::max_value());
|
||||
Balances::make_free_balance_be(&1, u64::MAX);
|
||||
Balances::make_free_balance_be(&2, 1);
|
||||
|
||||
assert_err!(
|
||||
Balances::transfer(Some(1).into(), 2, u64::max_value()),
|
||||
Balances::transfer(Some(1).into(), 2, u64::MAX),
|
||||
ArithmeticError::Overflow,
|
||||
);
|
||||
|
||||
assert_eq!(Balances::free_balance(1), u64::max_value());
|
||||
assert_eq!(Balances::free_balance(1), u64::MAX);
|
||||
assert_eq!(Balances::free_balance(2), 1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ where
|
||||
// storage_size cannot be zero because otherwise a contract that is just above
|
||||
// the subsistence threshold does not pay rent given a large enough subsistence
|
||||
// threshold. But we need rent payments to occur in order to benchmark for worst cases.
|
||||
let storage_size = u32::max_value() / 10;
|
||||
let storage_size = u32::MAX / 10;
|
||||
|
||||
// Endowment should be large but not as large to inhibit rent payments.
|
||||
// Balance will only cover half the storage
|
||||
|
||||
@@ -334,7 +334,7 @@ where
|
||||
///
|
||||
/// If the contract supplied buffer is smaller than the passed `buffer` an `Err` is returned.
|
||||
/// If `allow_skip` is set to true the contract is allowed to skip the copying of the buffer
|
||||
/// by supplying the guard value of `u32::max_value()` as `out_ptr`. The
|
||||
/// by supplying the guard value of `u32::MAX` as `out_ptr`. The
|
||||
/// `weight_per_byte` is only charged when the write actually happens and is not skipped or
|
||||
/// failed due to a too small output buffer.
|
||||
pub fn write(
|
||||
|
||||
@@ -550,7 +550,7 @@ where
|
||||
/// length of the buffer located at `out_ptr`. If that buffer is large enough the actual
|
||||
/// `buf.len()` is written to this location.
|
||||
///
|
||||
/// If `out_ptr` is set to the sentinel value of `u32::max_value()` and `allow_skip` is true the
|
||||
/// If `out_ptr` is set to the sentinel value of `u32::MAX` and `allow_skip` is true the
|
||||
/// operation is skipped and `Ok` is returned. This is supposed to help callers to make copying
|
||||
/// output optional. For example to skip copying back the output buffer of an `seal_call`
|
||||
/// when the caller is not interested in the result.
|
||||
@@ -570,7 +570,7 @@ where
|
||||
create_token: impl FnOnce(u32) -> Option<RuntimeCosts>,
|
||||
) -> Result<(), DispatchError>
|
||||
{
|
||||
if allow_skip && out_ptr == u32::max_value() {
|
||||
if allow_skip && out_ptr == u32::MAX {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -892,7 +892,7 @@ define_env!(Env, <E: Ext>,
|
||||
//
|
||||
// The callees output buffer is copied to `output_ptr` and its length to `output_len_ptr`.
|
||||
// The copy of the output buffer can be skipped by supplying the sentinel value
|
||||
// of `u32::max_value()` to `output_ptr`.
|
||||
// of `u32::MAX` to `output_ptr`.
|
||||
//
|
||||
// # Parameters
|
||||
//
|
||||
@@ -953,7 +953,7 @@ define_env!(Env, <E: Ext>,
|
||||
// by the code hash. The address of this new account is copied to `address_ptr` and its length
|
||||
// to `address_len_ptr`. The constructors output buffer is copied to `output_ptr` and its
|
||||
// length to `output_len_ptr`. The copy of the output buffer and address can be skipped by
|
||||
// supplying the sentinel value of `u32::max_value()` to `output_ptr` or `address_ptr`.
|
||||
// supplying the sentinel value of `u32::MAX` to `output_ptr` or `address_ptr`.
|
||||
//
|
||||
// After running the constructor it is verified that the contract account holds at
|
||||
// least the subsistence threshold. If that is not the case the instantiation fails and
|
||||
|
||||
@@ -118,13 +118,13 @@ benchmarks! {
|
||||
// Create s existing "seconds"
|
||||
for i in 0 .. s {
|
||||
let seconder = funded_account::<T>("seconder", i);
|
||||
Democracy::<T>::second(RawOrigin::Signed(seconder).into(), 0, u32::max_value())?;
|
||||
Democracy::<T>::second(RawOrigin::Signed(seconder).into(), 0, u32::MAX)?;
|
||||
}
|
||||
|
||||
let deposits = Democracy::<T>::deposit_of(0).ok_or("Proposal not created")?;
|
||||
assert_eq!(deposits.0.len(), (s + 1) as usize, "Seconds not recorded");
|
||||
whitelist_account!(caller);
|
||||
}: _(RawOrigin::Signed(caller), 0, u32::max_value())
|
||||
}: _(RawOrigin::Signed(caller), 0, u32::MAX)
|
||||
verify {
|
||||
let deposits = Democracy::<T>::deposit_of(0).ok_or("Proposal not created")?;
|
||||
assert_eq!(deposits.0.len(), (s + 2) as usize, "`second` benchmark did not work");
|
||||
@@ -609,7 +609,7 @@ benchmarks! {
|
||||
|
||||
let caller = funded_account::<T>("caller", 0);
|
||||
whitelist_account!(caller);
|
||||
}: _(RawOrigin::Signed(caller), proposal_hash.clone(), u32::max_value())
|
||||
}: _(RawOrigin::Signed(caller), proposal_hash.clone(), u32::MAX)
|
||||
verify {
|
||||
let proposal_hash = T::Hashing::hash(&encoded_proposal[..]);
|
||||
assert!(!Preimages::<T>::contains_key(proposal_hash));
|
||||
|
||||
@@ -23,11 +23,11 @@ use frame_support::storage::{migration, unhashed};
|
||||
#[test]
|
||||
fn test_decode_compact_u32_at() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let v = codec::Compact(u64::max_value());
|
||||
let v = codec::Compact(u64::MAX);
|
||||
migration::put_storage_value(b"test", b"", &[], v);
|
||||
assert_eq!(decode_compact_u32_at(b"test"), None);
|
||||
|
||||
for v in vec![0, 10, u32::max_value()] {
|
||||
for v in vec![0, 10, u32::MAX] {
|
||||
let compact_v = codec::Compact(v);
|
||||
unhashed::put(b"test", &compact_v);
|
||||
assert_eq!(decode_compact_u32_at(b"test"), Some(v));
|
||||
|
||||
@@ -81,11 +81,11 @@ fn preimage_deposit_should_be_reapable_earlier_by_owner() {
|
||||
|
||||
next_block();
|
||||
assert_noop!(
|
||||
Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2), u32::max_value()),
|
||||
Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2), u32::MAX),
|
||||
Error::<Test>::TooEarly
|
||||
);
|
||||
next_block();
|
||||
assert_ok!(Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2), u32::max_value()));
|
||||
assert_ok!(Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2), u32::MAX));
|
||||
|
||||
assert_eq!(Balances::free_balance(6), 60);
|
||||
assert_eq!(Balances::reserved_balance(6), 0);
|
||||
@@ -96,7 +96,7 @@ fn preimage_deposit_should_be_reapable_earlier_by_owner() {
|
||||
fn preimage_deposit_should_be_reapable() {
|
||||
new_test_ext_execute_with_cond(|operational| {
|
||||
assert_noop!(
|
||||
Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2), u32::max_value()),
|
||||
Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2), u32::MAX),
|
||||
Error::<Test>::PreimageMissing
|
||||
);
|
||||
|
||||
@@ -111,12 +111,12 @@ fn preimage_deposit_should_be_reapable() {
|
||||
next_block();
|
||||
next_block();
|
||||
assert_noop!(
|
||||
Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2), u32::max_value()),
|
||||
Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2), u32::MAX),
|
||||
Error::<Test>::TooEarly
|
||||
);
|
||||
|
||||
next_block();
|
||||
assert_ok!(Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2), u32::max_value()));
|
||||
assert_ok!(Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2), u32::MAX));
|
||||
assert_eq!(Balances::reserved_balance(6), 0);
|
||||
assert_eq!(Balances::free_balance(6), 48);
|
||||
assert_eq!(Balances::free_balance(5), 62);
|
||||
@@ -161,7 +161,7 @@ fn reaping_imminent_preimage_should_fail() {
|
||||
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
|
||||
next_block();
|
||||
next_block();
|
||||
assert_noop!(Democracy::reap_preimage(Origin::signed(6), h, u32::max_value()), Error::<Test>::Imminent);
|
||||
assert_noop!(Democracy::reap_preimage(Origin::signed(6), h, u32::MAX), Error::<Test>::Imminent);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,10 +35,10 @@ fn backing_for_should_work() {
|
||||
fn deposit_for_proposals_should_be_taken() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(propose_set_balance_and_note(1, 2, 5));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0, u32::max_value()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::max_value()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::max_value()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::max_value()));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_eq!(Balances::free_balance(1), 5);
|
||||
assert_eq!(Balances::free_balance(2), 15);
|
||||
assert_eq!(Balances::free_balance(5), 35);
|
||||
@@ -49,10 +49,10 @@ fn deposit_for_proposals_should_be_taken() {
|
||||
fn deposit_for_proposals_should_be_returned() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(propose_set_balance_and_note(1, 2, 5));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0, u32::max_value()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::max_value()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::max_value()));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::max_value()));
|
||||
assert_ok!(Democracy::second(Origin::signed(2), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
assert_ok!(Democracy::second(Origin::signed(5), 0, u32::MAX));
|
||||
fast_forward_to(3);
|
||||
assert_eq!(Balances::free_balance(1), 10);
|
||||
assert_eq!(Balances::free_balance(2), 20);
|
||||
@@ -79,7 +79,7 @@ fn poor_seconder_should_not_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(propose_set_balance_and_note(2, 2, 11));
|
||||
assert_noop!(
|
||||
Democracy::second(Origin::signed(1), 0, u32::max_value()),
|
||||
Democracy::second(Origin::signed(1), 0, u32::MAX),
|
||||
BalancesError::<Test, _>::InsufficientBalance
|
||||
);
|
||||
});
|
||||
|
||||
@@ -166,7 +166,7 @@ fn signed_ext_watch_dummy_works() {
|
||||
WatchDummy::<Test>(PhantomData).validate(&1, &call, &info, 150)
|
||||
.unwrap()
|
||||
.priority,
|
||||
u64::max_value(),
|
||||
u64::MAX,
|
||||
);
|
||||
assert_eq!(
|
||||
WatchDummy::<Test>(PhantomData).validate(&1, &call, &info, 250),
|
||||
|
||||
@@ -190,7 +190,7 @@ parameter_types! {
|
||||
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
|
||||
pub const MaxNominatorRewardedPerValidator: u32 = 64;
|
||||
pub const ElectionLookahead: u64 = 0;
|
||||
pub const StakingUnsignedPriority: u64 = u64::max_value() / 2;
|
||||
pub const StakingUnsignedPriority: u64 = u64::MAX / 2;
|
||||
}
|
||||
|
||||
impl onchain::Config for Test {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -42,20 +42,20 @@ pub trait CurrencyToVote<B> {
|
||||
|
||||
/// An implementation of `CurrencyToVote` tailored for chain's that have a balance type of u128.
|
||||
///
|
||||
/// The factor is the `(total_issuance / u64::max()).max(1)`, represented as u64. Let's look at the
|
||||
/// The factor is the `(total_issuance / u64::MAX).max(1)`, represented as u64. Let's look at the
|
||||
/// important cases:
|
||||
///
|
||||
/// If the chain's total issuance is less than u64::max(), this will always be 1, which means that
|
||||
/// If the chain's total issuance is less than u64::MAX, this will always be 1, which means that
|
||||
/// the factor will not have any effect. In this case, any account's balance is also less. Thus,
|
||||
/// both of the conversions are basically an `as`; Any balance can fit in u64.
|
||||
///
|
||||
/// If the chain's total issuance is more than 2*u64::max(), then a factor might be multiplied and
|
||||
/// If the chain's total issuance is more than 2*u64::MAX, then a factor might be multiplied and
|
||||
/// divided upon conversion.
|
||||
pub struct U128CurrencyToVote;
|
||||
|
||||
impl U128CurrencyToVote {
|
||||
fn factor(issuance: u128) -> u128 {
|
||||
(issuance / u64::max_value() as u128).max(1)
|
||||
(issuance / u64::MAX as u128).max(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ impl<'a> OneOrMany<DispatchClass> for &'a [DispatchClass] {
|
||||
|
||||
/// Primitives related to priority management of Frame.
|
||||
pub mod priority {
|
||||
/// The starting point of all Operational transactions. 3/4 of u64::max_value().
|
||||
/// The starting point of all Operational transactions. 3/4 of u64::MAX.
|
||||
pub const LIMIT: u64 = 13_835_058_055_282_163_711_u64;
|
||||
|
||||
/// Wrapper for priority of different dispatch classes.
|
||||
|
||||
@@ -43,7 +43,7 @@ frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
fn deposit_event() = default;
|
||||
type Error = Error<T>;
|
||||
const Foo: u32 = u32::max_value();
|
||||
const Foo: u32 = u32::MAX;
|
||||
|
||||
#[weight = 0]
|
||||
fn accumulate_dummy(_origin, _increase_by: T::Balance) {
|
||||
|
||||
@@ -778,7 +778,7 @@ fn hash69<T: AsMut<[u8]> + Default>() -> T {
|
||||
/// This type alias represents an index of an event.
|
||||
///
|
||||
/// We use `u32` here because this index is used as index for `Events<T>`
|
||||
/// which can't contain more than `u32::max_value()` items.
|
||||
/// which can't contain more than `u32::MAX` items.
|
||||
type EventIndex = u32;
|
||||
|
||||
/// Type used to encode the number of references an account has.
|
||||
|
||||
@@ -1142,11 +1142,11 @@ mod tests {
|
||||
};
|
||||
assert_eq!(
|
||||
Module::<Runtime>::compute_fee(
|
||||
<u32>::max_value(),
|
||||
u32::MAX,
|
||||
&dispatch_info,
|
||||
<u64>::max_value()
|
||||
u64::MAX
|
||||
),
|
||||
<u64>::max_value()
|
||||
u64::MAX
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -367,8 +367,8 @@ fn genesis_funding_works() {
|
||||
#[test]
|
||||
fn max_approvals_limited() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), u64::max_value());
|
||||
Balances::make_free_balance_be(&0, u64::max_value());
|
||||
Balances::make_free_balance_be(&Treasury::account_id(), u64::MAX);
|
||||
Balances::make_free_balance_be(&0, u64::MAX);
|
||||
|
||||
for _ in 0 .. MaxApprovals::get() {
|
||||
assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3));
|
||||
|
||||
Reference in New Issue
Block a user