mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
Runtime upgrade test (#364)
This commit is contained in:
@@ -66,3 +66,4 @@ std = [
|
||||
"sp-transaction-pool/std",
|
||||
"sp-version/std",
|
||||
]
|
||||
upgrade = []
|
||||
|
||||
+27
-1
@@ -47,6 +47,7 @@ pub use frame_support::{
|
||||
};
|
||||
use frame_system::limits::{BlockLength, BlockWeights};
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use pallet_sudo::Call as SudoCall;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
@@ -58,12 +59,17 @@ impl_opaque_keys! {
|
||||
pub struct SessionKeys {}
|
||||
}
|
||||
|
||||
const SPEC_VERSION: u32 = 3;
|
||||
|
||||
/// This runtime version.
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("cumulus-test-parachain"),
|
||||
impl_name: create_runtime_str!("cumulus-test-parachain"),
|
||||
authoring_version: 1,
|
||||
spec_version: 3,
|
||||
#[cfg(feature = "upgrade")]
|
||||
spec_version: SPEC_VERSION + 1,
|
||||
#[cfg(not(feature = "upgrade"))]
|
||||
spec_version: SPEC_VERSION,
|
||||
impl_version: 1,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 1,
|
||||
@@ -220,6 +226,15 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
pub storage ParachainId: cumulus_primitives_core::ParaId = 100.into();
|
||||
pub storage UpgradeDetection: bool = false;
|
||||
}
|
||||
|
||||
pub struct UpgradeDetectionOnRuntimeUpgrade;
|
||||
impl frame_support::traits::OnRuntimeUpgrade for UpgradeDetectionOnRuntimeUpgrade {
|
||||
fn on_runtime_upgrade() -> u64 {
|
||||
UpgradeDetection::set(&true);
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
construct_runtime! {
|
||||
@@ -284,6 +299,7 @@ pub type Executive = frame_executive::Executive<
|
||||
frame_system::ChainContext<Runtime>,
|
||||
Runtime,
|
||||
AllPallets,
|
||||
UpgradeDetectionOnRuntimeUpgrade,
|
||||
>;
|
||||
/// The payload being signed in transactions.
|
||||
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
|
||||
@@ -293,6 +309,10 @@ decl_runtime_apis! {
|
||||
/// Returns the last timestamp of a runtime.
|
||||
fn get_last_timestamp() -> u64;
|
||||
}
|
||||
pub trait GetUpgradeDetection {
|
||||
/// Returns `true` if the runtime has been upgraded at least once.
|
||||
fn has_upgraded() -> bool;
|
||||
}
|
||||
}
|
||||
|
||||
impl_runtime_apis! {
|
||||
@@ -372,6 +392,12 @@ impl_runtime_apis! {
|
||||
Timestamp::now()
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::GetUpgradeDetection<Block> for Runtime {
|
||||
fn has_upgraded() -> bool {
|
||||
UpgradeDetection::get()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cumulus_pallet_parachain_system::register_validate_block!(Runtime, Executive);
|
||||
|
||||
Reference in New Issue
Block a user