Skip to content

Commit 4c63763

Browse files
committed
idempotent w/ existing ATA
1 parent ef36b0b commit 4c63763

File tree

19 files changed

+765
-153
lines changed

19 files changed

+765
-153
lines changed

Cargo.lock

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
[workspace]
22
resolver = "2"
3-
members = ["interface", "program", "mollusk_harness", "pinocchio/interface", "pinocchio/program"]
3+
members = [
4+
"compat",
5+
"interface",
6+
"mollusk_harness",
7+
"pinocchio/interface",
8+
"pinocchio/program",
9+
"program",
10+
]
411

512
[workspace.metadata.spellcheck]
613
config = "scripts/spellcheck.toml"

compat/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "ata-compat-tests"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "Shared compatibility tests for legacy and Pinocchio ATA programs"
6+
publish = false
7+
8+
[dev-dependencies]
9+
mollusk-svm = "0.7.2"
10+
solana-instruction = "3.2.0"
11+
solana-program-error = "3.0.0"
12+
solana-program-pack = "3.1.0"
13+
solana-address = "2.2.0"
14+
spl-associated-token-account-interface = { version = "2.0.0", path = "../interface" }
15+
spl-associated-token-account-mollusk-harness = { version = "1.0.0", path = "../mollusk_harness" }
16+
spl-token-2022-interface = "2.1.0"
17+
spl-token-interface = "2.0.0"
18+
test-case = "3.3.1"
19+
20+
[lints]
21+
workspace = true

compat/tests/create_always.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use {
2+
mollusk_svm::result::Check,
3+
solana_address::Address,
4+
solana_program_error::ProgramError,
5+
spl_associated_token_account_mollusk_harness::{
6+
build_create_ata_instruction, AtaProgramUnderTest, AtaTestHarness, CreateAtaInstructionType,
7+
},
8+
test_case::test_matrix,
9+
};
10+
11+
#[test_matrix(
12+
[AtaProgramUnderTest::Legacy, AtaProgramUnderTest::Pinocchio],
13+
[spl_token_interface::id(), spl_token_2022_interface::id()]
14+
)]
15+
fn create_rejects_existing_ata(ata_program: AtaProgramUnderTest, token_program_id: Address) {
16+
let harness =
17+
AtaTestHarness::new_for(ata_program, &token_program_id).with_wallet_and_mint(1_000_000, 6);
18+
let wallet = harness.wallet.unwrap();
19+
let mint = harness.mint.unwrap();
20+
let ata_address = harness.insert_token_account_at_ata_address(wallet);
21+
22+
let instruction = build_create_ata_instruction(
23+
spl_associated_token_account_interface::program::id(),
24+
harness.payer,
25+
ata_address,
26+
wallet,
27+
mint,
28+
token_program_id,
29+
CreateAtaInstructionType::Create {
30+
bump: None,
31+
account_len: None,
32+
},
33+
);
34+
35+
harness
36+
.ctx
37+
.process_and_validate_instruction(&instruction, &[Check::err(ProgramError::IllegalOwner)]);
38+
}

0 commit comments

Comments
 (0)