What changed, and why it matters
This commit is a minor cleanup of an internal Rust unit test. It replaces a manual panic-catching block with Rust's built-in #[should_panic] test attribute. The test still verifies the same behavior: that calling reboot_to_bootloader in a test environment triggers a panic with the message 'reboot_to_bootloader called'. There is no change to production firmware code, no security fix, and no user-facing behavior change.
No security action required. This is a test-code refactoring commit with no production impact.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies src/rust/bitbox02-rust/src/hww/api/system.rs, specifically the test_reboot_to_bootloader unit test. Previously the test used std::panic::catch_unwind to verify that reboot_to_bootloader panics with a specific message. The commit simplifies this by adding #[should_panic(expected = “reboot_to_bootloader called”)] and removing the catch_unwind boilerplate. The production code under test (reboot_to_bootloader) is unchanged.
Changed components
src/rust/bitbox02-rust/src/hww/api/system.rs (unit test only)Inspect captured patch +8 / −16
diff --git a/src/rust/bitbox02-rust/src/hww/api/system.rs b/src/rust/bitbox02-rust/src/hww/api/system.rs
index b466556..b255d39 100644
--- a/src/rust/bitbox02-rust/src/hww/api/system.rs
+++ b/src/rust/bitbox02-rust/src/hww/api/system.rs
@@ -40,23 +40,15 @@ mod tests {
use util::bb02_async::block_on;
#[test]
+ #[should_panic(expected = "reboot_to_bootloader called")]
pub fn test_reboot_to_bootloader() {
- let reboot_called = std::panic::catch_unwind(|| {
- block_on(reboot_to_bootloader(
- &mut TestingHal::new(),
- &pb::RebootRequest {
- purpose: Purpose::Upgrade as _,
- },
- ))
- .unwrap();
- });
- match reboot_called {
- Ok(()) => panic!("reboot_to_bootloader was not called"),
- Err(msg) => assert_eq!(
- msg.downcast_ref::<&str>(),
- Some(&"reboot_to_bootloader called")
- ),
- }
+ block_on(reboot_to_bootloader(
+ &mut TestingHal::new(),
+ &pb::RebootRequest {
+ purpose: Purpose::Upgrade as _,
+ },
+ ))
+ .unwrap();
}
#[test]
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.