mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
cumulus test runtime: remove GenesisExt (#2147)
This PR removes the `GenesisExt` wrapper over the `GenesisRuntimeConfig` in `cumulus-test-service`. Initialization of values that were performed by `GenesisExt::BuildStorage` was moved into `test_pallet` genesis. --------- Co-authored-by: command-bot <> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
committed by
GitHub
parent
21fbc00d04
commit
1c0b437330
@@ -76,10 +76,6 @@ impl_opaque_keys! {
|
||||
pub struct SessionKeys {}
|
||||
}
|
||||
|
||||
/// Some key that we set in genesis and only read in [`TestOnRuntimeUpgrade`] to ensure that
|
||||
/// [`OnRuntimeUpgrade`] works as expected.
|
||||
pub const TEST_RUNTIME_UPGRADE_KEY: &[u8] = b"+test_runtime_upgrade_key+";
|
||||
|
||||
/// The para-id used in this runtime.
|
||||
pub const PARACHAIN_ID: u32 = 100;
|
||||
|
||||
@@ -293,6 +289,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// will be set by test_pallet during genesis init
|
||||
pub storage ParachainId: cumulus_primitives_core::ParaId = PARACHAIN_ID.into();
|
||||
}
|
||||
|
||||
@@ -367,7 +364,10 @@ pub struct TestOnRuntimeUpgrade;
|
||||
|
||||
impl OnRuntimeUpgrade for TestOnRuntimeUpgrade {
|
||||
fn on_runtime_upgrade() -> frame_support::weights::Weight {
|
||||
assert_eq!(sp_io::storage::get(TEST_RUNTIME_UPGRADE_KEY), Some(vec![1, 2, 3, 4].into()));
|
||||
assert_eq!(
|
||||
sp_io::storage::get(test_pallet::TEST_RUNTIME_UPGRADE_KEY),
|
||||
Some(vec![1, 2, 3, 4].into())
|
||||
);
|
||||
Weight::from_parts(1, 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,13 @@
|
||||
/// A special pallet that exposes dispatchables that are only useful for testing.
|
||||
pub use pallet::*;
|
||||
|
||||
/// Some key that we set in genesis and only read in [`TestOnRuntimeUpgrade`] to ensure that
|
||||
/// [`OnRuntimeUpgrade`] works as expected.
|
||||
pub const TEST_RUNTIME_UPGRADE_KEY: &[u8] = b"+test_runtime_upgrade_key+";
|
||||
|
||||
#[frame_support::pallet(dev_mode)]
|
||||
pub mod pallet {
|
||||
use crate::test_pallet::TEST_RUNTIME_UPGRADE_KEY;
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
|
||||
@@ -45,4 +50,22 @@ pub mod pallet {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(frame_support::DefaultNoBound)]
|
||||
#[pallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub self_para_id: Option<cumulus_primitives_core::ParaId>,
|
||||
#[serde(skip)]
|
||||
pub _config: sp_std::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
sp_io::storage::set(TEST_RUNTIME_UPGRADE_KEY, &[1, 2, 3, 4]);
|
||||
self.self_para_id.map(|para_id| {
|
||||
crate::ParachainId::set(¶_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user