From 1091f53db6b2c09fe8432911034a4ddfa2a73688 Mon Sep 17 00:00:00 2001 From: Marvin Jones Date: Wed, 15 Jul 2026 11:14:49 -0400 Subject: [PATCH] test: align is_authorized with PrivateForeignInit's flipped semantics Recipient pre-states built for PrivateForeignInit now need is_authorized: true to match the assertion in output.rs. Also rewrites the boundary test that checked the old invalid case to check the new one, and updates stale "unauthorized" wording left over from the PrivateUnauthorized name. --- .../circuit/tests.rs | 16 ++++++++-------- lee/state_machine/src/state/tests/circuit.rs | 18 +++++++++--------- lee/state_machine/src/state/tests/mod.rs | 4 ++-- .../src/state/tests/validity_window.rs | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs b/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs index ac9db51b..34f3cede 100644 --- a/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs +++ b/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs @@ -60,7 +60,7 @@ fn prove_privacy_preserving_execution_circuit_public_and_private_pre_accounts() let recipient_account_id = AccountId::for_regular_private_account(&recipient_keys.npk(), &recipient_keys.vpk(), 0); - let recipient = AccountWithMetadata::new(Account::default(), false, recipient_account_id); + let recipient = AccountWithMetadata::new(Account::default(), true, recipient_account_id); let balance_to_move: u128 = 37; @@ -144,7 +144,7 @@ fn prove_privacy_preserving_execution_circuit_fully_private() { let recipient_account_id = AccountId::for_regular_private_account(&recipient_keys.npk(), &recipient_keys.vpk(), 0); - let recipient = AccountWithMetadata::new(Account::default(), false, recipient_account_id); + let recipient = AccountWithMetadata::new(Account::default(), true, recipient_account_id); let balance_to_move: u128 = 37; let mut commitment_set = CommitmentSet::with_capacity(2); @@ -247,7 +247,7 @@ fn circuit_fails_when_chained_validity_windows_have_empty_intersection() { let account_keys = test_private_account_keys_1(); let pre = AccountWithMetadata::new( Account::default(), - false, + true, AccountId::for_regular_private_account(&account_keys.npk(), &account_keys.vpk(), 0), ); @@ -422,7 +422,7 @@ fn private_pda_withdraw() { /// Shared regular private account: receives funds via `authenticated_transfer` directly, /// no custom program needed. This demonstrates the non-PDA shared account flow where /// keys are derived from GMS via `derive_keys_for_shared_account`. The shared account -/// uses the standard unauthorized private account path and works with auth-transfer's +/// uses the standard foreign private account path and works with auth-transfer's /// transfer path like any other private account. #[test] fn shared_account_receives_via_simple_transfer() { @@ -443,9 +443,9 @@ fn shared_account_receives_via_simple_transfer() { sender_id, ); - // Recipient: shared private account (new, unauthorized) + // Recipient: shared private account (new, foreign) let shared_account_id = AccountId::from((&shared_npk, &shared_keys.vpk(), shared_identifier)); - let recipient = AccountWithMetadata::new(Account::default(), false, shared_account_id); + let recipient = AccountWithMetadata::new(Account::default(), true, shared_account_id); let balance_to_move: u128 = 100; let instruction = Program::serialize_instruction(balance_to_move).unwrap(); @@ -510,7 +510,7 @@ fn private_authorized_init_encrypts_regular_kind_with_identifier() { /// `PrivateForeignInit` with a non-default identifier produces a ciphertext that decrypts /// to `PrivateAccountKind::Regular` carrying the correct identifier. #[test] -fn private_unauthorized_init_encrypts_regular_kind_with_identifier() { +fn private_foreign_init_encrypts_regular_kind_with_identifier() { let program = crate::test_methods::claimer(); let keys = test_private_account_keys_1(); let identifier: u128 = 99; @@ -521,7 +521,7 @@ fn private_unauthorized_init_encrypts_regular_kind_with_identifier() { &Nonce::private_account_nonce_init(&recipient_id), ); let ssk = SharedSecretKey::encapsulate_deterministic(&keys.vpk(), &esk).0; - let recipient = AccountWithMetadata::new(Account::default(), false, recipient_id); + let recipient = AccountWithMetadata::new(Account::default(), true, recipient_id); let (output, _) = execute_and_prove( vec![recipient], diff --git a/lee/state_machine/src/state/tests/circuit.rs b/lee/state_machine/src/state/tests/circuit.rs index 4875c76a..160b033c 100644 --- a/lee/state_machine/src/state/tests/circuit.rs +++ b/lee/state_machine/src/state/tests/circuit.rs @@ -49,7 +49,7 @@ fn circuit_fails_if_invalid_auth_keys_are_provided() { ); let private_account_2 = AccountWithMetadata::new( Account::default(), - false, + true, (&recipient_keys.npk(), &recipient_keys.vpk(), 0), ); @@ -102,7 +102,7 @@ fn circuit_should_fail_if_new_private_account_with_non_default_balance_is_provid balance: 1, ..Account::default() }, - false, + true, (&recipient_keys.npk(), &recipient_keys.vpk(), 0), ); @@ -151,7 +151,7 @@ fn circuit_should_fail_if_new_private_account_with_non_default_program_owner_is_ program_owner: [0, 1, 2, 3, 4, 5, 6, 7], ..Account::default() }, - false, + true, (&recipient_keys.npk(), &recipient_keys.vpk(), 0), ); @@ -200,7 +200,7 @@ fn circuit_should_fail_if_new_private_account_with_non_default_data_is_provided( data: b"hola mundo".to_vec().try_into().unwrap(), ..Account::default() }, - false, + true, (&recipient_keys.npk(), &recipient_keys.vpk(), 0), ); @@ -249,7 +249,7 @@ fn circuit_should_fail_if_new_private_account_with_non_default_nonce_is_provided nonce: Nonce(0xdead_beef), ..Account::default() }, - false, + true, (&recipient_keys.npk(), &recipient_keys.vpk(), 0), ); @@ -279,7 +279,7 @@ fn circuit_should_fail_if_new_private_account_with_non_default_nonce_is_provided } #[test] -fn circuit_should_fail_if_new_private_account_is_provided_with_default_values_but_marked_as_authorized() +fn circuit_should_fail_if_new_private_account_is_provided_with_default_values_but_marked_as_unauthorized() { let program = crate::test_methods::simple_balance_transfer(); let sender_keys = test_private_account_keys_1(); @@ -295,8 +295,8 @@ fn circuit_should_fail_if_new_private_account_is_provided_with_default_values_bu ); let private_account_2 = AccountWithMetadata::new( Account::default(), - // This should be set to false in normal circumstances - true, + // This should be set to true in normal circumstances + false, (&recipient_keys.npk(), &recipient_keys.vpk(), 0), ); @@ -773,7 +773,7 @@ fn private_unauthorized_uninitialized_account_can_still_be_claimed() { // remains allowed. let unauthorized_account = AccountWithMetadata::new( Account::default(), - false, + true, (&private_keys.npk(), &private_keys.vpk(), 0), ); diff --git a/lee/state_machine/src/state/tests/mod.rs b/lee/state_machine/src/state/tests/mod.rs index 1d6b87a2..76a8db7d 100644 --- a/lee/state_machine/src/state/tests/mod.rs +++ b/lee/state_machine/src/state/tests/mod.rs @@ -269,7 +269,7 @@ fn shielded_balance_transfer_for_tests( let recipient = AccountWithMetadata::new( Account::default(), - false, + true, (&recipient_keys.npk(), &recipient_keys.vpk(), 0), ); @@ -319,7 +319,7 @@ fn private_balance_transfer_for_tests( ); let recipient_pre = AccountWithMetadata::new( Account::default(), - false, + true, (&recipient_keys.npk(), &recipient_keys.vpk(), 0), ); diff --git a/lee/state_machine/src/state/tests/validity_window.rs b/lee/state_machine/src/state/tests/validity_window.rs index 4581aa89..7e314bc2 100644 --- a/lee/state_machine/src/state/tests/validity_window.rs +++ b/lee/state_machine/src/state/tests/validity_window.rs @@ -126,7 +126,7 @@ fn validity_window_works_in_privacy_preserving_transactions( let account_keys = test_private_account_keys_1(); let pre = AccountWithMetadata::new( Account::default(), - false, + true, (&account_keys.npk(), &account_keys.vpk(), 0), ); let mut state = V03State::new().with_test_programs(); @@ -191,7 +191,7 @@ fn timestamp_validity_window_works_in_privacy_preserving_transactions( let account_keys = test_private_account_keys_1(); let pre = AccountWithMetadata::new( Account::default(), - false, + true, (&account_keys.npk(), &account_keys.vpk(), 0), ); let mut state = V03State::new().with_test_programs();