From 9d7d1d0c13516f00301b5bdbea8bc40b973b0c91 Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Fri, 2 Aug 2024 15:37:42 +0000 Subject: [PATCH 01/11] test: more complex input queues scenario for queue compatibility tests --- .../src/canister_state/queues/tests.rs | 88 +++++++++++++++++++ .../queues_compatibility_test.rs | 79 ++++++++++++++--- rs/types/base_types/src/principal_id.rs | 20 ++++- rs/types/types_test_utils/src/ids.rs | 4 +- 4 files changed, 172 insertions(+), 19 deletions(-) diff --git a/rs/replicated_state/src/canister_state/queues/tests.rs b/rs/replicated_state/src/canister_state/queues/tests.rs index 8bf3355d223..09eb5304f6c 100644 --- a/rs/replicated_state/src/canister_state/queues/tests.rs +++ b/rs/replicated_state/src/canister_state/queues/tests.rs @@ -10,6 +10,7 @@ use ic_test_utilities_types::ids::{canister_test_id, message_test_id, user_test_ use ic_test_utilities_types::messages::{IngressBuilder, RequestBuilder, ResponseBuilder}; use ic_types::messages::{CallbackId, CanisterMessage}; use ic_types::time::{expiry_time_from_now, CoarseTime, UNIX_EPOCH}; +use ic_types::UserId; use maplit::btreemap; use proptest::prelude::*; use std::cell::RefCell; @@ -2348,4 +2349,91 @@ mod mainnet_compatibility_tests { assert!(!queues.queues.has_output()); } } + + /// Test that, with multiple input queues of different types, the iterators behave the same way + mod input_iterator_test { + use super::super::*; + use super::*; + + const OUTPUT_NAME: &str = "queues.pbuf"; + const CANISTER_ID: CanisterId = CanisterId::from_u64(42); + const LOCAL_CANISTER_ID: CanisterId = CanisterId::from_u64(13); + const REMOTE_CANISTER_ID: CanisterId = CanisterId::from_u64(666); + const USER_ID: UserId = user_test_id(7); + + #[test] + #[ignore] + fn serialize() { + let mut queues = CanisterQueuesMultiFixture::new(); + queues.this = CANISTER_ID; + + // Put a request and a response from a local canister in the input queues + queues + .push_input_request(LOCAL_CANISTER_ID, InputQueueType::LocalSubnet) + .unwrap(); + // Make an outgoing request just to create a reservation for a response (even if they don't match) + queues.push_output_request(LOCAL_CANISTER_ID).unwrap(); + queues + .push_input_response(LOCAL_CANISTER_ID, InputQueueType::LocalSubnet) + .unwrap(); + + // Put a request and a response from a remote canister in the input queues + queues + .push_input_request(REMOTE_CANISTER_ID, InputQueueType::RemoteSubnet) + .unwrap(); + // Make an outgoing request just to create a reservation for a response (even if they don't match) + queues.push_output_request(REMOTE_CANISTER_ID).unwrap(); + queues + .push_input_response(REMOTE_CANISTER_ID, InputQueueType::RemoteSubnet) + .unwrap(); + + // Put a request from the canister itself in the input queues + queues + .push_input_request(CANISTER_ID, InputQueueType::LocalSubnet) + .unwrap(); + + // Put an ingress message in the input queues + queues.push_ingress( + IngressBuilder::default() + .source(USER_ID) + .receiver(CANISTER_ID) + .build(), + ); + + let pb_queues: pb_queues::CanisterQueues = (&queues.queues).into(); + let serialized = pb_queues.encode_to_vec(); + + let output_path = std::path::Path::new(OUTPUT_NAME); + File::create(output_path) + .unwrap() + .write_all(&serialized) + .unwrap(); + } + + #[test] + #[ignore] + fn deserialize() { + let serialized = std::fs::read(OUTPUT_NAME).expect("Could not read file"); + let pb_queues = pb_queues::CanisterQueues::decode(&serialized as &[u8]) + .expect("Failed to deserialize the protobuf"); + let c_queues = CanisterQueues::try_from(( + pb_queues, + &StrictMetrics as &dyn CheckpointLoadingMetrics, + )) + .expect("Failed to convert the protobuf to CanisterQueues"); + + let mut queues = CanisterQueuesMultiFixture::new(); + queues.queues = c_queues; + queues.this = CANISTER_ID; + + assert_matches!(queues.pop_input().unwrap(), CanisterMessage::Request(ref req) if req.sender == LOCAL_CANISTER_ID); + assert_matches!(queues.pop_input().unwrap(), CanisterMessage::Ingress(ref ing) if ing.source == USER_ID); + assert_matches!(queues.pop_input().unwrap(), CanisterMessage::Request(ref req) if req.sender == REMOTE_CANISTER_ID); + assert_matches!(queues.pop_input().unwrap(), CanisterMessage::Request(ref req) if req.sender == CANISTER_ID); + assert_matches!(queues.pop_input().unwrap(), CanisterMessage::Response(ref req) if req.respondent == REMOTE_CANISTER_ID); + assert_matches!(queues.pop_input().unwrap(), CanisterMessage::Response(ref req) if req.respondent == LOCAL_CANISTER_ID); + + assert!(!queues.queues.has_input()); + } + } } diff --git a/rs/tests/message_routing/queues_compatibility_test.rs b/rs/tests/message_routing/queues_compatibility_test.rs index 9e202dc6104..c37b5da3e8d 100644 --- a/rs/tests/message_routing/queues_compatibility_test.rs +++ b/rs/tests/message_routing/queues_compatibility_test.rs @@ -67,6 +67,11 @@ fn run_unit_test( .output() .unwrap_or_else(|e| panic!("Could not execute unit test binary {binary:?}: {e:?}")); info!(logger, "Command output: {:?}", output); + info!( + logger, + "Command output stderr: {}", + String::from_utf8_lossy(&output.stderr) + ); assert!( output.status.success(), "Command failed: with status {:?}", @@ -86,7 +91,7 @@ fn run_unit_test( fn download_mainnet_binary( binary_name: &str, - version: String, + version: &str, target_dir: &Path, log: &Logger, ) -> PathBuf { @@ -98,7 +103,7 @@ fn download_mainnet_binary( || async { download_binary( log, - ReplicaVersion::try_from(version.clone()).unwrap(), + ReplicaVersion::try_from(version).unwrap(), binary_name.into(), target_dir, ) @@ -140,27 +145,66 @@ fn test_one_direction( ); } +enum TestType { + SelfTestOnly, + Bidirectional { published_binary: String }, +} + struct TestCase { - published_binary: String, test_binary: String, test_module: String, + test_type: TestType, } impl TestCase { - fn new(published_binary: &str, test_binary: &str, test_module: &str) -> Self { + fn new(test_type: TestType, test_binary: &str, test_module: &str) -> Self { Self { - published_binary: published_binary.to_string(), test_binary: test_binary.to_string(), test_module: test_module.to_string(), + test_type, + } + } + + pub fn run(&self, mainnet_version: &str, logger: &Logger) { + match &self.test_type { + TestType::Bidirectional { published_binary } => { + self.self_test(logger); + self.bidirectional_test(mainnet_version, published_binary, logger) + } + TestType::SelfTestOnly => { + self.self_test(logger); + } } } - pub fn bidirectional_test(&self, mainnet_version: String, logger: &Logger) { + fn self_test(&self, logger: &Logger) { + let test_binary = data_dependency_file(&self.test_binary); + info!( + logger, + "Testing self-compatibility of module {}", self.test_module + ); + let tmp_dir = tempfile::tempdir().unwrap(); + let tmp_dir_path = tmp_dir.path(); + test_one_direction( + &test_binary, + &test_binary, + &self.test_module, + tmp_dir_path, + logger, + ); + } + + fn bidirectional_test( + &self, + mainnet_version: &str, + published_binary_name: &str, + logger: &Logger, + ) { let download_dir = tempfile::tempdir().unwrap(); let download_dir_path = download_dir.path(); let published_binary = download_mainnet_binary( - &self.published_binary, - mainnet_version.clone(), + published_binary_name, + mainnet_version, download_dir_path, logger, ); @@ -170,11 +214,10 @@ impl TestCase { "Testing module {} with the mainnet commit {} and published binary {}", self.test_module, mainnet_version, - self.published_binary + published_binary_name, ); for (direction, from, to) in [ ("upgrade", &published_binary, &test_binary), - ("current self-compatibility", &test_binary, &test_binary), ("downgrade", &test_binary, &published_binary), ] { info!(logger, "Testing {}", direction); @@ -193,8 +236,10 @@ struct Subnets { fn test(env: TestEnv) { let logger = env.logger(); - let test_case = TestCase::new( - "replicated-state-test", + 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", ); @@ -210,8 +255,16 @@ fn test(env: TestEnv) { info!(logger, "Mainnet versions: {:?}", mainnet_versions); for mainnet_version in mainnet_versions { - test_case.bidirectional_test(mainnet_version, &logger) + basic_test.run(&mainnet_version, &logger) } + + let iterator_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_iterator_test", + ); + + iterator_test.run("", &logger); } fn main() -> Result<()> { diff --git a/rs/types/base_types/src/principal_id.rs b/rs/types/base_types/src/principal_id.rs index 7141b0a18c1..dd30d4efdb0 100644 --- a/rs/types/base_types/src/principal_id.rs +++ b/rs/types/base_types/src/principal_id.rs @@ -196,11 +196,23 @@ impl PrincipalId { PrincipalId::new(len + 1, blob) } - pub fn new_user_test_id(n: u64) -> Self { - let mut bytes = n.to_le_bytes().to_vec(); - bytes.push(0xfe); // internal marker for user test ids - Self::new_opaque(&bytes[..]) + pub const fn new_user_test_id(n: u64) -> Self { + let mut bytes = [0u8; Self::MAX_LENGTH_IN_BYTES]; + let n_bytes = n.to_le_bytes(); + + // Copy the u64 bytes into the array + let mut i = 0; + while i < n_bytes.len() { + bytes[i] = n_bytes[i]; + i += 1; + } + + // Append the internal marker + bytes[8] = 0xfe; + + Self::new_opaque_from_array(bytes, 9) } + pub fn new_node_test_id(n: u64) -> Self { let mut bytes = n.to_le_bytes().to_vec(); bytes.push(0xfd); // internal marker for node test ids diff --git a/rs/types/types_test_utils/src/ids.rs b/rs/types/types_test_utils/src/ids.rs index e2805444d00..ac06dc1a3e5 100644 --- a/rs/types/types_test_utils/src/ids.rs +++ b/rs/types/types_test_utils/src/ids.rs @@ -174,8 +174,8 @@ pub fn new_node_test_id(i: u64) -> NodeId { } /// Returns a [`UserId`] that can be used in tests. -pub fn user_test_id(i: u64) -> UserId { - UserId::from(PrincipalId::new_user_test_id(i)) +pub const fn user_test_id(i: u64) -> UserId { + UserId::new(PrincipalId::new_user_test_id(i)) } /// Returns the user id of the anonymous user. From a8b3c869295ead62156144ef9e37f7ee2b991f88 Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Fri, 2 Aug 2024 15:42:33 +0000 Subject: [PATCH 02/11] Tidy the test up --- rs/replicated_state/src/canister_state/queues/tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rs/replicated_state/src/canister_state/queues/tests.rs b/rs/replicated_state/src/canister_state/queues/tests.rs index 09eb5304f6c..8883b1846bb 100644 --- a/rs/replicated_state/src/canister_state/queues/tests.rs +++ b/rs/replicated_state/src/canister_state/queues/tests.rs @@ -2371,7 +2371,7 @@ mod mainnet_compatibility_tests { queues .push_input_request(LOCAL_CANISTER_ID, InputQueueType::LocalSubnet) .unwrap(); - // Make an outgoing request just to create a reservation for a response (even if they don't match) + // Make an outgoing request just to create a reservation for a response queues.push_output_request(LOCAL_CANISTER_ID).unwrap(); queues .push_input_response(LOCAL_CANISTER_ID, InputQueueType::LocalSubnet) @@ -2381,7 +2381,7 @@ mod mainnet_compatibility_tests { queues .push_input_request(REMOTE_CANISTER_ID, InputQueueType::RemoteSubnet) .unwrap(); - // Make an outgoing request just to create a reservation for a response (even if they don't match) + // Make an outgoing request just to create a reservation for a response queues.push_output_request(REMOTE_CANISTER_ID).unwrap(); queues .push_input_response(REMOTE_CANISTER_ID, InputQueueType::RemoteSubnet) @@ -2433,7 +2433,7 @@ mod mainnet_compatibility_tests { assert_matches!(queues.pop_input().unwrap(), CanisterMessage::Response(ref req) if req.respondent == REMOTE_CANISTER_ID); assert_matches!(queues.pop_input().unwrap(), CanisterMessage::Response(ref req) if req.respondent == LOCAL_CANISTER_ID); - assert!(!queues.queues.has_input()); + assert!(!queues.has_input()); } } } From c63632689faf3eb235fc2b2d7298180f604155e3 Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Fri, 2 Aug 2024 15:45:15 +0000 Subject: [PATCH 03/11] Remove a magic constant --- rs/types/base_types/src/principal_id.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rs/types/base_types/src/principal_id.rs b/rs/types/base_types/src/principal_id.rs index dd30d4efdb0..96ece6d6f53 100644 --- a/rs/types/base_types/src/principal_id.rs +++ b/rs/types/base_types/src/principal_id.rs @@ -208,7 +208,7 @@ impl PrincipalId { } // Append the internal marker - bytes[8] = 0xfe; + bytes[n_bytes.len()] = 0xfe; Self::new_opaque_from_array(bytes, 9) } From 7bb6d561775fceaa822a8d9e32b297988d09cd40 Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Mon, 5 Aug 2024 11:50:45 +0000 Subject: [PATCH 04/11] Remove another magic constant --- rs/types/base_types/src/principal_id.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rs/types/base_types/src/principal_id.rs b/rs/types/base_types/src/principal_id.rs index 96ece6d6f53..2cd8b81d059 100644 --- a/rs/types/base_types/src/principal_id.rs +++ b/rs/types/base_types/src/principal_id.rs @@ -210,7 +210,7 @@ impl PrincipalId { // Append the internal marker bytes[n_bytes.len()] = 0xfe; - Self::new_opaque_from_array(bytes, 9) + Self::new_opaque_from_array(bytes, n_bytes.len() + 1) } pub fn new_node_test_id(n: u64) -> Self { From 8d01884e9634902771859fca203303b33852bb55 Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Mon, 5 Aug 2024 11:52:38 +0000 Subject: [PATCH 05/11] Rename the test --- rs/replicated_state/src/canister_state/queues/tests.rs | 5 +++-- rs/tests/message_routing/queues_compatibility_test.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rs/replicated_state/src/canister_state/queues/tests.rs b/rs/replicated_state/src/canister_state/queues/tests.rs index 8883b1846bb..2dc1297663e 100644 --- a/rs/replicated_state/src/canister_state/queues/tests.rs +++ b/rs/replicated_state/src/canister_state/queues/tests.rs @@ -2350,8 +2350,9 @@ mod mainnet_compatibility_tests { } } - /// Test that, with multiple input queues of different types, the iterators behave the same way - mod input_iterator_test { + /// Test that, with multiple input queues of different types, the order in which they + /// are consumed stays the same + mod input_order_test { use super::super::*; use super::*; diff --git a/rs/tests/message_routing/queues_compatibility_test.rs b/rs/tests/message_routing/queues_compatibility_test.rs index c37b5da3e8d..a72391e84ed 100644 --- a/rs/tests/message_routing/queues_compatibility_test.rs +++ b/rs/tests/message_routing/queues_compatibility_test.rs @@ -258,13 +258,13 @@ fn test(env: TestEnv) { basic_test.run(&mainnet_version, &logger) } - let iterator_test = TestCase::new( + 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_iterator_test", + "canister_state::queues::tests::mainnet_compatibility_tests::input_order_test", ); - iterator_test.run("", &logger); + input_order_test.run("", &logger); } fn main() -> Result<()> { From 3f585f34840c6bc7662a2b8c37bb18083de21e2b Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Mon, 5 Aug 2024 12:59:32 +0000 Subject: [PATCH 06/11] Appease Clippy --- rs/sns/root/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rs/sns/root/src/lib.rs b/rs/sns/root/src/lib.rs index 84a8cfe82c9..6ae99be86ad 100644 --- a/rs/sns/root/src/lib.rs +++ b/rs/sns/root/src/lib.rs @@ -1685,7 +1685,7 @@ mod tests { async fn register_dapp_canisters_redundant() { // Step 1: Prepare the world. thread_local! { - static DAPP_CANISTER_ID: PrincipalId = PrincipalId::new_user_test_id(4); + static DAPP_CANISTER_ID: PrincipalId = const { PrincipalId::new_user_test_id(4) }; static SNS_ROOT_CANISTER: RefCell = RefCell::new(SnsRootCanister { governance_canister_id: Some(PrincipalId::new_user_test_id(1)), ledger_canister_id: Some(PrincipalId::new_user_test_id(2)), From d569473ab96e3be53eebefbf1a2f0d7828c3511c Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Tue, 6 Aug 2024 11:03:37 +0000 Subject: [PATCH 07/11] Comment on why a while loop --- rs/types/base_types/src/principal_id.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rs/types/base_types/src/principal_id.rs b/rs/types/base_types/src/principal_id.rs index 2cd8b81d059..00d12ef3e11 100644 --- a/rs/types/base_types/src/principal_id.rs +++ b/rs/types/base_types/src/principal_id.rs @@ -201,6 +201,8 @@ impl PrincipalId { let n_bytes = n.to_le_bytes(); // Copy the u64 bytes into the array + // Need a while loop since one can't use a for loop in const functions, see: + // https://github.com/rust-lang/rust/issues/87575 let mut i = 0; while i < n_bytes.len() { bytes[i] = n_bytes[i]; From 2300b2ba6b5aeacc6735e3a1f9bb2a3542c9493c Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Tue, 6 Aug 2024 11:36:30 +0000 Subject: [PATCH 08/11] Trim the system test dependencies for the queues compatibility test Bazel doesn't seem do caching that well for Rust, so trimming unused dependencies helps a lot. --- rs/tests/message_routing/BUILD.bazel | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rs/tests/message_routing/BUILD.bazel b/rs/tests/message_routing/BUILD.bazel index 3793339c1e6..fb4349c4e3b 100644 --- a/rs/tests/message_routing/BUILD.bazel +++ b/rs/tests/message_routing/BUILD.bazel @@ -87,11 +87,19 @@ system_test( system_test( name = "queues_compatibility_test", - proc_macro_deps = MACRO_DEPENDENCIES, target_compatible_with = ["@platforms//os:linux"], # requires libssh that does not build on Mac OS runtime_deps = [ "//rs/replicated_state:replicated_state_test_binary", "//testnet:mainnet_revisions", ], - deps = DEPENDENCIES + ["//rs/tests"], + deps = [ + "//rs/recovery", + "//rs/tests/driver:ic-system-test-driver", + "//rs/types/types", + "@crate_index//:anyhow", + "@crate_index//:serde", + "@crate_index//:serde_json", + "@crate_index//:slog", + "@crate_index//:tempfile", + ], ) From 8677104c1c50d41cb3d1ebbd70034d46fbc885a2 Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Tue, 6 Aug 2024 11:37:36 +0000 Subject: [PATCH 09/11] Use a more realistic lifecycle for messages in tests --- .../src/canister_state/queues/tests.rs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/rs/replicated_state/src/canister_state/queues/tests.rs b/rs/replicated_state/src/canister_state/queues/tests.rs index 2dc1297663e..20651b8e960 100644 --- a/rs/replicated_state/src/canister_state/queues/tests.rs +++ b/rs/replicated_state/src/canister_state/queues/tests.rs @@ -391,6 +391,18 @@ impl CanisterQueuesMultiFixture { ) } + fn reserve_and_push_input_response( + &mut self, + other: CanisterId, + input_queue_type: InputQueueType, + ) -> Result<(), (StateError, RequestOrResponse)> { + self.push_output_request(other) + .map_err(|(se, req)| (se, (*req).clone().into()))?; + self.pop_output() + .expect("Just pushed an output request, but nothing popped"); + self.push_input_response(other, input_queue_type) + } + fn push_ingress(&mut self, msg: Ingress) { self.queues.push_ingress(msg) } @@ -2372,20 +2384,16 @@ mod mainnet_compatibility_tests { queues .push_input_request(LOCAL_CANISTER_ID, InputQueueType::LocalSubnet) .unwrap(); - // Make an outgoing request just to create a reservation for a response - queues.push_output_request(LOCAL_CANISTER_ID).unwrap(); queues - .push_input_response(LOCAL_CANISTER_ID, InputQueueType::LocalSubnet) + .reserve_and_push_input_response(LOCAL_CANISTER_ID, InputQueueType::LocalSubnet) .unwrap(); // Put a request and a response from a remote canister in the input queues queues .push_input_request(REMOTE_CANISTER_ID, InputQueueType::RemoteSubnet) .unwrap(); - // Make an outgoing request just to create a reservation for a response - queues.push_output_request(REMOTE_CANISTER_ID).unwrap(); queues - .push_input_response(REMOTE_CANISTER_ID, InputQueueType::RemoteSubnet) + .reserve_and_push_input_response(REMOTE_CANISTER_ID, InputQueueType::RemoteSubnet) .unwrap(); // Put a request from the canister itself in the input queues From af725b2c066dd93bd294d9221dd7cd658d8570fa Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Tue, 6 Aug 2024 11:38:06 +0000 Subject: [PATCH 10/11] Improve the test "framework" --- .../queues_compatibility_test.rs | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/rs/tests/message_routing/queues_compatibility_test.rs b/rs/tests/message_routing/queues_compatibility_test.rs index a72391e84ed..c29c5122638 100644 --- a/rs/tests/message_routing/queues_compatibility_test.rs +++ b/rs/tests/message_routing/queues_compatibility_test.rs @@ -147,7 +147,10 @@ fn test_one_direction( enum TestType { SelfTestOnly, - Bidirectional { published_binary: String }, + Bidirectional { + published_binary: String, + mainnet_version: String, + }, } struct TestCase { @@ -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) } @@ -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"); @@ -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<()> { From 642b870193b3e8f4ef01b96f2c5d14312e53a787 Mon Sep 17 00:00:00 2001 From: Ognjen Maric Date: Tue, 6 Aug 2024 14:50:19 +0000 Subject: [PATCH 11/11] Appease Clippy some more --- .../message_routing/queues_compatibility_test.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/rs/tests/message_routing/queues_compatibility_test.rs b/rs/tests/message_routing/queues_compatibility_test.rs index c29c5122638..1ae3137c701 100644 --- a/rs/tests/message_routing/queues_compatibility_test.rs +++ b/rs/tests/message_routing/queues_compatibility_test.rs @@ -264,14 +264,11 @@ fn test(env: TestEnv) { "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(), - ); + .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", + )]); for t in tests { t.run(&logger);