What changed, and why it matters
This commit only changes test code for the Avalanche app. It adds two new unit tests for address encoding and HD path validation, and corrects one existing test assertion about which blockchain ID an export transaction should return. There are no changes to production code, so this does not fix or introduce a runtime security issue.
No security action needed; treat as routine test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is confined to #[cfg(test)] modules. In address.rs it adds encode_and_evm_address_test and get_address_invalid_hd_path. In transactions/export.rs it changes an expected value in a test from X_TEST_BLOCKCHAIN_ID to P_BLOCKCHAIN_ID. No library or runtime logic is modified.
Changed components
rust/apps/avalanche/src/address.rs (tests only)rust/apps/avalanche/src/transactions/export.rs (tests only)Inspect captured patch +26 / −1
diff --git a/rust/apps/avalanche/src/address.rs b/rust/apps/avalanche/src/address.rs
index f6e2370..00eb8be 100644
--- a/rust/apps/avalanche/src/address.rs
+++ b/rust/apps/avalanche/src/address.rs
@@ -109,4 +109,29 @@ mod tests {
);
}
}
+
+ #[test]
+ fn encode_and_evm_address_test() {
+ // 20-byte payload
+ let data: [u8; ADDRESS_LEN] = [
+ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x11, 0x22,
+ 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc,
+ ];
+ let addr = Address { address: data };
+ let bech = addr.encode();
+ assert!(bech.starts_with("avax1"));
+ let evm = addr.to_evm_address();
+ assert!(evm.starts_with("0x"));
+ assert_eq!(evm.len(), 2 + 40); // 0x + 40 hex chars
+ }
+
+ #[test]
+ fn get_address_invalid_hd_path() {
+ let hd_path = "m/44'/9000'/0'/0/0";
+ let root_x_pub = "xpub6CPE4bhTujy9CeJJbyskjJsp8FGgyWBsWV2W9GfZwuP9aeDBEoPRBsLk3agq32Gp5gkb9nJSjCn9fgZmuvmV3nPLk5Bc2wfKUQZREp4eG13";
+ // root_path not a prefix of hd_path → should error
+ let root_path = "m/44'/9000'/1'";
+ let err = get_address(Network::AvaxMainNet, hd_path, root_x_pub, root_path).unwrap_err();
+ matches!(err, AvaxError::InvalidHDPath(_));
+ }
}
diff --git a/rust/apps/avalanche/src/transactions/export.rs b/rust/apps/avalanche/src/transactions/export.rs
index 951460d..9924855 100644
--- a/rust/apps/avalanche/src/transactions/export.rs
+++ b/rust/apps/avalanche/src/transactions/export.rs
@@ -124,7 +124,7 @@ mod tests {
let bytes =
Bytes::from(hex::decode(input_bytes).expect("Failed to decode hex string"));
let result = ExportTx::try_from(bytes).unwrap();
- assert_eq!(result.get_dest_chain(), X_TEST_BLOCKCHAIN_ID);
+ assert_eq!(result.get_dest_chain(), P_BLOCKCHAIN_ID);
}
// p chain export to x
Why this scored 12/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.