Skip to content

Commit

Permalink
basic stuff migrated
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Mar 25, 2024
1 parent 8f87798 commit 668f7a4
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 35 deletions.
4 changes: 3 additions & 1 deletion runtime/integration-tests/src/generic/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cfg_types::{
locations::Location,
oracles::OracleKey,
permissions::{PermissionScope, Role},
tokens::{CurrencyId, CustomMetadata, FilterCurrency, TrancheCurrency},
tokens::{AssetStringLimit, CurrencyId, CustomMetadata, FilterCurrency, TrancheCurrency},
};
use fp_self_contained::{SelfContainedCall, UncheckedExtrinsic};
use frame_support::{
Expand Down Expand Up @@ -54,6 +54,7 @@ pub trait Runtime:
RuntimeEvent = Self::RuntimeEventExt,
Lookup = AccountIdLookup<AccountId, ()>,
RuntimeOrigin = Self::RuntimeOriginExt,
Block = Self::BlockExt,
Hash = H256,
> + pallet_pool_system::Config<
CurrencyId = CurrencyId,
Expand Down Expand Up @@ -89,6 +90,7 @@ pub trait Runtime:
AssetId = CurrencyId,
CustomMetadata = CustomMetadata,
Balance = Balance,
StringLimit = AssetStringLimit,
> + pallet_uniques::Config<CollectionId = CollectionId, ItemId = ItemId>
+ pallet_timestamp::Config<Moment = Millis>
+ pallet_aura::Config<Moment = Millis, AuthorityId = AuraId>
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 @@ -9,7 +9,6 @@ use frame_support::{
dispatch::GetDispatchInfo,
inherent::{InherentData, ProvideInherent},
storage::{transactional, TransactionOutcome},
traits::GenesisBuild,
};
use frame_system::LastRuntimeUpgradeInfo;
use parity_scale_codec::Encode;
Expand All @@ -20,7 +19,7 @@ use sp_core::{sr25519::Public, Get, H256};
use sp_runtime::{
traits::Extrinsic,
transaction_validity::{InvalidTransaction, TransactionValidityError},
Digest, DigestItem, DispatchError, Storage,
BuildStorage, Digest, DigestItem, DispatchError, Storage,
};
use sp_timestamp::Timestamp;

Expand Down Expand Up @@ -287,6 +286,7 @@ impl<T: Runtime> RuntimeEnv<T> {
}
}

