-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zombienet upgrade test #5794
base: master
Are you sure you want to change the base?
Zombienet upgrade test #5794
Changes from all commits
b9fcadb
6451ebf
ec9c439
01fae8f
9348c73
9dd43a0
a90e9b8
c5bc15c
2e626dc
2839e07
805072f
e141238
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 |
---|---|---|
|
@@ -3,3 +3,6 @@ | |
|
||
#[cfg(feature = "zombie-metadata")] | ||
mod coretime_revenue; | ||
|
||
#[cfg(feature = "zombienet")] | ||
mod runtime_upgrade; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::anyhow; | ||
use std::env; | ||
use zombienet_sdk::{tx_helper::RuntimeUpgradeOptions, NetworkConfigBuilder}; | ||
|
||
const BEST_BLOCK_METRIC: &str = "block_height{status=\"best\"}"; | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn runtime_upgrade_test() -> Result<(), anyhow::Error> { | ||
env_logger::init_from_env( | ||
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), | ||
); | ||
|
||
let images = zombienet_sdk::environment::get_images_from_env(); | ||
let config = NetworkConfigBuilder::new() | ||
.with_relaychain(|r| { | ||
r.with_chain("rococo-local") | ||
.with_default_command("polkadot") | ||
.with_default_image(images.polkadot.as_str()) | ||
.with_node(|node| { | ||
node.with_name("latest-release") | ||
// used for getting the chain-spec | ||
.with_image("parity/polkadot:latest") | ||
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. Can we somehow use the exact runtime-image that roco chain is currently using, or at least the last stable release version, since the upgrades happened all at once. 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. |
||
}) | ||
.with_node(|node| node.with_name("bob")) | ||
}) | ||
.build() | ||
.map_err(|e| { | ||
let errs = e.into_iter().map(|e| e.to_string()).collect::<Vec<_>>().join(" "); | ||
anyhow!("config errs: {errs}") | ||
})?; | ||
|
||
let spawn_fn = zombienet_sdk::environment::get_spawn_fn(); | ||
let network = spawn_fn(config).await?; | ||
|
||
// wait 10 blocks | ||
let latest_release = network.get_node("latest-release")?; | ||
assert!(latest_release.wait_metric(BEST_BLOCK_METRIC, |b| b > 10_f64).await.is_ok()); | ||
|
||
// get current runtime spec | ||
let client = network.get_node("latest-release")?.client::<subxt::PolkadotConfig>().await?; | ||
let current_runtime = client.backend().current_runtime_version().await?; | ||
|
||
// get current best | ||
latest_release.wait_metric(BEST_BLOCK_METRIC, |x| x > 10_f64).await?; | ||
let best_block = latest_release.reports(BEST_BLOCK_METRIC).await?; | ||
|
||
// upgrade runtime | ||
let wasm = env::var("ZOMBIE_WASM_INCREMENTED_PATH").unwrap_or_else(|_| { | ||
let root_workspace_dir = env!("CARGO_WORKSPACE_ROOT_DIR"); | ||
format!("{root_workspace_dir}/target/testnet/wbuild/rococo-runtime/wasm_binary_spec_version_incremented.rs.compact.compressed.wasm") | ||
}); | ||
|
||
network | ||
.relaychain() | ||
.runtime_upgrade(RuntimeUpgradeOptions::new(wasm.as_str().into())) | ||
.await?; | ||
|
||
// wait 10 more blocks | ||
latest_release | ||
.wait_metric(BEST_BLOCK_METRIC, |x| x > best_block + 10_f64) | ||
.await?; | ||
|
||
let incremented_runtime = client.backend().current_runtime_version().await?; | ||
|
||
assert_eq!( | ||
incremented_runtime.spec_version, | ||
current_runtime.spec_version + 1000, | ||
"version should be incremented" | ||
); | ||
|
||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would extract out:
CONST SPEC_VERSION: 1_015_000 and then here I would use SPEC_VERSION + 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can extract out, I will leave this way.
Thx!