-
Notifications
You must be signed in to change notification settings - Fork 1.5k
add unit tests to run runtime migrations #5865
Changes from 1 commit
33f9f98
797bdcb
a953f33
1cda3b2
0503bf1
ae265d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1174,7 +1174,10 @@ pub type Executive = frame_executive::Executive< | |
| frame_system::ChainContext<Runtime>, | ||
| Runtime, | ||
| AllPalletsWithSystem, | ||
| (pallet_staking::migrations::v10::MigrateToV10<Runtime>,), | ||
| ( | ||
| pallet_staking::migrations::v10::MigrateToV10<Runtime>, | ||
| pallet_nomination_pools::migration::v2::MigrateToV2<Runtime>, | ||
| ), | ||
| >; | ||
| /// The payload being signed in transactions. | ||
| pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>; | ||
|
|
@@ -1748,3 +1751,40 @@ sp_api::impl_runtime_apis! { | |
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(all(test, feature = "try-runtime"))] | ||
| mod remote_tests { | ||
| use super::*; | ||
| use frame_try_runtime::runtime_decl_for_TryRuntime::TryRuntime; | ||
| use remote_externalities::{ | ||
| Builder, Mode, OfflineConfig, OnlineConfig, SnapshotConfig, Transport, | ||
| }; | ||
|
|
||
| #[tokio::test] | ||
| async fn run_migrations() { | ||
| sp_tracing::try_init_simple(); | ||
| let transport: Transport = std::option_env!("WSS") | ||
| .unwrap_or("wss://westend-rpc.polkadot.io:443") | ||
| .to_string() | ||
| .into(); | ||
| let maybe_state_snapshot: Option<SnapshotConfig> = | ||
| std::option_env!("SNAP").map(|s| s.to_string().into()); | ||
|
||
| let mut ext = Builder::<Block>::default() | ||
| .mode(if let Some(state_snapshot) = maybe_state_snapshot { | ||
| Mode::OfflineOrElseOnline( | ||
| OfflineConfig { state_snapshot: state_snapshot.clone() }, | ||
| OnlineConfig { | ||
| transport, | ||
| state_snapshot: Some(state_snapshot), | ||
| ..Default::default() | ||
| }, | ||
| ) | ||
| } else { | ||
| Mode::Online(OnlineConfig { transport, ..Default::default() }) | ||
| }) | ||
| .build() | ||
| .await | ||
| .unwrap(); | ||
| ext.execute_with(|| Runtime::on_runtime_upgrade()); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.