Skip to content

Commit

Permalink
Add back in test to check the account program id
Browse files Browse the repository at this point in the history
  • Loading branch information
garious authored and solana-grimes committed Mar 18, 2019
1 parent a54854a commit 607b368
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion programs/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 607b368

Please sign in to comment.