Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
NunoAlexandre committed Oct 25, 2023
1 parent 622d26a commit cada2ad
Show file tree
Hide file tree
Showing 52 changed files with 143 additions and 83 deletions.
4 changes: 2 additions & 2 deletions libs/mock-builder/tests/pallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub mod pallet_mock_test {
pub trait Config: frame_system::Config {}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down Expand Up @@ -117,7 +117,7 @@ pub mod my_pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

impl<T: Config> Pallet<T> {
pub fn my_call(name: &str, value: u64) -> Result<(), String> {
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/change_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod pallet_mock_change_guard {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/liquidity_pools_gateway_routers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod pallet {
pub trait Config: frame_system::Config {}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod pallet {
pub trait Config: frame_system::Config {}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/try_convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T, I = ()>(_);
pub struct Pallet<T, I = ()>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config<I>, I: 'static = ()> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/write_off_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
Expand Down
2 changes: 1 addition & 1 deletion libs/test-utils/src/mocks/order_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

#[pallet::genesis_config]
pub struct GenesisConfig<T: Config>
Expand Down
8 changes: 6 additions & 2 deletions pallets/block-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub mod pallet {
}

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);

/// Data associated to the current session.
Expand Down Expand Up @@ -361,7 +361,11 @@ impl<T: Config> Pallet<T> {
/// * deposit_stake (4 reads, 4 writes): Currency, Group, StakeAccount,
/// Account
pub(crate) fn do_init_collator(who: &T::AccountId) -> DispatchResult {
T::Currency::mint_into(T::StakeCurrencyId::get(), who, T::StakeAmount::get() + T::ExistentialDeposit::get())?;
T::Currency::mint_into(
T::StakeCurrencyId::get(),
who,
T::StakeAmount::get() + T::ExistentialDeposit::get(),
)?;
T::Rewards::deposit_stake(T::StakeCurrencyId::get(), who, T::StakeAmount::get())
}

Expand Down
14 changes: 11 additions & 3 deletions pallets/block-rewards/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ impl pallet_block_rewards::Config for Test {
type AdminOrigin = EnsureRoot<AccountId>;
type AuthorityId = UintAuthorityId;
type Balance = Balance;
type ExistentialDeposit = ExistentialDeposit;
type Beneficiary = RewardRemainderMock;
type Currency = Tokens;
type CurrencyId = CurrencyId;
type ExistentialDeposit = ExistentialDeposit;
type MaxChangesPerSession = MaxChangesPerSession;
type MaxCollators = MaxCollators;
type Rewards = Rewards;
Expand All @@ -264,7 +264,11 @@ pub(crate) fn assert_staked(who: &AccountId) {
ExistentialDeposit::get()
);
assert_eq!(
<Test as Config>::Currency::can_withdraw(<Test as Config>::StakeCurrencyId::get(), who, ExistentialDeposit::get() * 2),
<Test as Config>::Currency::can_withdraw(
<Test as Config>::StakeCurrencyId::get(),
who,
ExistentialDeposit::get() * 2
),
WithdrawConsequence::BalanceLow
);
}
Expand All @@ -277,7 +281,11 @@ pub(crate) fn assert_not_staked(who: &AccountId, was_before: bool) {
.is_zero());
assert_eq!(
<Test as Config>::Currency::balance(<Test as Config>::StakeCurrencyId::get(), who),
if was_before { ExistentialDeposit::get() } else { 0 }
if was_before {
ExistentialDeposit::get()
} else {
0
}
);
}

Expand Down
2 changes: 0 additions & 2 deletions pallets/block-rewards/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ fn single_claim_reward() {
Ok(REWARD)
);



assert_ok!(BlockRewards::claim_reward(RuntimeOrigin::signed(2), 1));
System::assert_last_event(mock::RuntimeEvent::Rewards(
pallet_rewards::Event::RewardClaimed {
Expand Down
2 changes: 1 addition & 1 deletion pallets/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub mod pallet {
// This structure is a placeholder for traits and functions implementation
// for the pallet.
#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

// ------------------------------------------------------------------------
// Pallet configuration
Expand Down
9 changes: 5 additions & 4 deletions pallets/bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ use sp_core::{blake2_128, ConstU64, H256};
use sp_io::TestExternalities;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
traits::{BlakeTwo256, ConstU128, IdentityLookup},
};
use sp_runtime::traits::ConstU128;

use crate::{self as pallet_bridge, Config as BridgePalletConfig};

Expand All @@ -56,8 +55,10 @@ pub(crate) const RELAYER_A: u64 = 0x2;
pub(crate) const RELAYER_B: u64 = 0x3;
pub(crate) const RELAYER_C: u64 = 0x4;
pub(crate) const ENDOWED_BALANCE: Balance = 10000 * CFG;
//todo(nuno): if we AllowDeath in Fees::withdraw_fee, we don't need to add the ED here
pub(crate) const RELAYER_B_INITIAL_BALANCE: Balance = NATIVE_TOKEN_TRANSFER_FEE + ExistentialDeposit::get();
//todo(nuno): if we AllowDeath in Fees::withdraw_fee, we don't need to add the
// ED here
pub(crate) const RELAYER_B_INITIAL_BALANCE: Balance =
NATIVE_TOKEN_TRANSFER_FEE + ExistentialDeposit::get();
pub(crate) const TEST_RELAYER_VOTE_THRESHOLD: u32 = 2;

// ----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pallets/claims/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub mod pallet {
// This structure is a placeholder for traits and functions implementation
// for the pallet.
#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

// ------------------------------------------------------------------------
// Pallet configuration
Expand Down
6 changes: 4 additions & 2 deletions pallets/claims/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@

use frame_support::{assert_noop, assert_ok};
use sp_core::H256;
use sp_runtime::TokenError;
use sp_runtime::traits::{BadOrigin, Hash};
use sp_runtime::{
traits::{BadOrigin, Hash},
TokenError,
};

use crate::{mock::*, *};

Expand Down
2 changes: 1 addition & 1 deletion pallets/crowdloan-claim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub mod pallet {
// This structure is a placeholder for traits and functions implementation
// for the pallet.
#[pallet::pallet]
pub struct Pallet<T>(_);
pub struct Pallet<T>(_);

// ------------------------------------------------------------------------
// Pallet configuration
Expand Down
2 changes: 1 addition & 1 deletion pallets/data-collector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub mod pallet {
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T, I = ()>(_);

#[pallet::config]
Expand Down
4 changes: 3 additions & 1 deletion pallets/ethereum-transaction/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use pallet_evm::{
FixedGasWeightMapping, IsPrecompileResult, PrecompileHandle, PrecompileSet,
SubstrateBlockHashMapping,
};
use sp_core::{crypto::AccountId32, ByteArray, ConstU16, ConstU32, ConstU64, H160, H256, U256, ConstU128};
use sp_core::{
crypto::AccountId32, ByteArray, ConstU128, ConstU16, ConstU32, ConstU64, H160, H256, U256,
};
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
Expand Down
1 change: 0 additions & 1 deletion pallets/interest-accrual/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ pub mod pallet {
const STORAGE_VERSION: StorageVersion = StorageVersion::new(3);

#[pallet::pallet]

#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);

Expand Down
10 changes: 4 additions & 6 deletions pallets/investments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ pub mod pallet {
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

#[pallet::pallet]

#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);

Expand Down Expand Up @@ -620,11 +619,10 @@ where
// Remove order from storage if empty
if amount == T::Amount::zero() {
*maybe_order = None;
}
else {
// nuno: check that this is ok. Amount == 0 removes the order, so there's
// no point in processing a transfer of 0 which fails because it would
// kill the account (< ED)
} else {
// nuno: check that this is ok. Amount == 0 removes the order, so
// there's no point in processing a transfer of 0 which fails because it
// would kill the account (< ED)
Self::do_update_redeem_order(
total_order,
&who,
Expand Down
54 changes: 45 additions & 9 deletions pallets/investments/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,51 @@ impl TestExternalitiesBuilder {
orml_tokens::GenesisConfig::<MockRuntime> {
balances: vec![
// Owner holds enough capital to satisfy redemptions
(Owner::get(), AUSD_CURRENCY_ID, OWNER_START_BALANCE + ExistentialDeposit::get()),
(InvestorA::get(), AUSD_CURRENCY_ID, 100 * CURRENCY + ExistentialDeposit::get()),
(InvestorB::get(), AUSD_CURRENCY_ID, 100 * CURRENCY + ExistentialDeposit::get()),
(InvestorC::get(), AUSD_CURRENCY_ID, 100 * CURRENCY + ExistentialDeposit::get()),
(InvestorD::get(), AUSD_CURRENCY_ID, 100 * CURRENCY + ExistentialDeposit::get()),
(TrancheHolderA::get(), INVESTMENT_0_0.into(), 100 * CURRENCY + ExistentialDeposit::get()),
(TrancheHolderB::get(), INVESTMENT_0_0.into(), 100 * CURRENCY + ExistentialDeposit::get()),
(TrancheHolderC::get(), INVESTMENT_0_0.into(), 100 * CURRENCY + ExistentialDeposit::get()),
(TrancheHolderD::get(), INVESTMENT_0_0.into(), 100 * CURRENCY + ExistentialDeposit::get()),
(
Owner::get(),
AUSD_CURRENCY_ID,
OWNER_START_BALANCE + ExistentialDeposit::get(),
),
(
InvestorA::get(),
AUSD_CURRENCY_ID,
100 * CURRENCY + ExistentialDeposit::get(),
),
(
InvestorB::get(),
AUSD_CURRENCY_ID,
100 * CURRENCY + ExistentialDeposit::get(),
),
(
InvestorC::get(),
AUSD_CURRENCY_ID,
100 * CURRENCY + ExistentialDeposit::get(),
),
(
InvestorD::get(),
AUSD_CURRENCY_ID,
100 * CURRENCY + ExistentialDeposit::get(),
),
(
TrancheHolderA::get(),
INVESTMENT_0_0.into(),
100 * CURRENCY + ExistentialDeposit::get(),
),
(
TrancheHolderB::get(),
INVESTMENT_0_0.into(),
100 * CURRENCY + ExistentialDeposit::get(),
),
(
TrancheHolderC::get(),
INVESTMENT_0_0.into(),
100 * CURRENCY + ExistentialDeposit::get(),
),
(
TrancheHolderD::get(),
INVESTMENT_0_0.into(),
100 * CURRENCY + ExistentialDeposit::get(),
),
],
}
.assimilate_storage(&mut storage)
Expand Down
Loading

0 comments on commit cada2ad

Please sign in to comment.