sdk: refactor pda generation
This commit is contained in:
committed by
Trent Nelson
parent
f871afd548
commit
d3a7e22112
@@ -263,8 +263,10 @@ fn process_instruction(
|
||||
)?,
|
||||
accounts[DERIVED_KEY1_INDEX].key
|
||||
);
|
||||
let not_native_program_id = Pubkey::new_from_array([6u8; 32]);
|
||||
assert!(!not_native_program_id.is_native_program_id());
|
||||
assert_eq!(
|
||||
Pubkey::create_program_address(&[b"You pass butter"], &Pubkey::default())
|
||||
Pubkey::create_program_address(&[b"You pass butter"], ¬_native_program_id)
|
||||
.unwrap_err(),
|
||||
PubkeyError::InvalidSeeds
|
||||
);
|
||||
@@ -276,8 +278,10 @@ fn process_instruction(
|
||||
Pubkey::try_find_program_address(&[b"You pass butter"], program_id).unwrap();
|
||||
assert_eq!(&address, accounts[DERIVED_KEY1_INDEX].key);
|
||||
assert_eq!(bump_seed, bump_seed1);
|
||||
let not_native_program_id = Pubkey::new_from_array([6u8; 32]);
|
||||
assert!(!not_native_program_id.is_native_program_id());
|
||||
assert_eq!(
|
||||
Pubkey::create_program_address(&[b"You pass butter"], &Pubkey::default())
|
||||
Pubkey::create_program_address(&[b"You pass butter"], ¬_native_program_id)
|
||||
.unwrap_err(),
|
||||
PubkeyError::InvalidSeeds
|
||||
);
|
||||
|
@@ -2192,8 +2192,10 @@ mod tests {
|
||||
let upgrade_authority_address = Pubkey::new_unique();
|
||||
let buffer_address = Pubkey::new_unique();
|
||||
let program_address = Pubkey::new_unique();
|
||||
let (programdata_address, _) =
|
||||
Pubkey::find_program_address(&[program_address.as_ref()], &id());
|
||||
let (programdata_address, _) = Pubkey::find_program_address(
|
||||
&[program_address.as_ref()],
|
||||
&bpf_loader_upgradeable::id(),
|
||||
);
|
||||
let spill_address = Pubkey::new_unique();
|
||||
let upgrade_authority_account = AccountSharedData::new_ref(1, 0, &Pubkey::new_unique());
|
||||
let rent_id = sysvar::rent::id();
|
||||
@@ -2846,8 +2848,10 @@ mod tests {
|
||||
let new_upgrade_authority_address = Pubkey::new_unique();
|
||||
let new_upgrade_authority_account = AccountSharedData::new_ref(1, 0, &Pubkey::new_unique());
|
||||
let program_address = Pubkey::new_unique();
|
||||
let (programdata_address, _) =
|
||||
Pubkey::find_program_address(&[program_address.as_ref()], &id());
|
||||
let (programdata_address, _) = Pubkey::find_program_address(
|
||||
&[program_address.as_ref()],
|
||||
&bpf_loader_upgradeable::id(),
|
||||
);
|
||||
let programdata_account = AccountSharedData::new_ref(
|
||||
1,
|
||||
UpgradeableLoaderState::programdata_len(0).unwrap(),
|
||||
|
@@ -12,7 +12,7 @@ use solana_sdk::{
|
||||
stake::config::Config as StakeConfig,
|
||||
};
|
||||
|
||||
solana_sdk::declare_id!("Config1111111111111111111111111111111111111");
|
||||
pub use solana_sdk::config::program::id;
|
||||
|
||||
pub trait ConfigState: serde::Serialize + Default {
|
||||
/// Maximum space that the serialized representation will require
|
||||
|
@@ -12,4 +12,4 @@ extern crate solana_metrics;
|
||||
#[macro_use]
|
||||
extern crate solana_frozen_abi_macro;
|
||||
|
||||
solana_sdk::declare_id!("Vote111111111111111111111111111111111111111");
|
||||
pub use solana_sdk::vote::program::{check_id, id};
|
||||
|
Reference in New Issue
Block a user