Unifies ThisInvokeContext and dyn trait InvokeContext. (#21563)
This commit is contained in:
committed by
GitHub
parent
8dfa83c579
commit
bfdb775ffc
@ -34,7 +34,7 @@ const NOOP_PROGRAM_ID: [u8; 32] = [
|
||||
fn process_instruction(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &mut InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -6958,7 +6958,7 @@ pub(crate) mod tests {
|
||||
fn mock_process_instruction(
|
||||
first_instruction_account: usize,
|
||||
data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> result::Result<(), InstructionError> {
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
if let Ok(instruction) = bincode::deserialize(data) {
|
||||
@ -10709,7 +10709,7 @@ pub(crate) mod tests {
|
||||
fn mock_vote_processor(
|
||||
_first_instruction_account: usize,
|
||||
_instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
let program_id = invoke_context.get_caller()?;
|
||||
if mock_vote_program_id() != *program_id {
|
||||
@ -10767,7 +10767,7 @@ pub(crate) mod tests {
|
||||
fn mock_vote_processor(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
Err(InstructionError::Custom(42))
|
||||
}
|
||||
@ -10817,7 +10817,7 @@ pub(crate) mod tests {
|
||||
fn mock_ix_processor(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
Err(InstructionError::Custom(42))
|
||||
}
|
||||
@ -11705,7 +11705,7 @@ pub(crate) mod tests {
|
||||
fn mock_process_instruction(
|
||||
first_instruction_account: usize,
|
||||
data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> result::Result<(), InstructionError> {
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
let lamports = data[0] as u64;
|
||||
@ -11763,7 +11763,7 @@ pub(crate) mod tests {
|
||||
fn mock_process_instruction(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &mut InvokeContext,
|
||||
) -> result::Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
@ -11949,7 +11949,7 @@ pub(crate) mod tests {
|
||||
fn mock_ok_vote_processor(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
@ -12199,7 +12199,7 @@ pub(crate) mod tests {
|
||||
fn nested_processor(
|
||||
first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> result::Result<(), InstructionError> {
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
let account = keyed_account_at_index(keyed_accounts, first_instruction_account)?;
|
||||
@ -12473,7 +12473,7 @@ pub(crate) mod tests {
|
||||
fn mock_ix_processor(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
@ -12522,7 +12522,7 @@ pub(crate) mod tests {
|
||||
fn mock_ix_processor(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_context: &mut dyn InvokeContext,
|
||||
_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
@ -12899,11 +12899,11 @@ pub(crate) mod tests {
|
||||
#[derive(Debug)]
|
||||
struct TestExecutor {}
|
||||
impl Executor for TestExecutor {
|
||||
fn execute(
|
||||
fn execute<'a, 'b>(
|
||||
&self,
|
||||
_first_instruction_account: usize,
|
||||
_instruction_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &'a mut InvokeContext<'b>,
|
||||
_use_jit: bool,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
Ok(())
|
||||
@ -13422,7 +13422,7 @@ pub(crate) mod tests {
|
||||
fn mock_process_instruction(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), solana_sdk::instruction::InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
@ -14923,7 +14923,7 @@ pub(crate) mod tests {
|
||||
fn mock_ix_processor(
|
||||
first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
use solana_sdk::account::WritableAccount;
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
@ -15135,7 +15135,7 @@ pub(crate) mod tests {
|
||||
fn mock_ix_processor(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
let compute_budget = invoke_context.get_compute_budget();
|
||||
assert_eq!(
|
||||
@ -15180,7 +15180,7 @@ pub(crate) mod tests {
|
||||
fn mock_ix_processor(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
let compute_budget = invoke_context.get_compute_budget();
|
||||
assert_eq!(
|
||||
|
@ -15,7 +15,7 @@ fn process_instruction_with_program_logging(
|
||||
process_instruction: ProcessInstructionWithContext,
|
||||
first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
let logger = invoke_context.get_log_collector();
|
||||
let program_id = invoke_context.get_caller()?;
|
||||
@ -35,7 +35,7 @@ macro_rules! with_program_logging {
|
||||
($process_instruction:expr) => {
|
||||
|first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext| {
|
||||
invoke_context: &mut InvokeContext| {
|
||||
process_instruction_with_program_logging(
|
||||
$process_instruction,
|
||||
first_instruction_account,
|
||||
@ -135,7 +135,7 @@ fn genesis_builtins() -> Vec<Builtin> {
|
||||
fn dummy_process_instruction(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &mut InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_program_runtime::{
|
||||
instruction_recorder::InstructionRecorder,
|
||||
invoke_context::{BuiltinProgram, ComputeMeter, Executors, InvokeContext, ThisInvokeContext},
|
||||
invoke_context::{BuiltinProgram, ComputeMeter, Executors, InvokeContext},
|
||||
log_collector::LogCollector,
|
||||
timings::ExecuteDetailsTimings,
|
||||
};
|
||||
@ -56,7 +56,7 @@ impl MessageProcessor {
|
||||
blockhash: Hash,
|
||||
lamports_per_signature: u64,
|
||||
) -> Result<(), TransactionError> {
|
||||
let mut invoke_context = ThisInvokeContext::new(
|
||||
let mut invoke_context = InvokeContext::new(
|
||||
rent,
|
||||
accounts,
|
||||
builtin_programs,
|
||||
@ -165,7 +165,7 @@ mod tests {
|
||||
fn mock_system_process_instruction(
|
||||
first_instruction_account: usize,
|
||||
data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
if let Ok(instruction) = bincode::deserialize(data) {
|
||||
@ -336,7 +336,7 @@ mod tests {
|
||||
fn mock_system_process_instruction(
|
||||
first_instruction_account: usize,
|
||||
data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
if let Ok(instruction) = bincode::deserialize(data) {
|
||||
@ -537,7 +537,7 @@ mod tests {
|
||||
fn mock_process_instruction(
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
_invoke_context: &mut InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
Err(InstructionError::Custom(0xbabb1e))
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ pub trait NonceKeyedAccount {
|
||||
fn advance_nonce_account(
|
||||
&self,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError>;
|
||||
fn withdraw_nonce_account(
|
||||
&self,
|
||||
@ -24,19 +24,19 @@ pub trait NonceKeyedAccount {
|
||||
to: &KeyedAccount,
|
||||
rent: &Rent,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError>;
|
||||
fn initialize_nonce_account(
|
||||
&self,
|
||||
nonce_authority: &Pubkey,
|
||||
rent: &Rent,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError>;
|
||||
fn authorize_nonce_account(
|
||||
&self,
|
||||
nonce_authority: &Pubkey,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError>;
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
|
||||
fn advance_nonce_account(
|
||||
&self,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
let merge_nonce_error_into_system_error = invoke_context
|
||||
.is_feature_active(&feature_set::merge_nonce_error_into_system_error::id());
|
||||
@ -108,7 +108,7 @@ impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
|
||||
to: &KeyedAccount,
|
||||
rent: &Rent,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
let merge_nonce_error_into_system_error = invoke_context
|
||||
.is_feature_active(&feature_set::merge_nonce_error_into_system_error::id());
|
||||
@ -194,7 +194,7 @@ impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
|
||||
&self,
|
||||
nonce_authority: &Pubkey,
|
||||
rent: &Rent,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
let merge_nonce_error_into_system_error = invoke_context
|
||||
.is_feature_active(&feature_set::merge_nonce_error_into_system_error::id());
|
||||
@ -245,7 +245,7 @@ impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
|
||||
&self,
|
||||
nonce_authority: &Pubkey,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
let merge_nonce_error_into_system_error = invoke_context
|
||||
.is_feature_active(&feature_set::merge_nonce_error_into_system_error::id());
|
||||
@ -294,7 +294,7 @@ impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use solana_program_runtime::invoke_context::ThisInvokeContext;
|
||||
use solana_program_runtime::invoke_context::InvokeContext;
|
||||
use solana_sdk::{
|
||||
account::ReadableAccount,
|
||||
account_utils::State as AccountUtilsState,
|
||||
@ -322,8 +322,8 @@ mod test {
|
||||
)
|
||||
}
|
||||
|
||||
fn create_invoke_context_with_blockhash<'a>(seed: usize) -> ThisInvokeContext<'a> {
|
||||
let mut invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
fn create_invoke_context_with_blockhash<'a>(seed: usize) -> InvokeContext<'a> {
|
||||
let mut invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let (blockhash, lamports_per_signature) = create_test_blockhash(seed);
|
||||
invoke_context.set_blockhash(blockhash);
|
||||
invoke_context.set_lamports_per_signature(lamports_per_signature);
|
||||
@ -1017,7 +1017,7 @@ mod test {
|
||||
let result = nonce_account.authorize_nonce_account(
|
||||
&Pubkey::default(),
|
||||
&signers,
|
||||
&ThisInvokeContext::new_mock(&[], &[]),
|
||||
&InvokeContext::new_mock(&[], &[]),
|
||||
);
|
||||
assert_eq!(result, Err(InstructionError::InvalidAccountData));
|
||||
})
|
||||
|
@ -35,7 +35,7 @@ impl Address {
|
||||
fn create(
|
||||
address: &Pubkey,
|
||||
with_seed: Option<(&Pubkey, &str, &Pubkey)>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<Self, InstructionError> {
|
||||
let base = if let Some((base, seed, owner)) = with_seed {
|
||||
let address_with_seed = Pubkey::create_with_seed(base, seed, owner)?;
|
||||
@ -66,7 +66,7 @@ fn allocate(
|
||||
address: &Address,
|
||||
space: u64,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
if !address.is_signer(signers) {
|
||||
ic_msg!(
|
||||
@ -108,7 +108,7 @@ fn assign(
|
||||
address: &Address,
|
||||
owner: &Pubkey,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
// no work to do, just return
|
||||
if account.owner() == owner {
|
||||
@ -141,7 +141,7 @@ fn allocate_and_assign(
|
||||
space: u64,
|
||||
owner: &Pubkey,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
allocate(to, to_address, space, signers, invoke_context)?;
|
||||
assign(to, to_address, owner, signers, invoke_context)
|
||||
@ -155,7 +155,7 @@ fn create_account(
|
||||
space: u64,
|
||||
owner: &Pubkey,
|
||||
signers: &HashSet<Pubkey>,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
// if it looks like the `to` account is already in use, bail
|
||||
{
|
||||
@ -178,7 +178,7 @@ fn transfer_verified(
|
||||
from: &KeyedAccount,
|
||||
to: &KeyedAccount,
|
||||
lamports: u64,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
if !from.data_is_empty()? {
|
||||
ic_msg!(invoke_context, "Transfer: `from` must not carry data");
|
||||
@ -203,7 +203,7 @@ fn transfer(
|
||||
from: &KeyedAccount,
|
||||
to: &KeyedAccount,
|
||||
lamports: u64,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
if !invoke_context.is_feature_active(&feature_set::system_transfer_zero_check::id())
|
||||
&& lamports == 0
|
||||
@ -230,7 +230,7 @@ fn transfer_with_seed(
|
||||
from_owner: &Pubkey,
|
||||
to: &KeyedAccount,
|
||||
lamports: u64,
|
||||
invoke_context: &dyn InvokeContext,
|
||||
invoke_context: &InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
if !invoke_context.is_feature_active(&feature_set::system_transfer_zero_check::id())
|
||||
&& lamports == 0
|
||||
@ -265,7 +265,7 @@ fn transfer_with_seed(
|
||||
pub fn process_instruction(
|
||||
first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
invoke_context: &mut InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
let instruction = limited_deserialize(instruction_data)?;
|
||||
@ -481,7 +481,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{bank::Bank, bank_client::BankClient};
|
||||
use bincode::serialize;
|
||||
use solana_program_runtime::invoke_context::{mock_process_instruction, ThisInvokeContext};
|
||||
use solana_program_runtime::invoke_context::{mock_process_instruction, InvokeContext};
|
||||
#[allow(deprecated)]
|
||||
use solana_sdk::{
|
||||
account::{self, Account, AccountSharedData},
|
||||
@ -638,7 +638,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_address_create_with_seed_mismatch() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let from = Pubkey::new_unique();
|
||||
let seed = "dull boy";
|
||||
let to = Pubkey::new_unique();
|
||||
@ -652,7 +652,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_account_with_seed_missing_sig() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_unique();
|
||||
let seed = "dull boy";
|
||||
@ -682,7 +682,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_with_zero_lamports() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
// create account with zero lamports transferred
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_unique();
|
||||
@ -716,7 +716,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_negative_lamports() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
// Attempt to create account with more lamports than remaining in from_account
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_unique();
|
||||
@ -740,7 +740,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_request_more_than_allowed_data_length() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let from_account = AccountSharedData::new_ref(100, 0, &system_program::id());
|
||||
let from = Pubkey::new_unique();
|
||||
let to_account = AccountSharedData::new_ref(0, 0, &system_program::id());
|
||||
@ -787,7 +787,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_already_in_use() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
// Attempt to create system account in account already owned by another program
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_unique();
|
||||
@ -855,7 +855,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_unsigned() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
// Attempt to create an account without signing the transfer
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_unique();
|
||||
@ -910,7 +910,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_sysvar_invalid_id_with_feature() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
// Attempt to create system account in account already owned by another program
|
||||
let from = Pubkey::new_unique();
|
||||
let from_account = AccountSharedData::new_ref(100, 0, &system_program::id());
|
||||
@ -944,12 +944,8 @@ mod tests {
|
||||
feature_set
|
||||
.inactive
|
||||
.insert(feature_set::rent_for_sysvars::id());
|
||||
let invoke_context = ThisInvokeContext::new_mock_with_sysvars_and_features(
|
||||
&[],
|
||||
&[],
|
||||
&[],
|
||||
Arc::new(feature_set),
|
||||
);
|
||||
let invoke_context =
|
||||
InvokeContext::new_mock_with_sysvars_and_features(&[], &[], &[], Arc::new(feature_set));
|
||||
// Attempt to create system account in account already owned by another program
|
||||
let from = Pubkey::new_unique();
|
||||
let from_account = AccountSharedData::new_ref(100, 0, &system_program::id());
|
||||
@ -975,7 +971,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_data_populated() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
// Attempt to create system account in account with populated data
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let from = Pubkey::new_unique();
|
||||
@ -1009,7 +1005,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_from_account_is_nonce_fail() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let nonce = Pubkey::new_unique();
|
||||
let nonce_account = AccountSharedData::new_ref_data(
|
||||
42,
|
||||
@ -1045,7 +1041,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_assign() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let new_owner = Pubkey::new(&[9; 32]);
|
||||
let pubkey = Pubkey::new_unique();
|
||||
let mut account = AccountSharedData::new(100, 0, &system_program::id());
|
||||
@ -1085,7 +1081,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_assign_to_sysvar_with_feature() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let new_owner = sysvar::id();
|
||||
let from = Pubkey::new_unique();
|
||||
let mut from_account = AccountSharedData::new(100, 0, &system_program::id());
|
||||
@ -1111,12 +1107,8 @@ mod tests {
|
||||
feature_set
|
||||
.inactive
|
||||
.insert(feature_set::rent_for_sysvars::id());
|
||||
let invoke_context = ThisInvokeContext::new_mock_with_sysvars_and_features(
|
||||
&[],
|
||||
&[],
|
||||
&[],
|
||||
Arc::new(feature_set),
|
||||
);
|
||||
let invoke_context =
|
||||
InvokeContext::new_mock_with_sysvars_and_features(&[], &[], &[], Arc::new(feature_set));
|
||||
let new_owner = sysvar::id();
|
||||
let from = Pubkey::new_unique();
|
||||
let mut from_account = AccountSharedData::new(100, 0, &system_program::id());
|
||||
@ -1154,7 +1146,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_transfer_lamports() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let from = Pubkey::new_unique();
|
||||
let from_account = AccountSharedData::new_ref(100, 0, &Pubkey::new(&[2; 32])); // account owner should not matter
|
||||
let to = Pubkey::new(&[3; 32]);
|
||||
@ -1192,7 +1184,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_transfer_with_seed() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let base = Pubkey::new_unique();
|
||||
let base_account = AccountSharedData::new_ref(100, 0, &Pubkey::new(&[2; 32])); // account owner should not matter
|
||||
let from_base_keyed_account = KeyedAccount::new(&base, true, &base_account);
|
||||
@ -1252,7 +1244,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_transfer_lamports_from_nonce_account_fail() {
|
||||
let invoke_context = ThisInvokeContext::new_mock(&[], &[]);
|
||||
let invoke_context = InvokeContext::new_mock(&[], &[]);
|
||||
let from = Pubkey::new_unique();
|
||||
let from_account = AccountSharedData::new_ref_data(
|
||||
100,
|
||||
@ -1582,7 +1574,7 @@ mod tests {
|
||||
&keyed_accounts,
|
||||
|first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext| {
|
||||
invoke_context: &mut InvokeContext| {
|
||||
invoke_context.set_blockhash(hash(&serialize(&0).unwrap()));
|
||||
super::process_instruction(
|
||||
first_instruction_account,
|
||||
@ -1998,7 +1990,7 @@ mod tests {
|
||||
&keyed_accounts,
|
||||
|first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext| {
|
||||
invoke_context: &mut InvokeContext| {
|
||||
invoke_context.set_blockhash(hash(&serialize(&0).unwrap()));
|
||||
super::process_instruction(
|
||||
first_instruction_account,
|
||||
|
Reference in New Issue
Block a user