Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -545,16 +545,9 @@ async fn test_create_ata_failing() {
.create_and_send_transaction(&[ix], &payer_pubkey, &[&context.payer])
.await;

// Wrong bump can trigger either ProgramFailedToComplete (21) or PrivilegeEscalation (19)
// depending on runtime state - accept either
let is_valid_error =
light_program_test::utils::assert::assert_rpc_error(result.clone(), 0, 21).is_ok()
|| light_program_test::utils::assert::assert_rpc_error(result, 0, 19).is_ok();

assert!(
is_valid_error,
"Expected either ProgramFailedToComplete (21) or PrivilegeEscalation (19)"
);
// Wrong bump is now caught by validate_ata_derivation before account creation
// Error: 3 (InvalidAccountData - PDA derivation mismatch)
light_program_test::utils::assert::assert_rpc_error(result, 0, 3).unwrap();
}

// Test 6: Invalid config account owner
Expand Down
10 changes: 5 additions & 5 deletions programs/compressed-token/program/src/ctoken/create_ata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ fn process_create_associated_token_account_with_mode<const IDEMPOTENT: bool>(
let mint_bytes = mint.key();
let bump = inputs.bump;

// Always validate ATA derivation (both idempotent and non-idempotent modes)
validate_ata_derivation(associated_token_account, owner_bytes, mint_bytes, bump)?;

// If idempotent mode, check if account already exists
if IDEMPOTENT {
validate_ata_derivation(associated_token_account, owner_bytes, mint_bytes, bump)?;
if associated_token_account.is_owned_by(&crate::LIGHT_CPI_SIGNER.program_id) {
return Ok(());
}
if IDEMPOTENT && associated_token_account.is_owned_by(&crate::LIGHT_CPI_SIGNER.program_id) {
return Ok(());
}

// Check account is owned by system program (uninitialized)
Expand Down
Loading