1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
From 7fa33f31fc4cfa8884bffc637f607f17df7aef00 Mon Sep 17 00:00:00 2001
From: Ivan Shapovalov <intelfx@intelfx.name>
Date: Fri, 28 Mar 2025 03:37:11 +0700
Subject: [PATCH 4/5] node: fix test_node_announcement_validate for
!debug_assertions
When running tests in release mode (`cargo test --release`),
`cfg(debug_assertions)` is not defined, causing different POW_PARAMS to
be applied, subsequently failing the test that compares work amounts to
precomputed magic values.
---
crates/radicle-protocol/src/service/message.rs | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/crates/radicle-protocol/src/service/message.rs b/crates/radicle-protocol/src/service/message.rs
index afcea631..82123cd9 100644
--- a/crates/radicle-protocol/src/service/message.rs
+++ b/crates/radicle-protocol/src/service/message.rs
@@ -778,9 +778,16 @@ mod tests {
agent: UserAgent::from_str("/heartwood:1.0.0/").unwrap(),
};
- assert_eq!(ann.work(), 1);
- assert_eq!(ann.clone().solve(1).unwrap().work(), 1);
- assert_eq!(ann.clone().solve(8).unwrap().work(), 10);
+ // POW_PARAMS are overridden for cfg(debug_assertions)
+ if cfg!(debug_assertions) {
+ assert_eq!(ann.work(), 1);
+ assert_eq!(ann.clone().solve(1).unwrap().work(), 1);
+ assert_eq!(ann.clone().solve(8).unwrap().work(), 10);
+ } else {
+ assert_eq!(ann.work(), 2);
+ assert_eq!(ann.clone().solve(1).unwrap().work(), 2);
+ assert_eq!(ann.clone().solve(8).unwrap().work(), 14);
+ }
assert_eq!(ann.solve(14).unwrap().work(), 14);
}
}
--
2.53.0.8.g57fba0c4633
|