mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 21:33:09 +00:00
add tests
This commit is contained in:
parent
f31bbe4876
commit
2c2c4fed76
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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::<Address>().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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user