Skip to content

Commit

Permalink
Improve the test "framework"
Browse files Browse the repository at this point in the history
  • Loading branch information
oggy-dfin committed Aug 6, 2024
1 parent 8677104 commit af725b2
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions rs/tests/message_routing/queues_compatibility_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ fn test_one_direction(

enum TestType {
SelfTestOnly,
Bidirectional { published_binary: String },
Bidirectional {
published_binary: String,
mainnet_version: String,
},
}

struct TestCase {
Expand All @@ -165,9 +168,12 @@ impl TestCase {
}
}

pub fn run(&self, mainnet_version: &str, logger: &Logger) {
pub fn run(&self, logger: &Logger) {
match &self.test_type {
TestType::Bidirectional { published_binary } => {
TestType::Bidirectional {
published_binary,
mainnet_version,
} => {
self.self_test(logger);
self.bidirectional_test(mainnet_version, published_binary, logger)
}
Expand Down Expand Up @@ -236,14 +242,6 @@ struct Subnets {
fn test(env: TestEnv) {
let logger = env.logger();

let basic_test = TestCase::new(
TestType::Bidirectional {
published_binary: "replicated-state-test".to_string(),
},
"ic/rs/replicated_state/replicated_state_test_binary/replicated_state_test_binary",
"canister_state::queues::tests::mainnet_compatibility_tests::basic_test",
);

let versions_json = env
.read_dependency_to_string("testnet/mainnet_revisions.json")
.expect("mainnet IC versions");
Expand All @@ -254,17 +252,30 @@ fn test(env: TestEnv) {

info!(logger, "Mainnet versions: {:?}", mainnet_versions);

for mainnet_version in mainnet_versions {
basic_test.run(&mainnet_version, &logger)
}

let input_order_test = TestCase::new(
TestType::SelfTestOnly,
"ic/rs/replicated_state/replicated_state_test_binary/replicated_state_test_binary",
"canister_state::queues::tests::mainnet_compatibility_tests::input_order_test",
);
let tests = mainnet_versions
.iter()
.map(|v| {
TestCase::new(
TestType::Bidirectional {
published_binary: "replicated-state-test".to_string(),
mainnet_version: v.clone(),
},
"ic/rs/replicated_state/replicated_state_test_binary/replicated_state_test_binary",
"canister_state::queues::tests::mainnet_compatibility_tests::basic_test",
)
})
.chain(
[TestCase::new(
TestType::SelfTestOnly,
"ic/rs/replicated_state/replicated_state_test_binary/replicated_state_test_binary",
"canister_state::queues::tests::mainnet_compatibility_tests::input_order_test",
)]
.into_iter(),
);

input_order_test.run("", &logger);
for t in tests {
t.run(&logger);
}
}

fn main() -> Result<()> {
Expand Down

0 comments on commit af725b2

Please sign in to comment.