What changed, and why it matters
This is a tiny code cleanup inside test code. It moves a variable assignment to a slightly different spot so the test reads more logically. There is no change to how the program behaves, no security fix, and no user-facing effect.
No action needed; this is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In p2p/src/message.rs, within two unit tests, the let preimage = ... assignment is relocated to immediately before the assertions that use it, after the unwrap() of the parsed message. The assertions themselves are unchanged. This is purely a readability/refactoring change in test code.
Changed components
p2p/src/message.rs unit testsInspect captured patch +4 / −3
diff --git a/p2p/src/message.rs b/p2p/src/message.rs
index 12e7a8c3..9d457aa2 100644
--- a/p2p/src/message.rs
+++ b/p2p/src/message.rs
@@ -2662,9 +2662,10 @@ mod test {
0x64, 0x64, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x5d, 0xf6, 0xe0, 0xe2
]);
- let preimage = V1NetworkMessage::new(Magic::BITCOIN, NetworkMessage::GetAddr);
assert!(msg.is_ok());
let msg: V1NetworkMessage = msg.unwrap();
+
+ let preimage = V1NetworkMessage::new(Magic::BITCOIN, NetworkMessage::GetAddr);
assert_eq!(preimage.magic, msg.magic);
assert_eq!(preimage.payload, msg.payload);
}
@@ -2675,10 +2676,10 @@ mod test {
0x00, // Full command encoding flag
0x67, 0x65, 0x74, 0x61, 0x64, 0x64, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00,
]);
-
- let preimage = V2NetworkMessage::new(NetworkMessage::GetAddr);
assert!(msg.is_ok());
let msg: V2NetworkMessage = msg.unwrap();
+
+ let preimage = V2NetworkMessage::new(NetworkMessage::GetAddr);
assert_eq!(preimage, msg);
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.