I am trying to write a test with the solana-program-test crate for a solana program. This program makes a CPI to a token program:
let ix = Instruction {
program_id: *token_program.key,
accounts,
data,
};
invoke_signed(
&ix,
&[source, destination, authority, token_program],
signers,
)
The actual problem is that I am configuring the necessary data in test and I do not know if I am configuring the parameters of the token account properly, and the output fails with this information:
[2024-05-19T13:16:32.214732000Z DEBUG solana_runtime::message_processor::stable_log] Program log: Source: AccountInfo { key: C4hnLciKTRbQBpVudEUNUspTVzji7hjbXQto8HWHmFs2, owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA, is_signer: false, is_writable: true, executable: false, rent_epoch: 0, lamports: 100000, data.len: 165, data: 0000000000000003000000000000000000000000000000000000000000000000f7264700bf2f678de6636c426bf6e31f19c5ab95734ec388bbc3b297ed925332, .. }
[2024-05-19T13:16:32.214761000Z DEBUG solana_runtime::message_processor::stable_log] Program log: Destination: AccountInfo { key: 9QWRBvbNqmTogWomnRB1ikC4Ygsz2vquP63bAVpczRCp, owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA, is_signer: false, is_writable: true, executable: false, rent_epoch: 0, lamports: 100000, data.len: 165, data: 00000000000000040000000000000000000000000000000000000000000000006d1fb1f1c3190167c15dee881fdabbb5001eeb801d42f35ed14baa65d4f8a02f, .. }
[2024-05-19T13:16:32.214782000Z DEBUG solana_runtime::message_processor::stable_log] Program log: Authority: AccountInfo { key: HdmZ8mg7K7Ppwds7utZ5zWzgYFEoeMtSWM7HvSnUzuny, owner: 11111111111111111111111111111111, is_signer: true, is_writable: true, executable: false, rent_epoch: 0, lamports: 100000, data.len: 0, .. }
[2024-05-19T13:16:32.214805000Z DEBUG solana_runtime::message_processor::stable_log] Program log: Token program: AccountInfo { key: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA, owner: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA, is_signer: false, is_writable: false, executable: true, rent_epoch: 0, lamports: 100000, data.len: 0, .. }
[2024-05-19T13:16:32.214814000Z DEBUG solana_runtime::message_processor::stable_log] Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]
test test::test_transaction ... FAILED
successes:
successes:
failures:
---- test::test_transaction stdout ----
thread 'solBankForksCli' panicked at /Users/srivas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-program-test-1.16.23/src/lib.rs:312:77:
Unsupported program id
The configuration in the test is the following:
// Token program id account initialization
let token_program_id_key = spl_token::id();
let token_program_id_account_data_size = 0;
let token_program_id_account_lamports = 100000;
let mut token_program_id_account = Account::new(token_program_id_account_lamports,
token_program_id_account_data_size, &spl_token::id());
token_program_id_account.executable = true;
program_test.add_account(token_program_id_key, token_program_id_account);
Please, feel free to ask me any information. I tried to explain the problem the best way possible.
Thanks in advance.