Skip to content

Commit 1da2ab1

Browse files
committed
Added substrate validators warp sync test
1 parent 13fddc8 commit 1da2ab1

File tree

7 files changed

+689
-27
lines changed

7 files changed

+689
-27
lines changed

.github/zombienet-tests/zombienet_substrate_tests.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,17 @@
44
use-zombienet-sdk: true
55

66
- job-name: "zombienet-substrate-0001-basic-warp-sync"
7-
test-definition: "test-warp-sync.zndsl"
8-
local-dir: "./substrate/zombienet/0001-basic-warp-sync"
7+
test-filter: "zombie_ci::basic_warp_sync::basic_warp_sync"
98
runner-type: "default"
10-
concurrency: 4
11-
use-zombienet-sdk: false
9+
use-zombienet-sdk: true
1210

1311
# TODO: Disabled, fails 1 in 50 runs
1412
- job-name: "zombienet-substrate-0002-validators-warp-sync"
15-
test-definition: "test-validators-warp-sync.zndsl"
16-
local-dir: "./substrate/zombienet/0002-validators-warp-sync"
13+
test-filter: "zombie_ci::validators_warp_sync::validators_warp_sync"
1714
runner-type: "default"
18-
concurrency: 4
19-
use-zombienet-sdk: false
20-
additional-setup: |
21-
cp --remove-destination ./substrate/zombienet/0001-basic-warp-sync/chain-spec.json ./substrate/zombienet/0002-validators-warp-sync
15+
use-zombienet-sdk: true
2216

2317
- job-name: "zombienet-substrate-0003-block-building-warp-sync"
24-
test-definition: "test-block-building-warp-sync.zndsl"
25-
local-dir: "./substrate/zombienet/0003-block-building-warp-sync"
18+
test-filter: "zombie_ci::block_building_warp_sync::block_building_warp_sync"
2619
runner-type: "default"
27-
concurrency: 4
28-
use-zombienet-sdk: false
29-
additional-setup: |
30-
cp --remove-destination ./substrate/zombienet/0001-basic-warp-sync/chain-spec.json ./substrate/zombienet/0003-block-building-warp-sync
20+
use-zombienet-sdk: true

substrate/zombienet/zombienet-sdk/tests/utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use zombienet_sdk::{LocalFileSystem, Network, NetworkConfig};
55

66
pub const BEST_BLOCK_METRIC: &str = "block_height{status=\"best\"}";
7+
pub const FINALIZED_BLOCK_METRIC: &str = "substrate_block_height{status=\"finalized\"}";
8+
pub const BEEFY_BEST_BLOCK_METRIC: &str = "substrate_beefy_best_block";
79
pub const DEFAULT_SUBSTRATE_IMAGE: &str = "docker.io/paritypr/substrate:latest";
810

911
pub const DEFAULT_DB_SNAPSHOT_URL: &str =

substrate/zombienet/zombienet-sdk/tests/zombie_ci/basic_warp_sync.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
use std::time::Duration;
55

6-
use crate::utils::{initialize_network, BEST_BLOCK_METRIC};
6+
use crate::utils::{
7+
initialize_network, BEST_BLOCK_METRIC, DEFAULT_CHAIN_SPEC, DEFAULT_DB_SNAPSHOT_URL,
8+
};
79
use anyhow::{anyhow, Result};
810
use env_logger::Env;
911
use zombienet_orchestrator::network::node::LogLineCountOptions;
@@ -29,10 +31,6 @@ const DB_SNAPSHOT_ENV: &str = "DB_SNAPSHOT";
2931
const CHAIN_SPEC_ENV: &str = "WARP_CHAIN_SPEC_PATH";
3032
const DB_BLOCK_HEIGHT_ENV: &str = "DB_BLOCK_HEIGHT";
3133
const DEFAULT_SUBSTRATE_IMAGE: &str = "docker.io/paritypr/substrate:latest";
32-
const DEFAULT_DB_SNAPSHOT_URL: &str =
33-
"https://storage.googleapis.com/zombienet-db-snaps/substrate/0001-basic-warp-sync/chains-0bb3f0be2ce41b5615b224215bcc8363aa0416a6.tgz";
34-
const DEFAULT_CHAIN_SPEC: &str =
35-
"https://raw.githubusercontent.com/paritytech/polkadot-sdk/refs/heads/master/substrate/zombienet/0001-basic-warp-sync/chain-spec.json";
3634

