Fix Clippy (#2522)

* Import Clippy config from Polkadot

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Auto clippy fix

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* No tabs in comments

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Prefer matches

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Dont drop references

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Trivial

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Refactor

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* fmt

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* add clippy to ci

* Clippy reborrow

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update client/pov-recovery/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update client/pov-recovery/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Partially revert 'Prefer matches'

Using matches! instead of match does give less compiler
checks as per review from @chevdor.

Partially reverts 8c0609677f3ea040f77fffd5be6facf7c3fec95c

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update .cargo/config.toml

Co-authored-by: Chevdor <chevdor@users.noreply.github.com>

* Revert revert 💩

Should be fine to use matches! macro since it is an explicit whitelist,
not wildcard matching.

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: alvicsam <alvicsam@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Oliver Tale-Yazdi
2023-05-06 08:01:03 +02:00
committed by GitHub
parent 4dc50c8d89
commit c312f0b9a6
92 changed files with 910 additions and 967 deletions
@@ -129,7 +129,7 @@ benchmarks! {
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
}: {
assert_ok!(
<CollatorSelection<T>>::set_desired_candidates(origin, max.clone())
<CollatorSelection<T>>::set_desired_candidates(origin, max)
);
}
verify {
@@ -142,7 +142,7 @@ benchmarks! {
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
}: {
assert_ok!(
<CollatorSelection<T>>::set_candidacy_bond(origin, bond_amount.clone())
<CollatorSelection<T>>::set_candidacy_bond(origin, bond_amount)
);
}
verify {
@@ -162,7 +162,7 @@ benchmarks! {
let caller: T::AccountId = whitelisted_caller();
let bond: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();
T::Currency::make_free_balance_be(&caller, bond.clone());
T::Currency::make_free_balance_be(&caller, bond);
<session::Pallet<T>>::set_keys(
RawOrigin::Signed(caller.clone()).into(),
+4 -4
View File
@@ -238,8 +238,8 @@ pub mod pallet {
"genesis desired_candidates are more than T::MaxCandidates",
);
<DesiredCandidates<T>>::put(&self.desired_candidates);
<CandidacyBond<T>>::put(&self.candidacy_bond);
<DesiredCandidates<T>>::put(self.desired_candidates);
<CandidacyBond<T>>::put(self.candidacy_bond);
<Invulnerables<T>>::put(bounded_invulnerables);
}
}
@@ -326,7 +326,7 @@ pub mod pallet {
if max > T::MaxCandidates::get() {
log::warn!("max > T::MaxCandidates; you might need to run benchmarks again");
}
<DesiredCandidates<T>>::put(&max);
<DesiredCandidates<T>>::put(max);
Self::deposit_event(Event::NewDesiredCandidates { desired_candidates: max });
Ok(().into())
}
@@ -339,7 +339,7 @@ pub mod pallet {
bond: BalanceOf<T>,
) -> DispatchResultWithPostInfo {
T::UpdateOrigin::ensure_origin(origin)?;
<CandidacyBond<T>>::put(&bond);
<CandidacyBond<T>>::put(bond);
Self::deposit_event(Event::NewCandidacyBond { bond_amount: bond });
Ok(().into())
}
+3 -7
View File
@@ -152,12 +152,12 @@ pub struct TestSessionHandler;
impl pallet_session::SessionHandler<u64> for TestSessionHandler {
const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID];
fn on_genesis_session<Ks: OpaqueKeys>(keys: &[(u64, Ks)]) {
SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())
SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::<Vec<_>>())
}
fn on_new_session<Ks: OpaqueKeys>(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) {
SessionChangeBlock::set(System::block_number());
dbg!(keys.len());
SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())
SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::<Vec<_>>())
}
fn on_before_session_ending() {}
fn on_disabled(_: u32) {}
@@ -195,11 +195,7 @@ parameter_types! {
pub struct IsRegistered;
impl ValidatorRegistration<u64> for IsRegistered {
fn is_registered(id: &u64) -> bool {
if *id == 7u64 {
false
} else {
true
}
*id != 7u64
}
}
+8 -8
View File
@@ -45,7 +45,7 @@ fn it_should_set_invulnerables() {
// cannot set with non-root.
assert_noop!(
CollatorSelection::set_invulnerables(RuntimeOrigin::signed(1), new_set.clone()),
CollatorSelection::set_invulnerables(RuntimeOrigin::signed(1), new_set),
BadOrigin
);
@@ -54,7 +54,7 @@ fn it_should_set_invulnerables() {
assert_noop!(
CollatorSelection::set_invulnerables(
RuntimeOrigin::signed(RootAccount::get()),
invulnerables.clone()
invulnerables
),
Error::<Test>::ValidatorNotRegistered
);
@@ -184,8 +184,8 @@ fn cannot_register_dupe_candidate() {
#[test]
fn cannot_register_as_candidate_if_poor() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(&3), 100);
assert_eq!(Balances::free_balance(&33), 0);
assert_eq!(Balances::free_balance(3), 100);
assert_eq!(Balances::free_balance(33), 0);
// works
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
@@ -208,14 +208,14 @@ fn register_as_candidate_works() {
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
// take two endowed, non-invulnerables accounts.
assert_eq!(Balances::free_balance(&3), 100);
assert_eq!(Balances::free_balance(&4), 100);
assert_eq!(Balances::free_balance(3), 100);
assert_eq!(Balances::free_balance(4), 100);
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
assert_eq!(Balances::free_balance(&3), 90);
assert_eq!(Balances::free_balance(&4), 90);
assert_eq!(Balances::free_balance(3), 90);
assert_eq!(Balances::free_balance(4), 90);
assert_eq!(CollatorSelection::candidates().len(), 2);
});
+46 -48
View File
@@ -39,93 +39,91 @@ pub trait WeightInfo {
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn set_invulnerables(b: u32) -> Weight {
Weight::from_parts(18_563_000 as u64, 0)
Weight::from_parts(18_563_000_u64, 0)
// Standard Error: 0
.saturating_add(Weight::from_parts(68_000 as u64, 0).saturating_mul(b as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
.saturating_add(Weight::from_parts(68_000_u64, 0).saturating_mul(b as u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
fn set_desired_candidates() -> Weight {
Weight::from_parts(16_363_000 as u64, 0).saturating_add(T::DbWeight::get().writes(1 as u64))
Weight::from_parts(16_363_000_u64, 0).saturating_add(T::DbWeight::get().writes(1_u64))
}
fn set_candidacy_bond() -> Weight {
Weight::from_parts(16_840_000 as u64, 0).saturating_add(T::DbWeight::get().writes(1 as u64))
Weight::from_parts(16_840_000_u64, 0).saturating_add(T::DbWeight::get().writes(1_u64))
}
fn register_as_candidate(c: u32) -> Weight {
Weight::from_parts(71_196_000 as u64, 0)
Weight::from_parts(71_196_000_u64, 0)
// Standard Error: 0
.saturating_add(Weight::from_parts(198_000 as u64, 0).saturating_mul(c as u64))
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
.saturating_add(Weight::from_parts(198_000_u64, 0).saturating_mul(c as u64))
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
fn leave_intent(c: u32) -> Weight {
Weight::from_parts(55_336_000 as u64, 0)
Weight::from_parts(55_336_000_u64, 0)
// Standard Error: 0
.saturating_add(Weight::from_parts(151_000 as u64, 0).saturating_mul(c as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
.saturating_add(Weight::from_parts(151_000_u64, 0).saturating_mul(c as u64))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
fn note_author() -> Weight {
Weight::from_parts(71_461_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(3 as u64))
.saturating_add(T::DbWeight::get().writes(4 as u64))
Weight::from_parts(71_461_000_u64, 0)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
fn new_session(r: u32, c: u32) -> Weight {
Weight::from_parts(0 as u64, 0)
Weight::from_parts(0_u64, 0)
// Standard Error: 1_010_000
.saturating_add(Weight::from_parts(109_961_000 as u64, 0).saturating_mul(r as u64))
.saturating_add(Weight::from_parts(109_961_000_u64, 0).saturating_mul(r as u64))
// Standard Error: 1_010_000
.saturating_add(Weight::from_parts(151_952_000 as u64, 0).saturating_mul(c as u64))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64)))
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64)))
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(r as u64)))
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64)))
.saturating_add(Weight::from_parts(151_952_000_u64, 0).saturating_mul(c as u64))
.saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(r as u64)))
.saturating_add(T::DbWeight::get().reads(2_u64.saturating_mul(c as u64)))
.saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(r as u64)))
.saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(c as u64)))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
fn set_invulnerables(b: u32) -> Weight {
Weight::from_parts(18_563_000 as u64, 0)
Weight::from_parts(18_563_000_u64, 0)
// Standard Error: 0
.saturating_add(Weight::from_parts(68_000 as u64, 0).saturating_mul(b as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
.saturating_add(Weight::from_parts(68_000_u64, 0).saturating_mul(b as u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
fn set_desired_candidates() -> Weight {
Weight::from_parts(16_363_000 as u64, 0)
.saturating_add(RocksDbWeight::get().writes(1 as u64))
Weight::from_parts(16_363_000_u64, 0).saturating_add(RocksDbWeight::get().writes(1_u64))
}
fn set_candidacy_bond() -> Weight {
Weight::from_parts(16_840_000 as u64, 0)
.saturating_add(RocksDbWeight::get().writes(1 as u64))
Weight::from_parts(16_840_000_u64, 0).saturating_add(RocksDbWeight::get().writes(1_u64))
}
fn register_as_candidate(c: u32) -> Weight {
Weight::from_parts(71_196_000 as u64, 0)
Weight::from_parts(71_196_000_u64, 0)
// Standard Error: 0
.saturating_add(Weight::from_parts(198_000 as u64, 0).saturating_mul(c as u64))
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(2 as u64))
.saturating_add(Weight::from_parts(198_000_u64, 0).saturating_mul(c as u64))
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
fn leave_intent(c: u32) -> Weight {
Weight::from_parts(55_336_000 as u64, 0)
Weight::from_parts(55_336_000_u64, 0)
// Standard Error: 0
.saturating_add(Weight::from_parts(151_000 as u64, 0).saturating_mul(c as u64))
.saturating_add(RocksDbWeight::get().reads(1 as u64))
.saturating_add(RocksDbWeight::get().writes(2 as u64))
.saturating_add(Weight::from_parts(151_000_u64, 0).saturating_mul(c as u64))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
fn note_author() -> Weight {
Weight::from_parts(71_461_000 as u64, 0)
.saturating_add(RocksDbWeight::get().reads(3 as u64))
.saturating_add(RocksDbWeight::get().writes(4 as u64))
Weight::from_parts(71_461_000_u64, 0)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
fn new_session(r: u32, c: u32) -> Weight {
Weight::from_parts(0 as u64, 0)
Weight::from_parts(0_u64, 0)
// Standard Error: 1_010_000
.saturating_add(Weight::from_parts(109_961_000 as u64, 0).saturating_mul(r as u64))
.saturating_add(Weight::from_parts(109_961_000_u64, 0).saturating_mul(r as u64))
// Standard Error: 1_010_000
.saturating_add(Weight::from_parts(151_952_000 as u64, 0).saturating_mul(c as u64))
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64)))
.saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(c as u64)))
.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(r as u64)))
.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(c as u64)))
.saturating_add(Weight::from_parts(151_952_000_u64, 0).saturating_mul(c as u64))
.saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(r as u64)))
.saturating_add(RocksDbWeight::get().reads(2_u64.saturating_mul(c as u64)))
.saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(r as u64)))
.saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(c as u64)))
}
}
+11 -15
View File
@@ -766,19 +766,19 @@ mod tests {
new_test_ext().execute_with(|| {
let enqueued = vec![msg(1000), msg(1001)];
enqueue(&enqueued);
let weight_used = handle_messages(&vec![msg(1002)], Weight::from_parts(1500, 1500));
let weight_used = handle_messages(&[msg(1002)], Weight::from_parts(1500, 1500));
assert_eq!(weight_used, Weight::from_parts(1000, 1000));
assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]);
assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 0);
let weight_used = handle_messages(&vec![msg(1003)], Weight::from_parts(1500, 1500));
let weight_used = handle_messages(&[msg(1003)], Weight::from_parts(1500, 1500));
assert_eq!(weight_used, Weight::from_parts(1001, 1001));
assert_eq!(take_trace(), vec![msg_complete(1001), msg_limit_reached(1002),]);
assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 1);
let weight_used = handle_messages(&vec![msg(1004)], Weight::from_parts(1500, 1500));
let weight_used = handle_messages(&[msg(1004)], Weight::from_parts(1500, 1500));
assert_eq!(weight_used, Weight::from_parts(1002, 1002));
assert_eq!(take_trace(), vec![msg_complete(1002), msg_limit_reached(1003),]);
assert_eq!(pages_queued(), 2);
@@ -877,9 +877,9 @@ mod tests {
#[test]
fn on_idle_should_service_queue() {
new_test_ext().execute_with(|| {
enqueue(&vec![msg(1000), msg(1001)]);
enqueue(&vec![msg(1002), msg(1003)]);
enqueue(&vec![msg(1004), msg(1005)]);
enqueue(&[msg(1000), msg(1001)]);
enqueue(&[msg(1002), msg(1003)]);
enqueue(&[msg(1004), msg(1005)]);
let weight_used = DmpQueue::on_idle(1, Weight::from_parts(6000, 6000));
assert_eq!(weight_used, Weight::from_parts(5010, 5010));
@@ -901,20 +901,17 @@ mod tests {
#[test]
fn handle_max_messages_per_block() {
new_test_ext().execute_with(|| {
enqueue(&vec![msg(1000), msg(1001)]);
enqueue(&vec![msg(1002), msg(1003)]);
enqueue(&vec![msg(1004), msg(1005)]);
enqueue(&[msg(1000), msg(1001)]);
enqueue(&[msg(1002), msg(1003)]);
enqueue(&[msg(1004), msg(1005)]);
let incoming = (0..MAX_MESSAGES_PER_BLOCK)
.into_iter()
.map(|i| msg(1006 + i as u64))
.collect::<Vec<_>>();
let incoming =
(0..MAX_MESSAGES_PER_BLOCK).map(|i| msg(1006 + i as u64)).collect::<Vec<_>>();
handle_messages(&incoming, Weight::from_parts(25000, 25000));
assert_eq!(
take_trace(),
(0..MAX_MESSAGES_PER_BLOCK)
.into_iter()
.map(|i| msg_complete(1000 + i as u64))
.collect::<Vec<_>>(),
);
@@ -924,7 +921,6 @@ mod tests {
assert_eq!(
take_trace(),
(MAX_MESSAGES_PER_BLOCK..MAX_MESSAGES_PER_BLOCK + 6)
.into_iter()
.map(|i| msg_complete(1000 + i as u64))
.collect::<Vec<_>>(),
);
+1 -1
View File
@@ -74,7 +74,7 @@ pub fn migrate_to_v1<T: Config>() -> Weight {
}
};
if let Err(_) = Configuration::<T>::translate(|pre| pre.map(translate)) {
if Configuration::<T>::translate(|pre| pre.map(translate)).is_err() {
log::error!(
target: "dmp_queue",
"unexpected error when performing translation of the QueueConfig type during storage upgrade to v2"
+18 -23
View File
@@ -473,10 +473,7 @@ pub mod pallet {
check_version: bool,
) -> DispatchResult {
ensure_root(origin)?;
AuthorizedUpgrade::<T>::put(CodeUpgradeAuthorization {
code_hash: code_hash.clone(),
check_version,
});
AuthorizedUpgrade::<T>::put(CodeUpgradeAuthorization { code_hash, check_version });
Self::deposit_event(Event::UpgradeAuthorized { code_hash });
Ok(())
@@ -753,7 +750,7 @@ impl<T: Config> Pallet<T> {
let authorization = AuthorizedUpgrade::<T>::get().ok_or(Error::<T>::NothingAuthorized)?;
// ensure that the actual hash matches the authorized hash
let actual_hash = T::Hashing::hash(&code[..]);
let actual_hash = T::Hashing::hash(code);
ensure!(actual_hash == authorization.code_hash, Error::<T>::Unauthorized);
// check versions if required as part of the authorization
@@ -941,10 +938,10 @@ impl<T: Config> Pallet<T> {
// `running_mqc_heads`. Otherwise, in a block where no messages were sent in a channel
// it won't get into next block's `last_mqc_heads` and thus will be all zeros, which
// would corrupt the message queue chain.
for &(ref sender, ref channel) in ingress_channels {
for (sender, channel) in ingress_channels {
let cur_head = running_mqc_heads
.entry(sender)
.or_insert_with(|| last_mqc_heads.get(&sender).cloned().unwrap_or_default())
.or_insert_with(|| last_mqc_heads.get(sender).cloned().unwrap_or_default())
.head();
let target_head = channel.mqc_head.unwrap_or_default();
@@ -1090,22 +1087,20 @@ impl<T: Config> Pallet<T> {
// may change so that the message is no longer valid.
//
// However, changing this setting is expected to be rare.
match Self::host_configuration() {
Some(cfg) =>
if message.len() > cfg.max_upward_message_size as usize {
return Err(MessageSendError::TooBig)
},
None => {
// This storage field should carry over from the previous block. So if it's None
// then it must be that this is an edge-case where a message is attempted to be
// sent at the first block.
//
// Let's pass this message through. I think it's not unreasonable to expect that
// the message is not huge and it comes through, but if it doesn't it can be
// returned back to the sender.
//
// Thus fall through here.
},
if let Some(cfg) = Self::host_configuration() {
if message.len() > cfg.max_upward_message_size as usize {
return Err(MessageSendError::TooBig)
}
} else {
// This storage field should carry over from the previous block. So if it's None
// then it must be that this is an edge-case where a message is attempted to be
// sent at the first block.
//
// Let's pass this message through. I think it's not unreasonable to expect that
// the message is not huge and it comes through, but if it doesn't it can be
// returned back to the sender.
//
// Thus fall through here.
};
<PendingUpwardMessages<T>>::append(message.clone());
+8 -11
View File
@@ -304,7 +304,7 @@ impl BlockTests {
// begin initialization
System::reset_events();
System::initialize(&n, &Default::default(), &Default::default());
System::initialize(n, &Default::default(), &Default::default());
// now mess with the storage the way validate_block does
let mut sproof_builder = RelayStateSproofBuilder::default();
@@ -357,10 +357,8 @@ impl BlockTests {
ParachainSystem::on_finalize(*n);
// did block execution set new validation code?
if NewValidationCode::<Test>::exists() {
if self.pending_upgrade.is_some() {
panic!("attempted to set validation code while upgrade was pending");
}
if NewValidationCode::<Test>::exists() && self.pending_upgrade.is_some() {
panic!("attempted to set validation code while upgrade was pending");
}
// clean up
@@ -404,7 +402,7 @@ fn events() {
let events = System::events();
assert_eq!(
events[0].event,
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionStored.into())
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionStored)
);
},
)
@@ -415,10 +413,9 @@ fn events() {
let events = System::events();
assert_eq!(
events[0].event,
RuntimeEvent::ParachainSystem(
crate::Event::ValidationFunctionApplied { relay_chain_block_num: 1234 }
.into()
)
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionApplied {
relay_chain_block_num: 1234
})
);
},
);
@@ -491,7 +488,7 @@ fn aborted_upgrade() {
let events = System::events();
assert_eq!(
events[0].event,
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionDiscarded.into())
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionDiscarded)
);
},
);
@@ -41,7 +41,7 @@ fn call_validate_block_encoded_header(
relay_parent_number: 1,
relay_parent_storage_root,
},
&WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"),
WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"),
)
.map(|v| v.head_data.0)
}
@@ -191,7 +191,7 @@ fn validate_block_invalid_parent_hash() {
.unwrap_err();
} else {
let output = Command::new(env::current_exe().unwrap())
.args(&["validate_block_invalid_parent_hash", "--", "--nocapture"])
.args(["validate_block_invalid_parent_hash", "--", "--nocapture"])
.env("RUN_TEST", "1")
.output()
.expect("Runs the test");
@@ -213,7 +213,7 @@ fn validate_block_fails_on_invalid_validation_data() {
call_validate_block(parent_head, block, Hash::random()).unwrap_err();
} else {
let output = Command::new(env::current_exe().unwrap())
.args(&["validate_block_fails_on_invalid_validation_data", "--", "--nocapture"])
.args(["validate_block_fails_on_invalid_validation_data", "--", "--nocapture"])
.env("RUN_TEST", "1")
.output()
.expect("Runs the test");
@@ -242,7 +242,7 @@ fn check_inherent_fails_on_validate_block_as_expected() {
.unwrap_err();
} else {
let output = Command::new(env::current_exe().unwrap())
.args(&["check_inherent_fails_on_validate_block_as_expected", "--", "--nocapture"])
.args(["check_inherent_fails_on_validate_block_as_expected", "--", "--nocapture"])
.env("RUN_TEST", "1")
.output()
.expect("Runs the test");
@@ -276,7 +276,7 @@ fn check_inherents_are_unsigned_and_before_all_other_extrinsics() {
.unwrap_err();
} else {
let output = Command::new(env::current_exe().unwrap())
.args(&[
.args([
"check_inherents_are_unsigned_and_before_all_other_extrinsics",
"--",
"--nocapture",
+1 -1
View File
@@ -538,7 +538,7 @@ impl<T: Config> Pallet<T> {
return false
}
s.extend_from_slice(&data[..]);
return true
true
});
if appended {
Ok((details.last_index - details.first_index - 1) as u32)
+1 -1
View File
@@ -94,7 +94,7 @@ pub fn migrate_to_v2<T: Config>() -> Weight {
}
};
if let Err(_) = QueueConfig::<T>::translate(|pre| pre.map(translate)) {
if QueueConfig::<T>::translate(|pre| pre.map(translate)).is_err() {
log::error!(
target: super::LOG_TARGET,
"unexpected error when performing translation of the QueueConfig type during storage upgrade to v2"
+1 -1
View File
@@ -120,7 +120,7 @@ impl cumulus_pallet_parachain_system::Config for Test {
parameter_types! {
pub const RelayChain: MultiLocation = MultiLocation::parent();
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32.into())).into();
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32));
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000, 1024);
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
+6 -6
View File
@@ -23,7 +23,7 @@ use sp_runtime::traits::BadOrigin;
fn one_message_does_not_panic() {
new_test_ext().execute_with(|| {
let message_format = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
let messages = vec![(Default::default(), 1u32.into(), message_format.as_slice())];
let messages = vec![(Default::default(), 1u32, message_format.as_slice())];
// This shouldn't cause a panic
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX);
@@ -128,7 +128,7 @@ fn suspend_xcm_execution_works() {
.encode();
let mut message_format = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
message_format.extend(xcm.clone());
let messages = vec![(ParaId::from(999), 1u32.into(), message_format.as_slice())];
let messages = vec![(ParaId::from(999), 1u32, message_format.as_slice())];
// This should have executed the incoming XCM, because it came from a system parachain
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX);
@@ -136,7 +136,7 @@ fn suspend_xcm_execution_works() {
let queued_xcm = InboundXcmpMessages::<Test>::get(ParaId::from(999), 1u32);
assert!(queued_xcm.is_empty());
let messages = vec![(ParaId::from(2000), 1u32.into(), message_format.as_slice())];
let messages = vec![(ParaId::from(2000), 1u32, message_format.as_slice())];
// This shouldn't have executed the incoming XCM
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX);
@@ -294,7 +294,7 @@ fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() {
// XcmpQueue - check dest is really not applicable
let dest = (Parent, Parent, Parent);
let mut dest_wrapper = Some(dest.clone().into());
let mut dest_wrapper = Some(dest.into());
let mut msg_wrapper = Some(message.clone());
assert_eq!(
Err(SendError::NotApplicable),
@@ -302,7 +302,7 @@ fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() {
);
// check wrapper were not consumed
assert_eq!(Some(dest.clone().into()), dest_wrapper.take());
assert_eq!(Some(dest.into()), dest_wrapper.take());
assert_eq!(Some(message.clone()), msg_wrapper.take());
// another try with router chain with asserting sender
@@ -322,7 +322,7 @@ fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() {
// XcmpQueue - check dest/msg is valid
let dest = (Parent, X1(Parachain(5555)));
let mut dest_wrapper = Some(dest.clone().into());
let mut dest_wrapper = Some(dest.into());
let mut msg_wrapper = Some(message.clone());
assert!(<XcmpQueue as SendXcm>::validate(&mut dest_wrapper, &mut msg_wrapper).is_ok());
+12 -12
View File
@@ -18,31 +18,31 @@ pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_u32() -> Weight {
Weight::from_parts(2_717_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
Weight::from_parts(2_717_000_u64, 0)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_weight() -> Weight {
Weight::from_parts(2_717_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
Weight::from_parts(2_717_000_u64, 0)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}
impl WeightInfo for () {
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_u32() -> Weight {
Weight::from_parts(2_717_000 as u64, 0)
.saturating_add(RocksDbWeight::get().reads(1 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
Weight::from_parts(2_717_000_u64, 0)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
// Storage: XcmpQueue QueueConfig (r:1 w:1)
fn set_config_with_weight() -> Weight {
Weight::from_parts(2_717_000 as u64, 0)
.saturating_add(RocksDbWeight::get().reads(1 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
Weight::from_parts(2_717_000_u64, 0)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}