Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn-x2 committed May 30, 2024
1 parent 112c178 commit 13c39a5
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 32 deletions.
14 changes: 7 additions & 7 deletions polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ pub type ParachainPalletXcm = pallet_xcm::Pallet<parachain::Runtime>;
// We check XCM messages recursively for blocklisted messages
fn recursively_matches_blocklisted_messages(message: &Instruction<()>) -> bool {
match message {
DepositReserveAsset { xcm, .. }
| ExportMessage { xcm, .. }
| InitiateReserveWithdraw { xcm, .. }
| InitiateTeleport { xcm, .. }
| TransferReserveAsset { xcm, .. }
| SetErrorHandler(xcm)
| SetAppendix(xcm) => xcm.iter().any(recursively_matches_blocklisted_messages),
DepositReserveAsset { xcm, .. } |
ExportMessage { xcm, .. } |
InitiateReserveWithdraw { xcm, .. } |
InitiateTeleport { xcm, .. } |
TransferReserveAsset { xcm, .. } |
SetErrorHandler(xcm) |
SetAppendix(xcm) => xcm.iter().any(recursively_matches_blocklisted_messages),
// The blocklisted message is the Transact instruction.
m => matches!(m, Transact { .. }),
}
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/delegated-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ pub(crate) fn start_era(era: sp_staking::EraIndex) {
}

pub(crate) fn eq_stake(who: AccountId, total: Balance, active: Balance) -> bool {
Staking::stake(&who).unwrap() == Stake { total, active }
&& get_agent(&who).ledger.stakeable_balance() == total
Staking::stake(&who).unwrap() == Stake { total, active } &&
get_agent(&who).ledger.stakeable_balance() == total
}

pub(crate) fn get_agent(agent: &AccountId) -> Agent<T> {
Expand Down
10 changes: 5 additions & 5 deletions substrate/frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
//! ### Custom `TryState` logic
//!
//! You can add custom logic that should be called in your runtime on a try-state test. This is
//! done by setting an optional generic parameter after the `OnRuntimeUpgrade` type. The custom logic will be called before
//! the `try-state` logic of all modules is called.
//! done by setting an optional generic parameter after the `OnRuntimeUpgrade` type. The custom
//! logic will be called before the `try-state` logic of all modules is called.
//!
//! ```
//! # use sp_runtime::generic;
Expand Down Expand Up @@ -678,9 +678,9 @@ impl<
// Check that `parent_hash` is correct.
let n = *header.number();
assert!(
n > BlockNumberFor::<System>::zero()
&& <frame_system::Pallet<System>>::block_hash(n - BlockNumberFor::<System>::one())
== *header.parent_hash(),
n > BlockNumberFor::<System>::zero() &&
<frame_system::Pallet<System>>::block_hash(n - BlockNumberFor::<System>::one()) ==
*header.parent_hash(),
"Parent hash should be valid.",
);

Expand Down
26 changes: 13 additions & 13 deletions substrate/frame/executive/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ mod custom2 {
// Inherent call is accepted for being dispatched
fn pre_dispatch(call: &Self::Call) -> Result<(), TransactionValidityError> {
match call {
Call::allowed_unsigned { .. }
| Call::optional_inherent { .. }
| Call::inherent { .. } => Ok(()),
Call::allowed_unsigned { .. } |
Call::optional_inherent { .. } |
Call::inherent { .. } => Ok(()),
_ => Err(UnknownTransaction::NoUnsignedValidator.into()),
}
}
Expand Down Expand Up @@ -538,8 +538,8 @@ fn balance_transfer_dispatch_works() {
.assimilate_storage(&mut t)
.unwrap();
let xt = TestXt::new(call_transfer(2, 69), sign_extra(1, 0, 0));
let weight = xt.get_dispatch_info().weight
+ <Runtime as frame_system::Config>::BlockWeights::get()
let weight = xt.get_dispatch_info().weight +
<Runtime as frame_system::Config>::BlockWeights::get()
.get(DispatchClass::Normal)
.base_extrinsic;
let fee: Balance =
Expand Down Expand Up @@ -726,8 +726,8 @@ fn block_weight_and_size_is_stored_per_tx() {
let mut t = new_test_ext(1);
t.execute_with(|| {
// Block execution weight + on_initialize weight from custom module
let base_block_weight = Weight::from_parts(175, 0)
+ <Runtime as frame_system::Config>::BlockWeights::get().base_block;
let base_block_weight = Weight::from_parts(175, 0) +
<Runtime as frame_system::Config>::BlockWeights::get().base_block;

Executive::initialize_block(&Header::new_from_number(1));

Expand All @@ -739,8 +739,8 @@ fn block_weight_and_size_is_stored_per_tx() {
assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok());

// default weight for `TestXt` == encoded length.
let extrinsic_weight = Weight::from_parts(len as u64, 0)
+ <Runtime as frame_system::Config>::BlockWeights::get()
let extrinsic_weight = Weight::from_parts(len as u64, 0) +
<Runtime as frame_system::Config>::BlockWeights::get()
.get(DispatchClass::Normal)
.base_extrinsic;
assert_eq!(
Expand Down Expand Up @@ -997,10 +997,10 @@ fn all_weights_are_recorded_correctly() {
// Weights are recorded correctly
assert_eq!(
frame_system::Pallet::<Runtime>::block_weight().total(),
custom_runtime_upgrade_weight
+ runtime_upgrade_weight
+ on_initialize_weight
+ base_block_weight,
custom_runtime_upgrade_weight +
runtime_upgrade_weight +
on_initialize_weight +
base_block_weight,
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
use crate::pallet::Def;

/// * implement the individual traits using the Hooks trait
/// * implement the `TryStateLogic` and `IdentifiableTryStateLogic` traits, that are strictly dependent on the `TryState` hook
/// * implement the `TryStateLogic` and `IdentifiableTryStateLogic` traits, that are strictly
/// dependent on the `TryState` hook
pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream {
let (where_clause, span, has_runtime_upgrade) = match def.hooks.as_ref() {
Some(hooks) => {
Expand Down
8 changes: 4 additions & 4 deletions substrate/frame/support/src/traits/try_runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl sp_std::str::FromStr for Select {
match s {
"all" | "All" => Ok(Select::All),
"none" | "None" => Ok(Select::None),
_ => {
_ =>
if s.starts_with("rr-") {
let count = s
.split_once('-')
Expand All @@ -89,8 +89,7 @@ impl sp_std::str::FromStr for Select {
} else {
let pallets = s.split(',').map(|x| x.as_bytes().to_vec()).collect::<Vec<_>>();
Ok(Select::Only(pallets))
}
},
},
}
}
}
Expand Down Expand Up @@ -172,7 +171,8 @@ where

/// Logic executed when `try-state` filters are provided in the `try-runtime` CLI.
///
/// Returning `true` for the provided ID will include this `try-state` logic in the overall tests performed.
/// Returning `true` for the provided ID will include this `try-state` logic in the overall tests
/// performed.
pub trait IdentifiableTryStateLogic<BlockNumber>: TryStateLogic<BlockNumber> {
fn matches_id(_id: &[u8]) -> bool;
}
Expand Down

0 comments on commit 13c39a5

Please sign in to comment.