#[cfg(test)]
mod tests {
use cfg_primitives::CFG;

Expand Down
14 changes: 8 additions & 6 deletions runtime/integration-tests/src/generic/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ impl_runtime!(development_runtime, Development);
impl_runtime!(altair_runtime, Altair);
impl_runtime!(centrifuge_runtime, Centrifuge);

/*
/// Implements fudge support for a runtime
macro_rules! impl_fudge_support {
(
$fudge_companion_type:ident,
$relay_path:ident,
$fudge_companion_type:ident,
$relay_path:ident,
$relay_session_keys:expr,
$parachain_path:ident,
$parachain_id:literal,
$sibling_id:literal
) => {
$parachain_path:ident,
$parachain_id:literal,
$sibling_id:literal
) => {
const _: () = {
use fudge::primitives::{Chain, ParaId};
use polkadot_core_primitives::Block as RelayBlock;
Expand Down Expand Up @@ -228,3 +229,4 @@ pub fn default_polkadot_session_keys() -> polkadot_runtime::SessionKeys {
authority_discovery: AuthorityDiscoveryId::from_slice([0u8; 32].as_slice()).unwrap(),
}
}
*/
2 changes: 1 addition & 1 deletion runtime/integration-tests/src/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

pub mod env;
pub mod envs {
pub mod fudge_env;
//pub mod fudge_env;
pub mod runtime_env;
}
pub mod config;
Expand Down
4 changes: 2 additions & 2 deletions runtime/integration-tests/src/generic/utils/currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ pub trait CurrencyInfo {
fn metadata(&self) -> AssetMetadata {
AssetMetadata {
decimals: self.decimals(),
name: self.name().as_bytes().to_vec(),
symbol: self.symbol().as_bytes().to_vec(),
name: self.name().as_bytes().to_vec().try_into().unwrap(),
symbol: self.symbol().as_bytes().to_vec().try_into().unwrap(),
existential_deposit: self.ed(),
location: self.location(),
additional: self.custom(),
Expand Down
4 changes: 3 additions & 1 deletion runtime/integration-tests/src/generic/utils/democracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
generic::{
config::Runtime,
env::{Blocks, Env},
envs::fudge_env::FudgeSupport,
//envs::fudge_env::FudgeSupport,
},
utils::accounts::Keyring,
};
Expand Down Expand Up @@ -55,6 +55,7 @@ pub fn fast_track<T: Runtime>(
.into()
}

/*
pub fn execute_via_democracy<T: Runtime + FudgeSupport>(
env: &mut impl Env<T>,
council_members: Vec<Keyring>,
Expand Down Expand Up @@ -112,6 +113,7 @@ pub fn execute_via_democracy<T: Runtime + FudgeSupport>(
(starting_prop_index + 2, starting_ref_index + 1)
}
*/

pub fn democracy_vote<T: Runtime>(
ref_index: ReferendumIndex,
Expand Down
32 changes: 10 additions & 22 deletions runtime/integration-tests/src/generic/utils/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
//! PLEASE be as much generic as possible because no domain or use cases are
//! considered at this level.
use std::marker::PhantomData;

use cfg_primitives::Balance;
use cfg_types::tokens::CurrencyId;
use frame_support::traits::GenesisBuild;
use parity_scale_codec::Encode;
use sp_core::crypto::AccountId32;
use sp_runtime::Storage;
use sp_runtime::{BuildStorage, Storage};

use crate::{
generic::{config::Runtime, utils::currency::CurrencyInfo},
utils::accounts::{default_accounts, Keyring},
};

pub struct Genesis<T> {
#[derive(Default)]
pub struct Genesis {
storage: Storage,
_config: PhantomData<T>,
}

impl<T> Default for Genesis<T> {
fn default() -> Self {
Self {
storage: Default::default(),
_config: Default::default(),
}
}
}

impl<T: Runtime> Genesis<T> {
pub fn add<I: 'static>(mut self, builder: impl GenesisBuild<T, I>) -> Self {
impl Genesis {
pub fn add(mut self, builder: impl BuildStorage) -> Self {
builder.assimilate_storage(&mut self.storage).unwrap();
self
}
Expand All @@ -40,9 +28,9 @@ impl<T: Runtime> Genesis<T> {
}
}

// Add GenesisBuild functions for pallet initialization.
// Add BuildStorage functions for pallet initialization.

pub fn balances<T: Runtime>(balance: Balance) -> impl GenesisBuild<T> {
pub fn balances<T: Runtime>(balance: Balance) -> impl BuildStorage {
pallet_balances::GenesisConfig::<T> {
balances: default_accounts()
.into_iter()
Expand All @@ -51,7 +39,7 @@ pub fn balances<T: Runtime>(balance: Balance) -> impl GenesisBuild<T> {
}
}

pub fn tokens<T: Runtime>(values: Vec<(CurrencyId, Balance)>) -> impl GenesisBuild<T> {
pub fn tokens<T: Runtime>(values: Vec<(CurrencyId, Balance)>) -> impl BuildStorage {
orml_tokens::GenesisConfig::<T> {
balances: default_accounts()
.into_iter()
Expand All @@ -67,7 +55,7 @@ pub fn tokens<T: Runtime>(values: Vec<(CurrencyId, Balance)>) -> impl GenesisBui
}
}

pub fn assets<T: Runtime>(currency_ids: Vec<Box<dyn CurrencyInfo>>) -> impl GenesisBuild<T> {
pub fn assets<T: Runtime>(currency_ids: Vec<Box<dyn CurrencyInfo>>) -> impl BuildStorage {
orml_asset_registry::GenesisConfig::<T> {
assets: currency_ids
.into_iter()
Expand All @@ -77,7 +65,7 @@ pub fn assets<T: Runtime>(currency_ids: Vec<Box<dyn CurrencyInfo>>) -> impl Gene
}
}

pub fn council_members<T, I>(members: Vec<Keyring>) -> impl GenesisBuild<T, I>
pub fn council_members<T, I>(members: Vec<Keyring>) -> impl BuildStorage
where
I: 'static,
T: pallet_collective::Config<I>,
Expand Down

0 comments on commit 668f7a4

Please sign in to comment.