From 607b368fe33840fcbce80305df8e2f61e49ec0d4 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Mon, 18 Mar 2019 08:53:18 -0600 Subject: [PATCH] Add back in test to check the account program id --- programs/config/src/lib.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/programs/config/src/lib.rs b/programs/config/src/lib.rs index 1cbc551cfba413..011278273fd3a2 100644 --- a/programs/config/src/lib.rs +++ b/programs/config/src/lib.rs @@ -58,7 +58,7 @@ mod tests { use solana_sdk::script::Script; use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::system_instruction::SystemInstruction; - use solana_sdk::transaction::Instruction; + use solana_sdk::transaction::{Instruction, InstructionError, TransactionError}; #[derive(Serialize, Deserialize, Default, Debug, PartialEq)] struct MyConfig { @@ -150,6 +150,24 @@ mod tests { config_client.process_transaction(transaction).unwrap_err(); } + #[test] + fn test_process_store_fail_account0_invalid_owner() { + solana_logger::setup(); + let (bank, from_keypair) = create_bank(10_000); + let config_client = BankClient::new(&bank, from_keypair); + let config_pubkey = config_client.pubkey(); // <-- Invalid owner, not a config account + + let my_config = MyConfig::new(42); + let instruction = ConfigInstruction::new_store(&config_pubkey, &my_config); + assert_eq!( + config_client.process_instruction(instruction), + Err(TransactionError::InstructionError( + 0, + InstructionError::ProgramError(ProgramError::IncorrectProgramId) + )) + ); + } + #[test] fn test_process_store_fail_account0_not_signer() { solana_logger::setup();