3735
#[tokio::test(flavor = "multi_thread")]
3836
async fn basic_warp_sync() -> Result<()> {
@@ -88,6 +86,9 @@ async fn basic_warp_sync() -> Result<()> {
8886
}
8987

9088
fn ensure_env_defaults() {
89+
if std::env::var(INTEGRATION_IMAGE_ENV).is_err() {
90+
std::env::set_var(INTEGRATION_IMAGE_ENV, DEFAULT_SUBSTRATE_IMAGE);
91+
}
9192
if std::env::var(DB_SNAPSHOT_ENV).is_err() {
9293
std::env::set_var(DB_SNAPSHOT_ENV, DEFAULT_DB_SNAPSHOT_URL);
9394
}
@@ -115,6 +116,8 @@ async fn resolve_db_snapshot_height(
115116
}
116117

117118
fn build_network_config() -> Result<NetworkConfig> {
119+
let integration_image = std::env::var(INTEGRATION_IMAGE_ENV)
120+
.unwrap_or_else(|_| DEFAULT_SUBSTRATE_IMAGE.to_string());
118121
let db_snapshot =
119122
std::env::var(DB_SNAPSHOT_ENV).map_err(|_| anyhow!("db snapshot env var not set"))?;
120123
let chain_spec =
@@ -125,7 +128,7 @@ fn build_network_config() -> Result<NetworkConfig> {
125128
relaychain
126129
.with_chain("local")
127130
.with_default_command("substrate")
128-
.with_default_image(DEFAULT_SUBSTRATE_IMAGE)
131+
.with_default_image(integration_image.as_str())
129132
.with_chain_spec_path(chain_spec.as_str())
130133
.with_node(|node| {
131134
node.with_name("alice").validator(false).with_db_snapshot(db_snapshot.as_str())

substrate/zombienet/zombienet-sdk/tests/zombie_ci/block_building.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33

44
use std::time::Duration;
55

6-
use crate::utils::initialize_network;
6+
use crate::utils::{initialize_network, DEFAULT_CHAIN_SPEC, DEFAULT_SUBSTRATE_IMAGE};
77
use anyhow::{anyhow, Result};
88
use subxt::{config::substrate::SubstrateConfig, dynamic::tx, OnlineClient};
99
use subxt_signer::sr25519::dev;
1010
use zombienet_orchestrator::network::node::LogLineCountOptions;
11-
use zombienet_sdk::{environment::get_spawn_fn, NetworkConfig, NetworkConfigBuilder, NetworkNode};
12-
13-
const DEFAULT_SUBSTRATE_IMAGE: &str = "docker.io/paritypr/substrate:latest";
11+
use zombienet_sdk::{NetworkConfig, NetworkConfigBuilder, NetworkNode};
1412

1513
const NODE_NAMES: [&str; 2] = ["alice", "bob"];
1614

@@ -28,13 +26,17 @@ const LOG_TIMEOUT_SECS: u64 = 2;
2826
const SCRIPT_TIMEOUT_SECS: u64 = 30;
2927

3028
const REMARK_PAYLOAD: &[u8] = b"block-building-test";
29+
const INTEGRATION_IMAGE_ENV: &str = "ZOMBIENET_INTEGRATION_TEST_IMAGE";
30+
const CHAIN_SPEC_ENV: &str = "WARP_CHAIN_SPEC_PATH";
3131

3232
#[tokio::test(flavor = "multi_thread")]
3333
async fn block_building_test() -> Result<()> {
3434
let _ = env_logger::try_init_from_env(
3535
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"),
3636
);
3737

38+
ensure_env_defaults();
39+
3840
log::info!("Spawning network");
3941
let config = build_network_config()?;
4042
let network = initialize_network(config).await?;
@@ -54,13 +56,28 @@ async fn block_building_test() -> Result<()> {
5456
Ok(())
5557
}
5658

59+
fn ensure_env_defaults() {
60+
if std::env::var(INTEGRATION_IMAGE_ENV).is_err() {
61+
std::env::set_var(INTEGRATION_IMAGE_ENV, DEFAULT_SUBSTRATE_IMAGE);
62+
}
63+
if std::env::var(CHAIN_SPEC_ENV).is_err() {
64+
std::env::set_var(CHAIN_SPEC_ENV, DEFAULT_CHAIN_SPEC);
65+
}
66+
}
67+
5768
fn build_network_config() -> Result<NetworkConfig> {
69+
let integration_image = std::env::var(INTEGRATION_IMAGE_ENV)
70+
.unwrap_or_else(|_| DEFAULT_SUBSTRATE_IMAGE.to_string());
71+
let chain_spec =
72+
std::env::var(CHAIN_SPEC_ENV).unwrap_or_else(|_| DEFAULT_CHAIN_SPEC.to_string());
73+
5874
let config = NetworkConfigBuilder::new()
5975
.with_relaychain(|relaychain| {
6076
relaychain
6177
.with_chain("local")
6278
.with_default_command("substrate")
63-
.with_default_image(DEFAULT_SUBSTRATE_IMAGE)
79+
.with_default_image(integration_image.as_str())
80+
.with_chain_spec_path(chain_spec.as_str())
6481
.with_default_args(vec!["-lparachain=debug".into()])
6582
.with_node(|node| node.with_name("alice"))
6683
.with_node(|node| node.with_name("bob"))

0 commit comments

Comments
 (0)