Fix blind keyed accounts indexing in Config program (#6369)

This commit is contained in:
Greg Fitzgerald
2019-10-15 14:35:42 -06:00
committed by GitHub
parent ae41c88eb2
commit f6255c2f9e
2 changed files with 41 additions and 18 deletions

View File

@@ -10,10 +10,12 @@ use solana_runtime::{bank::Bank, bank_client::BankClient};
use solana_sdk::{
client::SyncClient,
genesis_block::create_genesis_block,
instruction::InstructionError,
message::Message,
pubkey::Pubkey,
signature::{Keypair, KeypairUtil},
system_instruction,
transaction::TransactionError,
};
#[derive(Serialize, Deserialize, Debug, PartialEq)]
@@ -364,3 +366,26 @@ fn test_config_updates_requiring_config() {
.send_message(&[&mint_keypair, &config_keypair], message)
.unwrap_err();
}
#[test]
fn test_config_initialize_no_panic() {
let (bank, alice_keypair) = create_bank(3);
let bank_client = BankClient::new(bank);
let mut instructions = config_instruction::create_account::<MyConfig>(
&alice_keypair.pubkey(),
&Pubkey::new_rand(),
1,
vec![],
);
instructions[1].accounts = vec![]; // <!-- Attack! Prevent accounts from being passed into processor.
let message = Message::new(instructions);
assert_eq!(
bank_client
.send_message(&[&alice_keypair], message)
.unwrap_err()
.unwrap(),
TransactionError::InstructionError(1, InstructionError::NotEnoughAccountKeys)
);
}