Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Improve tests; try to fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnski committed Jul 14, 2023
1 parent dc5d6a0 commit 6ef14fe
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 26 deletions.
39 changes: 39 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ polkadot-test-client = { path = "../test/client" }
polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" }
env_logger = "0.9.0"
assert_matches = "1.5.0"
serial_test = "2.0.0"
tempfile = "3.2"

[build-dependencies]
Expand Down
10 changes: 6 additions & 4 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,7 @@ mod workers {
use super::*;

use assert_matches::assert_matches;
use serial_test::serial;
use std::{env::temp_dir, fs, os::unix::fs::PermissionsExt, path::Path};

const NODE_VERSION: &'static str = env!("SUBSTRATE_CLI_IMPL_VERSION");
Expand Down Expand Up @@ -1452,10 +1453,6 @@ echo {}
fn with_temp_dir_structure(
f: impl FnOnce(PathBuf) -> Result<(), Box<dyn std::error::Error>>,
) -> Result<(), Box<dyn std::error::Error>> {
// Ensure tests run one at a time so they don't interfere with each other.
static OVERRIDES_LOCK: Mutex<()> = Mutex::new(());
let _lock = OVERRIDES_LOCK.lock()?;

// Set up <tmp>/usr/lib/polkadot and <tmp>/usr/bin, both empty.

let tempdir = temp_dir();
Expand All @@ -1478,6 +1475,7 @@ echo {}
}

#[test]
#[serial]
fn test_given_worker_path() {
with_temp_dir_structure(|tempdir| {
let given_workers_path = tempdir.join("usr/local/bin");
Expand Down Expand Up @@ -1522,6 +1520,7 @@ echo {}
}

#[test]
#[serial]
fn missing_workers_paths_throws_error() {
with_temp_dir_structure(|tempdir| {
// Try with both binaries missing.
Expand Down Expand Up @@ -1571,6 +1570,7 @@ echo {}
}

#[test]
#[serial]
fn should_find_workers_at_all_locations() {
with_temp_dir_structure(|tempdir| {
let prepare_worker_bin_path = tempdir.join("usr/bin/polkadot-prepare-worker");
Expand All @@ -1596,6 +1596,7 @@ echo {}
}

#[test]
#[serial]
fn workers_version_mismatch_throws_error() {
let bad_version = "v9.9.9.9";

Expand Down Expand Up @@ -1645,6 +1646,7 @@ echo {}
}

#[test]
#[serial]
fn should_find_valid_workers() {
// Test bin location.
with_temp_dir_structure(|tempdir| {
Expand Down
24 changes: 13 additions & 11 deletions parachain/test-parachains/adder/collator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ fn main() -> Result<()> {

let full_node = polkadot_service::build_full(
config,
polkadot_service::IsCollator::Yes(collator.collator_key()),
None,
false,
None,
None,
None,
false,
polkadot_service::RealOverseerGen,
None,
None,
None,
polkadot_service::NewFullParams {
is_collator: polkadot_service::IsCollator::Yes(collator.collator_key()),
grandpa_pause: None,
enable_beefy: false,
jaeger_agent: None,
telemetry_worker_handle: None,
workers_path: None,
overseer_enable_anyways: false,
overseer_gen: polkadot_service::RealOverseerGen,
overseer_message_channel_capacity_override: None,
malus_finality_delay: None,
hwbench: None,
},
)
.map_err(|e| e.to_string())?;
let mut overseer_handle = full_node
Expand Down
24 changes: 13 additions & 11 deletions parachain/test-parachains/undying/collator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ fn main() -> Result<()> {

let full_node = polkadot_service::build_full(
config,
polkadot_service::IsCollator::Yes(collator.collator_key()),
None,
false,
None,
None,
None,
false,
polkadot_service::RealOverseerGen,
None,
None,
None,
polkadot_service::NewFullParams {
is_collator: polkadot_service::IsCollator::Yes(collator.collator_key()),
grandpa_pause: None,
enable_beefy: false,
jaeger_agent: None,
telemetry_worker_handle: None,
workers_path: None,
overseer_enable_anyways: false,
overseer_gen: polkadot_service::RealOverseerGen,
overseer_message_channel_capacity_override: None,
malus_finality_delay: None,
hwbench: None,
},
)
.map_err(|e| e.to_string())?;
let mut overseer_handle = full_node
Expand Down

0 comments on commit 6ef14fe

Please sign in to comment.