refactor: tests use PrivateAddressPlaintext

This commit is contained in:
Artem Gureev 2026-06-30 10:25:05 +00:00 committed by agureev
parent 5fbe0ce9c1
commit d2a7b329fb
9 changed files with 58 additions and 51 deletions

View File

@ -156,11 +156,12 @@ async fn import_private_account() -> Result<()> {
let mut ctx = TestContext::new().await?;
let key_chain = KeyChain::new_os_random();
let account_id = lee::AccountId::from((
&key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
let account_id = lee::PrivateAddressPlaintext::new(
key_chain.nullifier_public_key,
key_chain.viewing_public_key.clone(),
0,
));
)
.account_id();
let account = lee::Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 777,
@ -217,11 +218,12 @@ async fn import_private_account_second_time_overrides_account_data() -> Result<(
let mut ctx = TestContext::new().await?;
let key_chain = KeyChain::new_os_random();
let account_id = lee::AccountId::from((
&key_chain.nullifier_public_key,
&key_chain.viewing_public_key,
let account_id = lee::PrivateAddressPlaintext::new(
key_chain.nullifier_public_key,
key_chain.viewing_public_key.clone(),
0,
));
)
.account_id();
let key_chain_json =
serde_json::to_string(&key_chain).context("Failed to serialize key chain")?;

View File

@ -7,8 +7,8 @@ use integration_tests::{
public_mention, verify_commitment_is_in_state,
};
use lee::{
AccountId, execute_and_prove, privacy_preserving_transaction::circuit::ProgramWithDependencies,
program::Program,
AccountId, PrivateAddressPlaintext, execute_and_prove,
privacy_preserving_transaction::circuit::ProgramWithDependencies, program::Program,
};
use lee_core::{
InputAccountIdentity, NullifierPublicKey, account::AccountWithMetadata,
@ -599,14 +599,14 @@ async fn shielded_transfers_to_two_identifiers_same_npk() -> Result<()> {
.await?;
// Both accounts must be discovered with the correct balances.
let account_id_1 = AccountId::for_regular_private_account(&npk, &vpk, identifier_1);
let account_id_1 = PrivateAddressPlaintext::new(npk, vpk.clone(), identifier_1).account_id();
let acc_1 = ctx
.wallet()
.get_account_private(account_id_1)
.context("account for identifier 1 not found after sync")?;
assert_eq!(acc_1.balance, 100);
let account_id_2 = AccountId::for_regular_private_account(&npk, &vpk, identifier_2);
let account_id_2 = PrivateAddressPlaintext::new(npk, vpk.clone(), identifier_2).account_id();
let acc_2 = ctx
.wallet()
.get_account_private(account_id_2)
@ -667,7 +667,8 @@ async fn ppt_cant_chain_call_faucet() -> Result<()> {
let vpk = ViewingPublicKey::from_bytes(vec![4_u8; 1184]).unwrap();
let attacker_vault_id = {
let seed = vault_core::compute_vault_seed(attacker_id);
AccountId::for_private_pda(&vault_program_id, &seed, &npk, &vpk, 1337)
PrivateAddressPlaintext::new(npk, vpk.clone(), 1337)
.pda_account_id(&vault_program_id, &seed)
};
let amount: u128 = 1;

View File

@ -13,7 +13,7 @@ use integration_tests::{
verify_commitment_is_in_state,
};
use lee::{
AccountId, PrivacyPreservingTransaction, ProgramId,
AccountId, PrivacyPreservingTransaction, PrivateAddressPlaintext, ProgramId,
privacy_preserving_transaction::{
circuit::{ProgramWithDependencies, execute_and_prove},
message::Message,
@ -51,8 +51,8 @@ async fn fund_private_pda(
amount: u128,
auth_transfer: &ProgramWithDependencies,
) -> Result<()> {
let pda_account_id =
AccountId::for_private_pda(&authority_program_id, &seed, &npk, &vpk, identifier);
let pda_account_id = PrivateAddressPlaintext::new(npk, vpk.clone(), identifier)
.pda_account_id(&authority_program_id, &seed);
let sender_account = wallet
.get_account_public(sender)
.await
@ -177,8 +177,10 @@ async fn private_pda_family_members_receive_and_spend() -> Result<()> {
let spend_program =
ProgramWithDependencies::new(proxy, [(auth_transfer_id, auth_transfer)].into());
let alice_pda_0_id = AccountId::for_private_pda(&proxy_id, &seed, &alice_npk, &alice_vpk, 0);
let alice_pda_1_id = AccountId::for_private_pda(&proxy_id, &seed, &alice_npk, &alice_vpk, 1);
let alice_pda_0_id = PrivateAddressPlaintext::new(alice_npk, alice_vpk.clone(), 0)
.pda_account_id(&proxy_id, &seed);
let alice_pda_1_id = PrivateAddressPlaintext::new(alice_npk, alice_vpk.clone(), 1)
.pda_account_id(&proxy_id, &seed);
// Use two different public senders to avoid nonce conflicts between the back-to-back txs.
let senders = ctx.existing_public_accounts();

View File

@ -16,7 +16,8 @@ use bytesize::ByteSize;
use common::transaction::LeeTransaction;
use integration_tests::{TestContext, config::SequencerPartialConfig};
use lee::{
Account, AccountId, PrivacyPreservingTransaction, PrivateKey, PublicKey, PublicTransaction,
Account, AccountId, PrivacyPreservingTransaction, PrivateAddressPlaintext, PrivateKey,
PublicKey, PublicTransaction,
privacy_preserving_transaction::{self as pptx, circuit},
program::Program,
public_transaction as putx,
@ -265,7 +266,7 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
data: Data::default(),
},
true,
AccountId::for_regular_private_account(&sender_npk, &sender_vpk, 0),
PrivateAddressPlaintext::new(sender_npk, sender_vpk.clone(), 0).account_id(),
);
let recipient_nsk = [2; 32];
let recipient_vpk = ViewingPublicKey::from_seed(&[101_u8; 32], &[102_u8; 32]);
@ -273,7 +274,7 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
let recipient_pre = AccountWithMetadata::new(
Account::default(),
false,
AccountId::for_regular_private_account(&recipient_npk, &recipient_vpk, 0),
PrivateAddressPlaintext::new(recipient_npk, recipient_vpk.clone(), 0).account_id(),
);
let balance_to_move: u128 = 1;

View File

@ -907,11 +907,9 @@ fn test_wallet_ffi_transfer_shielded() -> Result<()> {
let (to, to_keys) = unsafe {
let mut out_keys = FfiPrivateAccountKeys::default();
wallet_ffi_create_private_accounts_key(wallet_ffi_handle, &raw mut out_keys).unwrap();
let account_id = lee::AccountId::for_regular_private_account(
&out_keys.npk(),
&out_keys.vpk().unwrap(),
0_u128,
);
let account_id =
lee::PrivateAddressPlaintext::new(out_keys.npk(), out_keys.vpk().unwrap(), 0_u128)
.account_id();
let to: FfiBytes32 = account_id.into();
(to, out_keys)
};
@ -1048,11 +1046,9 @@ fn test_wallet_ffi_transfer_private() -> Result<()> {
let (to, to_keys) = unsafe {
let mut out_keys = FfiPrivateAccountKeys::default();
wallet_ffi_create_private_accounts_key(wallet_ffi_handle, &raw mut out_keys).unwrap();
let account_id = lee::AccountId::for_regular_private_account(
&out_keys.npk(),
&out_keys.vpk().unwrap(),
0_u128,
);
let account_id =
lee::PrivateAddressPlaintext::new(out_keys.npk(), out_keys.vpk().unwrap(), 0_u128)
.account_id();
let to: FfiBytes32 = account_id.into();
(to, out_keys)
};

View File

@ -819,7 +819,7 @@ mod tests {
};
use key_protocol::key_management::KeyChain;
use lee::{
Account, AccountId, Data, PrivacyPreservingTransaction, V03State,
Account, Data, PrivacyPreservingTransaction, PrivateAddressPlaintext, V03State,
error::LeeError,
execute_and_prove,
privacy_preserving_transaction::{Message, circuit::ProgramWithDependencies},
@ -1604,11 +1604,12 @@ mod tests {
#[test]
fn private_bridge_withdraw_invocation_is_dropped() {
let sender_keys = KeyChain::new_os_random();
let sender_account_id = AccountId::for_regular_private_account(
&sender_keys.nullifier_public_key,
&sender_keys.viewing_public_key,
let sender_account_id = PrivateAddressPlaintext::new(
sender_keys.nullifier_public_key,
sender_keys.viewing_public_key.clone(),
0,
);
)
.account_id();
let sender_private_account = Account {
program_owner: Program::authenticated_transfer_program().id(),
balance: 100,
@ -1631,11 +1632,12 @@ mod tests {
let sender_pre = AccountWithMetadata::new(
sender_private_account,
true,
(
&sender_keys.nullifier_public_key,
&sender_keys.viewing_public_key,
PrivateAddressPlaintext::new(
sender_keys.nullifier_public_key,
sender_keys.viewing_public_key.clone(),
0,
),
)
.account_id(),
);
let bridge_pre = AccountWithMetadata::new(
state.get_account_by_id(bridge_account_id),

View File

@ -106,11 +106,12 @@ pub struct PrivateAccountPrivateInitialData {
impl PrivateAccountPrivateInitialData {
#[must_use]
pub fn account_id(&self) -> lee::AccountId {
lee::AccountId::for_regular_private_account(
&self.key_chain.nullifier_public_key,
&self.key_chain.viewing_public_key,
lee::PrivateAddressPlaintext::new(
self.key_chain.nullifier_public_key,
self.key_chain.viewing_public_key.clone(),
self.identifier,
)
.account_id()
}
}
@ -219,7 +220,8 @@ pub fn initial_state() -> V03State {
.map(|init_comm_data| {
let npk = &init_comm_data.npk;
let account_id =
lee::AccountId::for_regular_private_account(npk, &init_comm_data.vpk, 0);
lee::PrivateAddressPlaintext::new(*npk, init_comm_data.vpk.clone(), 0)
.account_id();
let mut acc = init_comm_data.account.clone();

View File

@ -4,7 +4,7 @@ use anyhow::{Context as _, Result};
use bytesize::ByteSize;
use indexer_service::{ChannelId, ClientConfig, IndexerConfig};
use key_protocol::key_management::KeyChain;
use lee::{AccountId, PrivateKey, PublicKey};
use lee::{AccountId, PrivateAddressPlaintext, PrivateKey, PublicKey};
use lee_core::Identifier;
use sequencer_core::config::{BedrockConfig, GenesisAction, SequencerConfig};
use url::Url;
@ -23,11 +23,12 @@ pub struct InitialPrivateAccountForWallet {
impl InitialPrivateAccountForWallet {
#[must_use]
pub fn account_id(&self) -> AccountId {
AccountId::from((
&self.key_chain.nullifier_public_key,
&self.key_chain.viewing_public_key,
PrivateAddressPlaintext::new(
self.key_chain.nullifier_public_key,
self.key_chain.viewing_public_key.clone(),
self.identifier,
))
)
.account_id()
}
}

View File

@ -12,7 +12,7 @@ use criterion::{Criterion, criterion_group, criterion_main};
use key_protocol::key_management::KeyChain;
use lee_core::{
Commitment, EncryptionScheme, SharedSecretKey,
account::{Account, AccountId},
account::{Account, PrivateAddressPlaintext},
program::PrivateAccountKind,
};
@ -49,7 +49,7 @@ fn bench_encryption(c: &mut Criterion) {
let npk = recipient_kc.nullifier_public_key;
let account = Account::default();
let account_id =
AccountId::for_regular_private_account(&npk, &recipient_kc.viewing_public_key, 0);
PrivateAddressPlaintext::new(npk, recipient_kc.viewing_public_key.clone(), 0).account_id();
let commitment = Commitment::new(&account_id, &account);
let (shared, _epk) = SharedSecretKey::encapsulate(&recipient_kc.viewing_public_key);
let kind = PrivateAccountKind::Regular(0_u128);