added test for new nonce mechanism

This commit is contained in:
jonesmarvin8 2026-02-17 19:10:35 -05:00
parent fa6a99192e
commit 946a45b8a3
24 changed files with 21 additions and 4 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -15,7 +15,7 @@ use nssa::{
};
use nssa_core::{
MembershipProof, NullifierPublicKey,
account::{AccountWithMetadata, data::Data},
account::{AccountWithMetadata, Nonce, data::Data},
encryption::ViewingPublicKey,
};
use tokio::test;

View File

@ -10,7 +10,7 @@ use anyhow::Result;
use integration_tests::{BlockingTestContext, TIME_TO_WAIT_FOR_BLOCK_SECONDS};
use log::info;
use nssa::{Account, AccountId, PrivateKey, PublicKey, program::Program};
use nssa_core::program::DEFAULT_PROGRAM_ID;
use nssa_core::{account::Nonce, program::DEFAULT_PROGRAM_ID};
use tempfile::tempdir;
use wallet::WalletCore;
use wallet_ffi::{
@ -523,7 +523,7 @@ fn test_wallet_ffi_get_account_private() -> Result<()> {
);
assert_eq!(account.balance, 10000);
assert!(account.data.is_empty());
assert_eq!(account.nonce, 0);
assert_eq!(account.nonce, Nonce(0));
unsafe {
wallet_ffi_free_account_data((&mut out_account) as *mut FfiAccount);

View File

@ -235,4 +235,21 @@ mod tests {
let expected_account_id = AccountId::new([0; 32]);
assert!(default_account_id == expected_account_id);
}
#[test]
fn initialize_private_nonce() {
let npk = NullifierPublicKey([42; 32]);
let nonce = Nonce::default().private_account_nonce_init(&npk);
let expected_nonce = Nonce(37937661125547691021612781941709513486);
assert_eq!(nonce, expected_nonce);
}
#[test]
fn increment_private_nonce() {
let nsk: NullifierSecretKey = [42u8; 32];
let nonce =
Nonce(37937661125547691021612781941709513486).private_account_nonce_increment(&nsk);
let expected_nonce = Nonce(327300903218789900388409116014290259894);
assert_eq!(nonce, expected_nonce);
}
}

View File

@ -89,7 +89,7 @@ impl Message {
pub mod tests {
use nssa_core::{
Commitment, EncryptionScheme, Nullifier, NullifierPublicKey, SharedSecretKey,
account::Account,
account::{Account, Nonce},
encryption::{EphemeralPublicKey, ViewingPublicKey},
};
use sha2::{Digest, Sha256};