https://github.com/SushantChandla/test-mint-bug/blob/main/programs/mint-bug/tests/mint.rs
I am trying to create an associated token account please have a look at the github file.
The error I get is Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL failed: insufficient account keys for instruction
which is weird as i am using the function provided in spl-associated-token-account crate and it should create instruction with all the required accounts.
async fn create_associated_token_account(
context: &mut ProgramTestContext,
account: &Pubkey,
mint: &Pubkey,
payer: &Keypair,
) -> transport::Result<Pubkey> {
let associated_token_account = get_associated_token_address(account, mint);
let associated_ix = spl_associated_token_account::instruction::create_associated_token_account(
&payer.pubkey(),
&account,
&mint,
);
let associated_tx = get_signed_transaction(context, &[associated_ix], payer).await;
context
.banks_client
.process_transaction(associated_tx)
.await?;
return Ok(associated_token_account);
}
Here are logs:
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/mint.rs (target/debug/deps/mint-b02ef8a2fffb7767)
running 1 test
[2022-08-14T17:00:14.371540000Z INFO solana_program_test] "mint_bug" BPF program from /Users/sushantchandla/Projects/mint-bug/target/deploy/mint_bug.so, modified 1 minute, 74 ms, 62 µs and 704 ns ago
[2022-08-14T17:00:14.479628000Z DEBUG solana_runtime::message_processor::stable_log] Program 11111111111111111111111111111111 invoke [1]
[2022-08-14T17:00:14.479697000Z TRACE solana_runtime::system_instruction_processor] process_instruction: CreateAccount { lamports: 1461600, space: 82, owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA }
[2022-08-14T17:00:14.479729000Z TRACE solana_runtime::system_instruction_processor] keyed_accounts: [KeyedAccount { is_signer: false, is_writable: false, key: 11111111111111111111111111111111, account: RefCell { value: Account { lamports: 1, data.len: 14, owner: NativeLoader1111111111111111111111111111111, executable: true, rent_epoch: 0, data: 73797374656d5f70726f6772616d } } }, KeyedAccount { is_signer: true, is_writable: true, key: 7seLqAnajhJ5yFDgzFoBEt65ETYfZ99vWiuX3eDzu8Yg, account: RefCell { value: Account { lamports: 99999990000, data.len: 0, owner: 11111111111111111111111111111111, executable: false, rent_epoch: 0 } } }, KeyedAccount { is_signer: true, is_writable: true, key: BgGUR32WU9WJVwxdPKT4cfPnthg53TsikuoMWn8ZzBy8, account: RefCell { value: Account { lamports: 0, data.len: 0, owner: 11111111111111111111111111111111, executable: false, rent_epoch: 0 } } }]
[2022-08-14T17:00:14.479875000Z DEBUG solana_runtime::message_processor::stable_log] Program 11111111111111111111111111111111 success
[2022-08-14T17:00:14.497758000Z DEBUG solana_runtime::message_processor::stable_log] Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]
[2022-08-14T17:00:14.498167000Z DEBUG solana_runtime::message_processor::stable_log] Program log: Instruction: InitializeMint
[2022-08-14T17:00:14.498666000Z DEBUG solana_rbpf::vm] BPF instructions executed (interp): 2253
[2022-08-14T17:00:14.498678000Z DEBUG solana_rbpf::vm] Max frame depth reached: 9
[2022-08-14T17:00:14.498686000Z DEBUG solana_runtime::message_processor::stable_log] Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2353 of 200000 compute units
[2022-08-14T17:00:14.498754000Z DEBUG solana_runtime::message_processor::stable_log] Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
[2022-08-14T17:00:14.515489000Z DEBUG solana_runtime::message_processor::stable_log] Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]
[2022-08-14T17:00:14.516218000Z DEBUG solana_rbpf::vm] BPF instructions executed (interp): 1953
[2022-08-14T17:00:14.516231000Z DEBUG solana_rbpf::vm] Max frame depth reached: 4
[2022-08-14T17:00:14.516239000Z DEBUG solana_runtime::message_processor::stable_log] Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 1953 of 200000 compute units
[2022-08-14T17:00:14.516277000Z DEBUG solana_runtime::message_processor::stable_log] Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL failed: insufficient account keys for instruction
test mint_tokens ... FAILED
failures:
---- mint_tokens stdout ----
thread 'mint_tokens' panicked at 'failed to create associated token account: TransactionError(InstructionError(0, NotEnoughAccountKeys))', programs/mint-bug/tests/mint.rs:84:6
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
mint_tokens
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.15s