Return an error from create_program_address syscall (#11658)

This commit is contained in:
Jack May
2020-08-17 09:49:40 -07:00
committed by GitHub
parent f8606fca4f
commit 750e5344f1
2 changed files with 17 additions and 6 deletions

View File

@ -12,7 +12,7 @@ use solana_sdk::{
info,
program::{invoke, invoke_signed},
program_error::ProgramError,
pubkey::Pubkey,
pubkey::{Pubkey, PubkeyError},
system_instruction,
};
@ -97,9 +97,15 @@ fn process_instruction(
info!("Test create_program_address");
{
let address =
Pubkey::create_program_address(&[b"You pass butter", &[nonce1]], program_id)?;
assert_eq!(&address, accounts[DERIVED_KEY1_INDEX].key);
assert_eq!(
&Pubkey::create_program_address(&[b"You pass butter", &[nonce1]], program_id)?,
accounts[DERIVED_KEY1_INDEX].key
);
assert_eq!(
Pubkey::create_program_address(&[b"You pass butter"], &Pubkey::default())
.unwrap_err(),
PubkeyError::InvalidSeeds
);
}
info!("Test derived signers");