|
1 | | -// Copyright © 2022-2025 Obol Labs Inc. Licensed under the terms of a Business |
2 | | -// Source License 1.1 |
3 | | - |
4 | 1 | /// List of supported cluster definition versions. |
5 | 2 | pub mod versions { |
6 | 3 | /// Version v1.10.0 (Default) |
@@ -42,3 +39,57 @@ pub const MIN_VERSION_FOR_PARTIAL_DEPOSITS: &str = V1_8; |
42 | 39 | pub const SUPPORTED_VERSIONS: [&str; 11] = [ |
43 | 40 | V1_10, V1_9, V1_8, V1_7, V1_6, V1_5, V1_4, V1_3, V1_2, V1_1, V1_0, |
44 | 41 | ]; |
| 42 | + |
| 43 | +/// Returns true if the provided cluster definition version supports |
| 44 | +/// pre-generated builder registrations. |
| 45 | +#[must_use] |
| 46 | +pub fn support_pregen_registrations(version: &str) -> bool { |
| 47 | + !matches!(version, V1_0 | V1_1 | V1_2 | V1_3 | V1_4 | V1_5 | V1_6) |
| 48 | +} |
| 49 | + |
| 50 | +/// Returns true if the provided cluster lock version supports node signatures. |
| 51 | +#[must_use] |
| 52 | +pub fn support_node_signatures(version: &str) -> bool { |
| 53 | + !matches!(version, V1_0 | V1_1 | V1_2 | V1_3 | V1_4 | V1_5 | V1_6) |
| 54 | +} |
| 55 | + |
| 56 | +#[cfg(test)] |
| 57 | +mod tests { |
| 58 | + use super::{ |
| 59 | + V1_0, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8, V1_9, V1_10, support_node_signatures, |
| 60 | + support_pregen_registrations, |
| 61 | + }; |
| 62 | + use test_case::test_case; |
| 63 | + |
| 64 | + #[test_case(V1_0, false; "v1.0.0")] |
| 65 | + #[test_case(V1_1, false; "v1.1.0")] |
| 66 | + #[test_case(V1_2, false; "v1.2.0")] |
| 67 | + #[test_case(V1_3, false; "v1.3.0")] |
| 68 | + #[test_case(V1_4, false; "v1.4.0")] |
| 69 | + #[test_case(V1_5, false; "v1.5.0")] |
| 70 | + #[test_case(V1_6, false; "v1.6.0")] |
| 71 | + #[test_case(V1_7, true; "v1.7.0")] |
| 72 | + #[test_case(V1_8, true; "v1.8.0")] |
| 73 | + #[test_case(V1_9, true; "v1.9.0")] |
| 74 | + #[test_case(V1_10, true; "v1.10.0")] |
| 75 | + #[test_case("invalid", true; "unknown version")] |
| 76 | + fn support_pregen_registrations_by_version(version: &str, expected: bool) { |
| 77 | + assert_eq!(support_pregen_registrations(version), expected); |
| 78 | + } |
| 79 | + |
| 80 | + #[test_case(V1_0, false; "v1.0.0")] |
| 81 | + #[test_case(V1_1, false; "v1.1.0")] |
| 82 | + #[test_case(V1_2, false; "v1.2.0")] |
| 83 | + #[test_case(V1_3, false; "v1.3.0")] |
| 84 | + #[test_case(V1_4, false; "v1.4.0")] |
| 85 | + #[test_case(V1_5, false; "v1.5.0")] |
| 86 | + #[test_case(V1_6, false; "v1.6.0")] |
| 87 | + #[test_case(V1_7, true; "v1.7.0")] |
| 88 | + #[test_case(V1_8, true; "v1.8.0")] |
| 89 | + #[test_case(V1_9, true; "v1.9.0")] |
| 90 | + #[test_case(V1_10, true; "v1.10.0")] |
| 91 | + #[test_case("invalid", true; "unknown version")] |
| 92 | + fn support_node_signatures_by_version(version: &str, expected: bool) { |
| 93 | + assert_eq!(support_node_signatures(version), expected); |
| 94 | + } |
| 95 | +} |
0 commit comments