40 lines
1003 B
Rust
40 lines
1003 B
Rust
//! NAC钱包核心集成测试
|
|
|
|
use nac_wallet_core::*;
|
|
|
|
#[test]
|
|
fn test_create_wallet() {
|
|
let keypair = KeyPair::generate(SignatureAlgorithm::Ed25519).unwrap();
|
|
assert_eq!(keypair.public_key.len(), 32);
|
|
|
|
let pubkey_hash = keypair.public_key_hash();
|
|
assert_eq!(pubkey_hash.len(), 26);
|
|
|
|
let address = StructuredAddress::new(
|
|
AccountType::Personal,
|
|
WalletKYCLevel::Standard,
|
|
156,
|
|
pubkey_hash,
|
|
);
|
|
|
|
assert_eq!(address.version, 1);
|
|
assert_eq!(address.account_type, AccountType::Personal);
|
|
}
|
|
|
|
#[test]
|
|
fn test_address_serialization() {
|
|
let pubkey_hash = [1u8; 26];
|
|
let address = StructuredAddress::new(
|
|
AccountType::Enterprise,
|
|
WalletKYCLevel::Advanced,
|
|
840,
|
|
pubkey_hash,
|
|
);
|
|
|
|
let bytes = address.to_bytes();
|
|
assert_eq!(bytes.len(), 32);
|
|
|
|
let recovered = StructuredAddress::from_bytes(&bytes).unwrap();
|
|
assert_eq!(recovered.account_type, AccountType::Enterprise);
|
|
}
|