-
Notifications
You must be signed in to change notification settings - Fork 1.5k
add unit tests to run runtime migrations #5865
Changes from 2 commits
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,7 @@ pub type Executive = frame_executive::Executive< | |
| frame_system::ChainContext<Runtime>, | ||
| Runtime, | ||
| AllPalletsWithSystem, | ||
| (pallet_staking::migrations::v10::MigrateToV10<Runtime>,), | ||
| (), | ||
| >; | ||
| /// The payload being signed in transactions. | ||
| pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>; | ||
|
|
@@ -1748,3 +1748,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()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not parse the env variable at runtime? Why at compile time?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no particular preference to be honest, I supposedly had the syntax for this on the top of my head 🤷
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its better to do at runtime, we had CI problems in the past where the CI did not provide the ENV variables. |
||
| 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.