What changed, and why it matters
This commit only adds two new unit tests for Tron personal-message handling and removes two old Tron standard-request test commands from the firmware's test harness. There is no change to production code, no bug fix, and no security-related behavior change.
No security action needed; this is a test-only maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a #[cfg(test)] module in rust/apps/tron/src/structs.rs covering PersonalMessage::from with and without a from/public-key argument. It also deletes the C test wrappers RustTestParseTronStandard and RustTestSignTronStandard plus their command-table entries in test/test_cmd.c. No runtime firmware logic is modified.
Changed components
rust/apps/tron/src/structs.rstest/test_cmd.cInspect captured patch +38 / −54
diff --git a/rust/apps/tron/src/structs.rs b/rust/apps/tron/src/structs.rs
index be6775a..34c032c 100644
--- a/rust/apps/tron/src/structs.rs
+++ b/rust/apps/tron/src/structs.rs
@@ -24,3 +24,41 @@ impl PersonalMessage {
})
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use alloc::string::ToString;
+
+ #[test]
+ fn test_personal_message_without_from() {
+ let msg = PersonalMessage::from(
+ "0x48656c6c6f".to_string(),
+ "Hello".to_string(),
+ None,
+ )
+ .unwrap();
+
+ assert_eq!(msg.raw_message, "0x48656c6c6f");
+ assert_eq!(msg.utf8_message, "Hello");
+ assert_eq!(msg.from, None);
+ }
+
+ #[test]
+ fn test_personal_message_with_from() {
+ let pubkey_hex = "0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8";
+ let pubkey_bytes = hex::decode(pubkey_hex).unwrap();
+ let pubkey = PublicKey::from_slice(&pubkey_bytes).unwrap();
+
+ let msg = PersonalMessage::from(
+ "0x48656c6c6f".to_string(),
+ "Hello".to_string(),
+ Some(pubkey),
+ )
+ .unwrap();
+
+ assert_eq!(msg.raw_message, "0x48656c6c6f");
+ assert_eq!(msg.utf8_message, "Hello");
+ assert!(msg.from.is_some());
+ }
+}
diff --git a/test/test_cmd.c b/test/test_cmd.c
index a26ee9f..d1b3c4b 100644
--- a/test/test_cmd.c
+++ b/test/test_cmd.c
@@ -132,8 +132,6 @@ static void RustTestParseBTCKeystone(int argc, char *argv[]);
static void RustTestCheckFailedBTCKeystone(int argc, char *argv[]);
static void RustTestCheckSucceedBCHKeystone(int argc, char *argv[]);
static void RustTestParseLTCKeystone(int argc, char *argv[]);
-static void RustTestParseTronStandard(int argc, char *argv[]);
-static void RustTestSignTronStandard(int argc, char *argv[]);
static void RustTestParseTronKeystone(int argc, char *argv[]);
static void RustTestCheckTronKeystoneSucceed(int argc, char *argv[]);
static void RustTestCheckTronKeystoneFailed(int argc, char *argv[]);
@@ -178,8 +176,6 @@ static void RustTestCheckFailedBTCKeystone(int argc, char *argv[]);
static void RustTestCheckSucceedBCHKeystone(int argc, char *argv[]);
static void RustTestParseLTCKeystone(int argc, char *argv[]);
static void RustTestParseTronKeystone(int argc, char *argv[]);
-static void RustTestParseTronStandard(int argc, char *argv[]);
-static void RustTestSignTronStandard(int argc, char *argv[]);
static void RustTestCheckTronKeystoneSucceed(int argc, char *argv[]);
static void RustTestCheckTronKeystoneFailed(int argc, char *argv[]);
static void RustTestSignTronKeystone(int argc, char *argv[]);
@@ -299,8 +295,6 @@ const static UartTestCmdItem_t g_uartTestCmdTable[] = {
{"rust test check bch succeed", RustTestCheckSucceedBCHKeystone},
{"rust test parse ltc", RustTestParseLTCKeystone},
{"rust test parse tron keystone", RustTestParseTronKeystone},
- {"rust test parse tron standard request", RustTestParseTronStandard},
- {"rust test sign tron standard request", RustTestSignTronStandard},
{"rust test check tron keystone succeed:", RustTestCheckTronKeystoneSucceed},
{"rust test check tron keystone failed", RustTestCheckTronKeystoneFailed},
{"rust test sign tron keystone:", RustTestSignTronKeystone},
@@ -1321,54 +1315,6 @@ static void RustTestParseLTCKeystone(int argc, char *argv[])
printf("FreeHeapSize = %d\n", xPortGetFreeHeapSize());
}
-void RustTestParseTronStandard(int argc, char *argv[])
-{
- printf("--- Test Tron Standard Parse Start ---\r\n");
-
- URParseResult *ur = test_get_tron_standard_request_bytes();
- void *ur_ptr = ur->data;
-
- TransactionParseResult_DisplayTron *result = tron_parse_sign_request(ur_ptr);
-
- printf("Error Code: %d\r\n", result->error_code);
- if (result->error_code == 0) {
- printf("From: %s\r\n", result->data->overview->from);
- printf("To: %s\r\n", result->data->overview->to);
- printf("Value: %s\r\n", result->data->overview->value);
- printf("Method: %s\r\n", result->data->overview->method);
- } else {
- printf("Error Message: %s\r\n", result->error_message);
- }
-
- free_ur_parse_result(ur);
- free_TransactionParseResult_DisplayTron(result);
- printf("--- Test Tron Standard Parse End ---\r\n");
-}
-
-void RustTestSignTronStandard(int argc, char *argv[])
-{
- printf("--- Test Tron Standard Sign Start ---\r\n");
- int32_t index = 0;
-
- URParseResult *ur = test_get_tron_standard_request_bytes();
- void *ur_ptr = ur->data;
-
- uint8_t seed[64];
- GetAccountSeed(index, seed, "123456");
-
- UREncodeResult *result = tron_sign_request(ur_ptr, seed, sizeof(seed));
-
- if (result->error_code == 0) {
- printf("Signature UR: %s\r\n", result->data);
- } else {
- printf("Sign Failed: %s\r\n", result->error_message);
- }
-
- free_ur_parse_result(ur);
- free_ur_encode_result(result);
- printf("--- Test Tron Standard Sign End ---\r\n");
-}
-
static void RustTestParseTronKeystone(int argc, char *argv[])
{
printf("RustTestParseTronKeystone 11\r\n");
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.