What changed, and why it matters
This commit only adds and updates test code for error handling in the Tron app. It expands unit tests to check that various error types convert correctly and removes an unnecessary `mut` keyword from a test variable. There are no changes to production code or security-sensitive behavior.
No security action needed; routine test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies two Rust test modules. In errors.rs, it renames the test module, expands assertions for KeystoreError, base58::Error, and ParseFloatError conversions, and adds equality/display checks for TronError variants. In wrapped_tron.rs, it removes an unused mut from a test-local WrappedTron instance. No runtime logic is altered.
Changed components
rust/apps/tron/src/errors.rs (tests only)rust/apps/tron/src/transaction/wrapped_tron.rs (tests only)Inspect captured patch +27 / −10
diff --git a/rust/apps/tron/src/errors.rs b/rust/apps/tron/src/errors.rs
index 087e1eb..377ee60 100644
--- a/rust/apps/tron/src/errors.rs
+++ b/rust/apps/tron/src/errors.rs
@@ -57,22 +57,39 @@ impl From<core::num::ParseFloatError> for TronError {
}
#[cfg(test)]
-mod error_tests {
+mod tests {
use super::*;
+ use bitcoin::base58;
use keystore::errors::KeystoreError;
#[test]
- fn test_tron_errors() {
- let errs = vec![
+ fn test_comprehensive_error_conversions() {
+ let ks_cases = vec![
+ KeystoreError::RSASignError,
+ KeystoreError::XPubError("xpub".to_string()),
+ ];
+ for ks_err in ks_cases {
+ let tr_err: TronError = ks_err.into();
+ assert!(format!("{}", tr_err).contains("keystore"));
+ }
+
+ let base58_err = base58::decode_check("123").unwrap_err();
+ let tr_base58_err = TronError::from(base58_err);
+ assert!(format!("{}", tr_base58_err).contains("base58"));
+
+ let float_err = "not_a_number".parse::<f64>().unwrap_err();
+ let tr_float_err: TronError = float_err.into();
+ assert!(matches!(tr_float_err, TronError::ParseNumberError(_)));
+
+ let all_variants = vec![
TronError::InvalidHDPath("path".to_string()),
TronError::NoMyInputs,
- TronError::SignFailure("reason".to_string()),
+ TronError::Base58Error("b58".to_string()),
];
- for e in errs {
- let _ = format!("{}", e);
- }
- let _: TronError = KeystoreError::RSASignError.into();
- let _: TronError = KeystoreError::XPubError("err".to_string()).into();
+ for err in all_variants {
+ let _ = format!("{}", err);
+ assert_eq!(err, err);
+ }
}
}
diff --git a/rust/apps/tron/src/transaction/wrapped_tron.rs b/rust/apps/tron/src/transaction/wrapped_tron.rs
index fd45eb0..c4cd465 100644
--- a/rust/apps/tron/src/transaction/wrapped_tron.rs
+++ b/rust/apps/tron/src/transaction/wrapped_tron.rs
@@ -579,7 +579,7 @@ mod tests {
#[test]
fn test_signature_hash_empty_raw() {
- let mut tx = WrappedTron {
+ let tx = WrappedTron {
tron_tx: Transaction::default(),
hd_path: "".to_string(),
extended_pubkey: "".to_string(),
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.