mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 08:01:09 +00:00
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:
committed by
GitHub
parent
4dc50c8d89
commit
c312f0b9a6
@@ -92,18 +92,19 @@ async fn collect_relay_storage_proof(
|
||||
.ok()?
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut relevant_keys = Vec::new();
|
||||
relevant_keys.push(relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::TWO_EPOCHS_AGO_RANDOMNESS.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::CURRENT_SLOT.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::ACTIVE_CONFIG.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::dmq_mqc_head(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::relay_dispatch_queue_size(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::hrmp_ingress_channel_index(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::hrmp_egress_channel_index(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::upgrade_go_ahead_signal(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::upgrade_restriction_signal(para_id));
|
||||
let mut relevant_keys = vec![
|
||||
relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS.to_vec(),
|
||||
relay_well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec(),
|
||||
relay_well_known_keys::TWO_EPOCHS_AGO_RANDOMNESS.to_vec(),
|
||||
relay_well_known_keys::CURRENT_SLOT.to_vec(),
|
||||
relay_well_known_keys::ACTIVE_CONFIG.to_vec(),
|
||||
relay_well_known_keys::dmq_mqc_head(para_id),
|
||||
relay_well_known_keys::relay_dispatch_queue_size(para_id),
|
||||
relay_well_known_keys::hrmp_ingress_channel_index(para_id),
|
||||
relay_well_known_keys::hrmp_egress_channel_index(para_id),
|
||||
relay_well_known_keys::upgrade_go_ahead_signal(para_id),
|
||||
relay_well_known_keys::upgrade_restriction_signal(para_id),
|
||||
];
|
||||
relevant_keys.extend(ingress_channels.into_iter().map(|sender| {
|
||||
relay_well_known_keys::hrmp_channels(HrmpChannelId { sender, recipient: para_id })
|
||||
}));
|
||||
|
||||
@@ -160,8 +160,8 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
|
||||
self.relay_offset + self.relay_blocks_per_para_block * self.current_para_block;
|
||||
|
||||
// Use the "sproof" (spoof proof) builder to build valid mock state root and proof.
|
||||
let mut sproof_builder = RelayStateSproofBuilder::default();
|
||||
sproof_builder.para_id = self.xcm_config.para_id;
|
||||
let mut sproof_builder =
|
||||
RelayStateSproofBuilder { para_id: self.xcm_config.para_id, ..Default::default() };
|
||||
|
||||
// Process the downward messages and set up the correct head
|
||||
let mut downward_messages = Vec::new();
|
||||
|
||||
@@ -99,7 +99,7 @@ mod tests {
|
||||
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| Header::decode(&mut &v.head_data.0[..]).expect("Decodes `Header`."))
|
||||
}
|
||||
@@ -175,7 +175,7 @@ mod tests {
|
||||
(slot_timestamp * 10, false),
|
||||
] {
|
||||
let output = Command::new(env::current_exe().unwrap())
|
||||
.args(&["check_timestamp_inherent_works", "--", "--nocapture"])
|
||||
.args(["check_timestamp_inherent_works", "--", "--nocapture"])
|
||||
.env("RUN_TEST", "1")
|
||||
.env("TIMESTAMP", timestamp.to_string())
|
||||
.output()
|
||||
|
||||
@@ -163,7 +163,7 @@ impl<
|
||||
|
||||
// Get the local asset id in which we can pay for fees
|
||||
let (local_asset_id, _) =
|
||||
Matcher::matches_fungibles(&first).map_err(|_| XcmError::AssetNotFound)?;
|
||||
Matcher::matches_fungibles(first).map_err(|_| XcmError::AssetNotFound)?;
|
||||
|
||||
// Calculate how much we should charge in the asset_id for such amount of weight
|
||||
// Require at least a payment of minimum_balance
|
||||
@@ -181,7 +181,7 @@ impl<
|
||||
.map_err(|_| XcmError::Overflow)?;
|
||||
|
||||
// Convert to the same kind of multiasset, with the required fungible balance
|
||||
let required = first.id.clone().into_multiasset(asset_balance.into());
|
||||
let required = first.id.into_multiasset(asset_balance.into());
|
||||
|
||||
// Substract payment
|
||||
let unused = payment.checked_sub(required.clone()).map_err(|_| XcmError::TooExpensive)?;
|
||||
@@ -204,7 +204,7 @@ impl<
|
||||
{
|
||||
// Get the local asset id in which we can refund fees
|
||||
let (local_asset_id, outstanding_balance) =
|
||||
Matcher::matches_fungibles(&(id.clone(), fun).into()).ok()?;
|
||||
Matcher::matches_fungibles(&(id, fun).into()).ok()?;
|
||||
|
||||
let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id);
|
||||
|
||||
@@ -233,8 +233,7 @@ impl<
|
||||
let asset_balance: u128 = asset_balance.saturated_into();
|
||||
|
||||
// Construct outstanding_concrete_asset with the same location id and substracted balance
|
||||
let outstanding_concrete_asset: MultiAsset =
|
||||
(id.clone(), outstanding_minus_substracted).into();
|
||||
let outstanding_concrete_asset: MultiAsset = (id, outstanding_minus_substracted).into();
|
||||
|
||||
// Substract from existing weight and balance
|
||||
weight_outstanding = weight_outstanding.saturating_sub(weight);
|
||||
@@ -365,7 +364,7 @@ mod tests {
|
||||
|
||||
// ParentAsUmp - 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),
|
||||
@@ -373,7 +372,7 @@ mod tests {
|
||||
);
|
||||
|
||||
// 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
|
||||
@@ -393,7 +392,7 @@ mod tests {
|
||||
|
||||
// ParentAsUmp - check dest/msg is valid
|
||||
let dest = (Parent, Here);
|
||||
let mut dest_wrapper = Some(dest.clone().into());
|
||||
let mut dest_wrapper = Some(dest.into());
|
||||
let mut msg_wrapper = Some(message.clone());
|
||||
assert!(<ParentAsUmp<(), (), ()> as SendXcm>::validate(
|
||||
&mut dest_wrapper,
|
||||
@@ -529,16 +528,13 @@ mod tests {
|
||||
|
||||
// prepare test data
|
||||
let asset: MultiAsset = (Here, AMOUNT).into();
|
||||
let payment = Assets::from(asset.clone());
|
||||
let payment = Assets::from(asset);
|
||||
let weight_to_buy = Weight::from_parts(1_000, 1_000);
|
||||
|
||||
// lets do first call (success)
|
||||
assert_ok!(trader.buy_weight(weight_to_buy, payment.clone()));
|
||||
|
||||
// lets do second call (error)
|
||||
assert_eq!(
|
||||
trader.buy_weight(weight_to_buy, payment.clone()),
|
||||
Err(XcmError::NotWithdrawable)
|
||||
);
|
||||
assert_eq!(trader.buy_weight(weight_to_buy, payment), Err(XcmError::NotWithdrawable));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user