mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
add unit tests to run runtime migrations (#5865)
* add unit tests to run runtime migrations * Update runtime/westend/src/lib.rs Co-authored-by: Mara Robin B. <mara@broda.me> * fix * fmt * Update runtime/westend/src/lib.rs Co-authored-by: Mara Robin B. <mara@broda.me>
This commit is contained in:
@@ -104,6 +104,9 @@ keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substra
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
separator = "0.4.1"
|
||||
serde_json = "1.0.81"
|
||||
remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
tokio = { version = "1.18.2", features = ["macros"] }
|
||||
sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -2308,3 +2308,38 @@ mod multiplier_tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[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,
|
||||
};
|
||||
use std::env::var;
|
||||
|
||||
#[tokio::test]
|
||||
async fn run_migrations() {
|
||||
sp_tracing::try_init_simple();
|
||||
let transport: Transport =
|
||||
var("WS").unwrap_or("wss://kusama-rpc.polkadot.io:443".to_string()).into();
|
||||
let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user