Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
MBrozhko34 committed Apr 4, 2024
1 parent 0d11154 commit 213bd66
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 19 deletions.
6 changes: 3 additions & 3 deletions pallets/ethereum-events/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ use codec::{Decode, Encode, MaxEncodedLen};
use sp_application_crypto::RuntimeAppPublic;
use sp_avn_common::{
event_types::{
AddedValidatorData, AvtGrowthLiftedData, Challenge, ChallengeReason, CheckResult,
EthEventCheckResult, EthEventId, EventData, LiftedData, NftCancelListingData,
AddedValidatorData, AvtGrowthLiftedData, AvtLowerClaimedData, Challenge, ChallengeReason,
CheckResult, EthEventCheckResult, EthEventId, EventData, LiftedData, NftCancelListingData,
NftEndBatchListingData, NftMintData, NftTransferToData, ProcessedEventHandler, ValidEvents,
Validator, AvtLowerClaimedData
Validator,
},
verify_signature, EthQueryRequest, EthQueryResponse, EthQueryResponseType, EthTransaction,
IngressCounter, InnerCallValidator, Proof,
Expand Down
12 changes: 6 additions & 6 deletions pallets/token-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ use pallet_avn::{
LowerParams, OnGrowthLiftedHandler, ProcessedEventsChecker, PACKED_LOWER_PARAM_SIZE,
};
use sp_avn_common::{
event_types::{AvtGrowthLiftedData, AvtLowerClaimedData, EthEvent, EventData, LiftedData, ProcessedEventHandler},
event_types::{
AvtGrowthLiftedData, AvtLowerClaimedData, EthEvent, EventData, LiftedData,
ProcessedEventHandler,
},
verify_signature, CallDecoder, InnerCallValidator, Proof,
};
use sp_core::{ConstU32, MaxEncodedLen, H160, H256};
Expand Down Expand Up @@ -616,7 +619,6 @@ impl<T: Config> Pallet<T> {
Ok(())
}


fn settle_lower(
token_id: T::TokenId,
from: &T::AccountId,
Expand Down Expand Up @@ -921,9 +923,7 @@ impl<T: Config> Pallet<T> {
}
LowersReadyToClaim::<T>::remove(data.lower_id);

Self::deposit_event(Event::<T>::AvtLowerClaimed {
lower_id: data.lower_id,
});
Self::deposit_event(Event::<T>::AvtLowerClaimed { lower_id: data.lower_id });

Ok(())
}
Expand Down Expand Up @@ -992,7 +992,7 @@ impl<T: Config> ProcessedEventHandler for Pallet<T> {
return match &event.event_data {
EventData::LogLifted(d) => return Self::process_lift(event, d),
EventData::LogAvtGrowthLifted(d) => return Self::process_avt_growth_lift(event, d),
EventData::LogLowerClaimed(d)=> return Self::process_lower_claim(event, d),
EventData::LogLowerClaimed(d) => return Self::process_lower_claim(event, d),

// Event handled or it is not for us, in which case ignore it.
_ => Ok(()),
Expand Down
5 changes: 4 additions & 1 deletion pallets/token-manager/src/test_avt_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ fn avn_test_lift_max_balance_to_non_zero_balance_account_should_return_deposit_f
insert_to_mock_processed_events(&mock_event.event_id);
let balance_before = Balances::free_balance(mock_data.receiver_account_id);

assert_noop!(TokenManager::on_event_processed(&mock_event), Error::<TestRuntime>::DepositFailed);
assert_noop!(
TokenManager::on_event_processed(&mock_event),
Error::<TestRuntime>::DepositFailed
);
assert_eq!(Balances::free_balance(mock_data.receiver_account_id), balance_before);

assert!(!System::events().iter().any(|a| a.event ==
Expand Down
5 changes: 4 additions & 1 deletion pallets/token-manager/src/test_common_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ fn avn_test_lift_zero_amount_should_fail() {
mock_data.receiver_account_id,
));

assert_noop!(TokenManager::on_event_processed(&mock_event), Error::<TestRuntime>::AmountIsZero);
assert_noop!(
TokenManager::on_event_processed(&mock_event),
Error::<TestRuntime>::AmountIsZero
);
assert_eq!(Balances::free_balance(mock_data.receiver_account_id), avt_token_balance_before);
assert_eq!(
<TokenManager as Store>::Balances::get((
Expand Down
5 changes: 4 additions & 1 deletion pallets/token-manager/src/test_non_avt_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ fn avn_test_lift_max_balance_to_non_zero_balance_account_should_fail_with_overfl
mock_data.receiver_account_id,
));

assert_noop!(TokenManager::on_event_processed(&mock_event), Error::<TestRuntime>::AmountOverflow);
assert_noop!(
TokenManager::on_event_processed(&mock_event),
Error::<TestRuntime>::AmountOverflow
);
assert_eq!(
<TokenManager as Store>::Balances::get((
NON_AVT_TOKEN_ID,
Expand Down
8 changes: 6 additions & 2 deletions primitives/avn-common/src/event_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ use crate::bounds::NftExternalRefBound;
use codec::{Decode, Encode, MaxEncodedLen};
use hex_literal::hex;
use sp_core::{bounded::BoundedVec, H160, H256, H512, U256};
use sp_runtime::{scale_info::TypeInfo, traits::{Member, Zero}, DispatchResult};
use sp_runtime::{
scale_info::TypeInfo,
traits::{Member, Zero},
DispatchResult,
};
use sp_std::{convert::TryInto, vec::Vec};

// ================================= Events Types ====================================
Expand Down Expand Up @@ -804,4 +808,4 @@ mod test_avt_growth_event_parsing;

#[cfg(test)]
#[path = "tests/test_lower_claim.rs"]
mod test_lower_claim;
mod test_lower_claim;
8 changes: 3 additions & 5 deletions primitives/avn-common/src/tests/test_lower_claim.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2024 Aventus Systems (UK) Ltd.
#[cfg(test)]
use super::*;
use sha3::{Digest, Keccak256};
use sp_core::U256;
use sp_std::vec::Vec;
use sha3::{Digest, Keccak256};

mod end_batch_listing {
use super::*;
Expand All @@ -19,7 +19,6 @@ mod end_batch_listing {

impl AvtLowerClaimedConfig {
fn setup() -> Self {

AvtLowerClaimedConfig {
topic1: vec![1; 32],
topic2_lower_id: vec![1u8; 32],
Expand Down Expand Up @@ -91,8 +90,7 @@ mod end_batch_listing {
fn event_contains_too_many_topics() {
let config = AvtLowerClaimedConfig::setup();

let topics =
vec![config.topic1.clone(), config.topic2_lower_id, config.topic1];
let topics = vec![config.topic1.clone(), config.topic2_lower_id, config.topic1];
let result = AvtLowerClaimedData::parse_bytes(config.data, topics);

assert_eq!(result, Err(Error::AvtLowerClaimedEventWrongTopicCount));
Expand All @@ -118,4 +116,4 @@ mod end_batch_listing {
assert_eq!(result, Err(Error::AvtLowerClaimedEventBadTopicLength));
}
}
}
}

0 comments on commit 213bd66

Please sign in to comment.