Skip to content

Commit

Permalink
integration-tests: Remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
cdamian committed Nov 7, 2023
1 parent 2b13734 commit 4be8323
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 41 deletions.
2 changes: 1 addition & 1 deletion runtime/integration-tests/src/generic/cases/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
},
utils::genesis::Genesis,
},
utils::{accounts::Keyring, logs::init_logs},
utils::accounts::Keyring,
};

fn transfer_balance<T: Runtime>() {
Expand Down
15 changes: 3 additions & 12 deletions runtime/integration-tests/src/generic/cases/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use sp_runtime::{
use xcm::{
prelude::XCM_VERSION,
v3::{
AssetId, Fungibility, Instruction::WithdrawAsset, Junction, Junction::*, Junctions,
Junctions::*, MultiAsset, MultiAssets, MultiLocation, NetworkId, WeightLimit, Xcm,
AssetId, Fungibility, Junction, Junction::*, Junctions, Junctions::*, MultiAsset,
MultiAssets, MultiLocation, WeightLimit,
},
VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation,
};
Expand Down Expand Up @@ -381,7 +381,6 @@ mod altair {

fn transfer_air_to_sibling<T: Runtime + FudgeSupport>(env: &mut FudgeEnv<T>) {
let alice_initial_balance = air(10);
let bob_initial_balance = air(10);
let transfer_amount = air(5);
let air_in_sibling = CurrencyId::ForeignAsset(12);

Expand Down Expand Up @@ -817,7 +816,6 @@ mod altair {

setup_xcm(&mut env);

let alice_initial_balance = air(10);
let sibling_asset_id = CurrencyId::ForeignAsset(1);
let asset_location = MultiLocation::new(
1,
Expand Down Expand Up @@ -1280,7 +1278,7 @@ mod altair {
}

mod centrifuge {
use centrifuge_runtime::{CurrencyIdConvert, PoolPalletIndex};
use centrifuge_runtime::CurrencyIdConvert;

use super::*;

Expand Down Expand Up @@ -1791,8 +1789,6 @@ mod centrifuge {
fn xtokens_transfer_multiasset<T: Runtime + FudgeSupport>() {
let mut env = FudgeEnv::<T>::from_storage(Default::default(), Default::default());

use codec::Encode;

let tranche_currency = CurrencyId::Tranche(401, [0; 16]);
let tranche_id =
WeakBoundedVec::<u8, ConstU32<32>>::force_from(tranche_currency.encode(), None);
Expand Down Expand Up @@ -1840,8 +1836,6 @@ mod centrifuge {
fn xtokens_transfer_multiassets<T: Runtime + FudgeSupport>() {
let mut env = FudgeEnv::<T>::from_storage(Default::default(), Default::default());

use codec::Encode;

let tranche_currency = CurrencyId::Tranche(401, [0; 16]);
let tranche_id =
WeakBoundedVec::<u8, ConstU32<32>>::force_from(tranche_currency.encode(), None);
Expand Down Expand Up @@ -1899,8 +1893,6 @@ mod centrifuge {

fn transfer_cfg_to_sibling<T: Runtime + FudgeSupport>(env: &mut FudgeEnv<T>) {
let alice_initial_balance = cfg(10);
let bob_initial_balance = cfg(10);
let transfer_amount = cfg(1);
let transfer_amount = cfg(5);
let cfg_in_sibling = CurrencyId::ForeignAsset(12);

Expand Down Expand Up @@ -2306,7 +2298,6 @@ mod centrifuge {

setup_xcm(&mut env);

let alice_initial_balance = cfg(10);
let sibling_asset_id = CurrencyId::ForeignAsset(1);
let asset_location = MultiLocation::new(
1,
Expand Down
3 changes: 1 addition & 2 deletions runtime/integration-tests/src/generic/envs/fudge_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ pub struct FudgeEnv<T: Runtime + FudgeSupport> {

impl<T: Runtime + FudgeSupport> Env<T> for FudgeEnv<T> {
fn from_storage(parachain_storage: Storage, sibling_storage: Storage) -> Self {
let mut handle =
T::FudgeHandle::new(Storage::default(), parachain_storage, sibling_storage);
let handle = T::FudgeHandle::new(Storage::default(), parachain_storage, sibling_storage);

Self {
handle,
Expand Down
11 changes: 3 additions & 8 deletions runtime/integration-tests/src/generic/envs/fudge_env/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use cfg_primitives::{AuraId, Balance, BlockNumber};
use cumulus_primitives_core::CollectCollationInfo;
use frame_support::{traits::GenesisBuild, Parameter};
use frame_support::traits::GenesisBuild;
use fudge::{
digest::{DigestCreator as DigestCreatorT, DigestProvider, FudgeAuraDigest, FudgeBabeDigest},
inherent::{
Expand All @@ -15,9 +15,7 @@ use fudge::{
};
use polkadot_core_primitives::{Block as RelayBlock, Header as RelayHeader};
use polkadot_parachain::primitives::Id as ParaId;
use polkadot_primitives::{
runtime_api::ParachainHost, AssignmentId, AuthorityDiscoveryId, ValidatorId,
};
use polkadot_primitives::runtime_api::ParachainHost;
use polkadot_runtime_parachains::configuration::HostConfiguration;
use sc_block_builder::BlockBuilderApi;
use sc_client_api::Backend;
Expand All @@ -27,10 +25,7 @@ use sp_consensus_aura::{sr25519::AuthorityId, AuraApi};
use sp_consensus_babe::BabeApi;
use sp_consensus_slots::SlotDuration;
use sp_core::{crypto::AccountId32, ByteArray, H256};
use sp_runtime::{
traits::{AccountIdLookup, BlakeTwo256, MaybeSerializeDeserialize, Member, OpaqueKeys},
Storage,
};
use sp_runtime::{traits::AccountIdLookup, Storage};
use sp_transaction_pool::runtime_api::TaggedTransactionQueue;
use tokio::runtime::Handle;

Expand Down
4 changes: 2 additions & 2 deletions runtime/integration-tests/src/generic/envs/runtime_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ impl<T: Runtime> Env<T> for RuntimeEnv<T> {
Ok(())
}

fn relay_state_mut<R>(&mut self, f: impl FnOnce() -> R) -> R {
fn relay_state_mut<R>(&mut self, _f: impl FnOnce() -> R) -> R {
unimplemented!("Mutable relay state not implemented for RuntimeEnv")
}

fn relay_state<R>(&self, f: impl FnOnce() -> R) -> R {
fn relay_state<R>(&self, _f: impl FnOnce() -> R) -> R {
unimplemented!("Relay state not implemented for RuntimeEnv")
}

Expand Down
22 changes: 8 additions & 14 deletions runtime/integration-tests/src/runtime_apis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ use sp_runtime::{
};
use tokio::runtime::Handle;

use crate::chain::{
centrifuge,
centrifuge::{Runtime, PARA_ID},
use crate::{
chain::{
centrifuge,
centrifuge::{Runtime, PARA_ID},
},
utils::accounts::Keyring,
};

/// Start date used for timestamps in test-enviornments
Expand Down Expand Up @@ -91,15 +94,7 @@ fn create_builder(

state.insert_storage(
pallet_balances::GenesisConfig::<centrifuge::Runtime> {
balances: vec![(
sp_runtime::AccountId32::from(
<sr25519::Pair as sp_core::Pair>::from_string("//Alice", None)
.unwrap()
.public()
.into_account(),
),
10000 * CFG,
)],
balances: vec![(Keyring::Alice.to_account_id(), 10000 * CFG)],
}
.build_storage()
.expect("ESSENTIAL: GenesisBuild must not fail at this stage."),
Expand Down Expand Up @@ -178,9 +173,8 @@ impl ApiEnv {
}

pub fn new_with_genesis(handle: Handle, genesis: Storage) -> Self {
// TODO: Actually make a lot of the utils in pools not specific to pools
// testing. Like init logs, creating builder and so on.
crate::utils::logs::init_logs();

Self {
builder: create_builder(handle, Some(genesis)),
}
Expand Down
9 changes: 7 additions & 2 deletions runtime/integration-tests/src/runtime_apis/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ where
/// we need another distribution to allow the participant claim
/// rewards
for (group_id, amount) in &rewards {
<Rewards as DistributedRewards>::distribute_reward(*amount, [*group_id])
.expect("Distributing rewards should work");
let res =
<Rewards as DistributedRewards>::distribute_reward(*amount, [*group_id])
.expect("Distributing rewards should work");

res.iter().for_each(|item| {
item.expect("Rewards distribution error");
});
}
}
})
Expand Down

0 comments on commit 4be8323

Please sign in to comment.