From 2c2c4fed764708ee142fc3ec02ac58e244e2fbbd Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Fri, 12 Sep 2025 09:36:26 -0300 Subject: [PATCH] add tests --- nssa/core/src/nullifier.rs | 17 +++++++++++++++++ nssa/src/address.rs | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/nssa/core/src/nullifier.rs b/nssa/core/src/nullifier.rs index 405bb56..c7ee26e 100644 --- a/nssa/core/src/nullifier.rs +++ b/nssa/core/src/nullifier.rs @@ -71,4 +71,21 @@ mod tests { let npk = NullifierPublicKey::from(&nsk); assert_eq!(npk, expected_npk); } + + #[test] + fn test_account_id_from_nullifier_public_key() { + let nsk = [ + 57, 5, 64, 115, 153, 56, 184, 51, 207, 238, 99, 165, 147, 214, 213, 151, 30, 251, 30, + 196, 134, 22, 224, 211, 237, 120, 136, 225, 188, 220, 249, 28, + ]; + let npk = NullifierPublicKey::from(&nsk); + let expected_account_id = AccountId::new([ + 202, 120, 42, 189, 194, 218, 78, 244, 31, 6, 108, 169, 29, 61, 22, 221, 69, 138, 197, + 161, 241, 39, 142, 242, 242, 50, 188, 201, 99, 28, 176, 238, + ]); + + let account_id = AccountId::from(&npk); + + assert_eq!(account_id, expected_account_id); + } } diff --git a/nssa/src/address.rs b/nssa/src/address.rs index 319b236..24fc7cf 100644 --- a/nssa/src/address.rs +++ b/nssa/src/address.rs @@ -90,6 +90,8 @@ impl From<&Address> for AccountId { #[cfg(test)] mod tests { + use nssa_core::account::AccountId; + use crate::{Address, address::AddressError}; #[test] @@ -119,4 +121,14 @@ mod tests { let result = hex_str.parse::
().unwrap_err(); assert!(matches!(result, AddressError::InvalidLength(_))); } + + #[test] + fn test_account_id_from_address() { + let address: Address = "37".repeat(32).parse().unwrap(); + let expected_account_id = AccountId::new([55; 32]); + + let account_id = AccountId::from(&address); + + assert_eq!(account_id, expected_account_id); + } }