Skip to content

Commit

Permalink
SYS-3955 Improve length comparison part 2 (#394)
Browse files Browse the repository at this point in the history
Co-authored-by: aventus-ci-agent <ci-agent-bot@aventus.io>
  • Loading branch information
nahuseyoum and aventus-ci-agent committed May 2, 2024
1 parent 6eef552 commit f80a9ef
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 41 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lto = "fat"
codegen-units = 1

[workspace.package]
version = "5.3.0"
version = "5.3.1"
authors = ["Aventus systems team"]
homepage = "https://www.aventus.io/"
repository = "https://github.com/Aventus-Network-Services/avn-node-parachain/"
Expand Down
2 changes: 1 addition & 1 deletion node/avn-lower-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ where
leaf_filter,
)?;

if extrinsics.len() > 0 && encoded_leaf.is_some() {
if !extrinsics.is_empty() && encoded_leaf.is_some() {
let leaf = encoded_leaf.expect("Leaf exists");
let merkle_path = generate_merkle_path(&leaf, extrinsics)?;
let response = MerklePathData { encoded_leaf: leaf, merkle_path };
Expand Down
2 changes: 1 addition & 1 deletion node/avn-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ where
extrinsics_duration
);

if extrinsics.len() > 0 {
if !extrinsics.is_empty() {
let root_hash_start_time = Instant::now();
let root_hash = generate_tree_root(extrinsics)?;
let root_hash_duration = root_hash_start_time.elapsed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn set_known_sender(sender: &AccountId, config: AdjustmentInput<TestRuntime>) {
}

pub(crate) fn fee_adjusted_event_emitted() -> bool {
System::events()
let transaction_payment_event_missing = System::events()
.into_iter()
.map(|r| r.event)
.filter_map(|e| {
Expand All @@ -90,8 +90,9 @@ pub(crate) fn fee_adjusted_event_emitted() -> bool {
}
})
.collect::<Vec<_>>()
.len() >
0
.is_empty();

return transaction_payment_event_missing == false
}

/// Rolls desired block number of times.
Expand Down
2 changes: 1 addition & 1 deletion pallets/avn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl<T: Config> Pallet<T> {
let validators = Self::validators();

// If there are no validators there's no point continuing
if validators.len() == 0 {
if validators.is_empty() {
return Err(Error::<T>::NoValidatorsFound)
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/eth-bridge/src/offence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn create_and_report_corroboration_offence<T: crate::Config>(
) {
let offenders = create_offenders_identification::<T>(offenders_accounts);

if offenders.len() > 0 {
if !offenders.is_empty() {
let invalid_event_offence = CorroborationOffence {
session_index: <pallet_session::Pallet<T>>::current_index(),
validator_set_count: crate::AVN::<T>::validators().len() as u32,
Expand Down
8 changes: 4 additions & 4 deletions pallets/eth-bridge/src/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ mod add_corroboration {
.as_active_tx()
.unwrap();

assert_eq!(active_tx.data.valid_tx_hash_corroborations.len(), 0);
assert!(active_tx.data.invalid_tx_hash_corroborations.len() > 0);
assert_eq!(true, active_tx.data.valid_tx_hash_corroborations.is_empty());
assert_eq!(false, active_tx.data.invalid_tx_hash_corroborations.is_empty());
});
}

Expand All @@ -514,7 +514,7 @@ mod add_corroboration {
let context = setup_context();
let active_tx = setup_corroboration_test(&context, true, false);

assert!(active_tx.data.invalid_tx_hash_corroborations.len() > 0);
assert_eq!(false, active_tx.data.invalid_tx_hash_corroborations.is_empty());
});
}

Expand All @@ -525,7 +525,7 @@ mod add_corroboration {
let context = setup_context();
let active_tx = setup_corroboration_test(&context, true, true);

assert!(active_tx.data.valid_tx_hash_corroborations.len() > 0);
assert_eq!(false, active_tx.data.valid_tx_hash_corroborations.is_empty());
});
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/ethereum-events/src/event_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn get_data(event: &JsonValue) -> Result<Option<Vec<u8>>, SimpleError> {

let bytes = hex_to_bytes(data)?;

if bytes.len() > 0 {
if !bytes.is_empty() {
return Ok(Some(bytes))
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/ethereum-events/src/offence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn create_and_report_invalid_log_offence<T: crate::Config>(
) {
let offenders = create_offenders_identification::<T>(offenders_accounts);

if offenders.len() > 0 {
if !offenders.is_empty() {
let invalid_event_offence = InvalidEthereumLogOffence {
session_index: <pallet_session::Pallet<T>>::current_index(),
validator_set_count: <pallet_session::Pallet<T>>::validators().len() as u32,
Expand Down
2 changes: 1 addition & 1 deletion pallets/nft-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ impl<T: Config> Pallet<T> {
fn validate_external_ref(
unique_external_ref: &BoundedVec<u8, NftExternalRefBound>,
) -> DispatchResult {
ensure!(unique_external_ref.len() > 0, Error::<T>::ExternalRefIsMandatory);
ensure!(!unique_external_ref.is_empty(), Error::<T>::ExternalRefIsMandatory);
ensure!(
Self::is_external_ref_used(&unique_external_ref) == false,
Error::<T>::ExternalRefIsAlreadyInUse
Expand Down
4 changes: 2 additions & 2 deletions pallets/parachain-staking/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ macro_rules! assert_eq_last_events {
#[macro_export]
macro_rules! assert_tail_eq {
($tail:expr, $arr:expr $(,)?) => {
if $tail.len() != 0 {
if !$tail.is_empty() {
// 0-length always passes

if $tail.len() > $arr.len() {
Expand All @@ -722,7 +722,7 @@ macro_rules! assert_tail_eq {
}
};
($tail:expr, $arr:expr, $($arg:tt)*) => {
if $tail.len() != 0 {
if !$tail.is_empty() {
// 0-length always passes

if $tail.len() > $arr.len() {
Expand Down
2 changes: 1 addition & 1 deletion pallets/summary/src/offence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn create_and_report_summary_offence<T: crate::Config>(
) {
let offenders = create_offenders_identification::<T>(offenders_accounts);

if offenders.len() > 0 {
if !offenders.is_empty() {
let invalid_event_offence = SummaryOffence {
session_index: <pallet_session::Pallet<T>>::current_index(),
validator_set_count: crate::AVN::<T>::validators().len() as u32,
Expand Down
2 changes: 1 addition & 1 deletion pallets/validators-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub mod pallet {
ensure_root(origin)?;
let validator_account_ids =
Self::validator_account_ids().ok_or(Error::<T>::NoValidators)?;
ensure!(validator_account_ids.len() > 0, Error::<T>::NoValidators);
ensure!(!validator_account_ids.is_empty(), Error::<T>::NoValidators);

ensure!(
!validator_account_ids.contains(&collator_account_id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ mod proxy_signed_nominate {

let mut sum = 0;
exposures.into_iter().for_each(|e| {
if e.others.len() as u32 > 0 {
if !e.others.is_empty() {
sum += e.others.iter().find(|o| o.who == staker).unwrap().value;
}
});
Expand Down
2 changes: 1 addition & 1 deletion primitives/avn-common/src/event_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl NftMintData {
pub fn is_valid(&self) -> bool {
return !self.batch_id.is_zero() &&
!self.t2_owner_public_key.is_zero() &&
self.unique_external_ref.len() > 0
!self.unique_external_ref.is_empty()
}

pub fn parse_bytes(data: Option<Vec<u8>>, topics: Vec<Vec<u8>>) -> Result<Self, Error> {
Expand Down
2 changes: 1 addition & 1 deletion runtime/avn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("avn-parachain"),
impl_name: create_runtime_str!("avn-parachain"),
authoring_version: 1,
spec_version: 62,
spec_version: 63,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
2 changes: 1 addition & 1 deletion runtime/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("avn-test-parachain"),
impl_name: create_runtime_str!("avn-test-parachain"),
authoring_version: 1,
spec_version: 62,
spec_version: 63,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down

0 comments on commit f80a9ef

Please sign in to comment.