Moves NonceKeyedAccount from the SDK to the Runtime. (#20954)

This commit is contained in:
Alexander Meißner 2021-10-25 22:58:18 +02:00 committed by GitHub
parent 8efba88dde
commit cf0fd5b2ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 23 deletions

View File

@ -38,6 +38,7 @@ pub mod log_collector;
pub mod message_processor; pub mod message_processor;
pub mod neon_evm_program; pub mod neon_evm_program;
pub mod non_circulating_supply; pub mod non_circulating_supply;
mod nonce_keyed_account;
mod pubkey_bins; mod pubkey_bins;
mod read_only_accounts_cache; mod read_only_accounts_cache;
pub mod rent_collector; pub mod rent_collector;

View File

@ -1,16 +1,11 @@
#![cfg(feature = "full")] use solana_sdk::{
use crate::{
account::{ReadableAccount, WritableAccount}, account::{ReadableAccount, WritableAccount},
account_utils::State as AccountUtilsState, account_utils::State as AccountUtilsState,
feature_set, ic_msg, feature_set, ic_msg,
keyed_account::KeyedAccount,
nonce_account::create_account,
process_instruction::InvokeContext,
};
use solana_program::{
instruction::{checked_add, InstructionError}, instruction::{checked_add, InstructionError},
keyed_account::KeyedAccount,
nonce::{self, state::Versions, State}, nonce::{self, state::Versions, State},
process_instruction::InvokeContext,
pubkey::Pubkey, pubkey::Pubkey,
system_instruction::{nonce_to_instruction_error, NonceError}, system_instruction::{nonce_to_instruction_error, NonceError},
sysvar::rent::Rent, sysvar::rent::Rent,
@ -256,30 +251,30 @@ impl<'a> NonceKeyedAccount for KeyedAccount<'a> {
} }
} }
/// Convenience function for working with keyed accounts in tests
pub fn with_test_keyed_account<F>(lamports: u64, signer: bool, f: F)
where
F: Fn(&KeyedAccount),
{
let pubkey = Pubkey::new_unique();
let account = create_account(lamports);
let keyed_account = KeyedAccount::new(&pubkey, signer, &account);
f(&keyed_account)
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::{ use solana_sdk::{
account::ReadableAccount, account::ReadableAccount,
account_utils::State as AccountUtilsState, account_utils::State as AccountUtilsState,
hash::{hash, Hash},
keyed_account::KeyedAccount, keyed_account::KeyedAccount,
nonce::{self, State}, nonce::{self, State},
nonce_account::create_account,
nonce_account::verify_nonce_account, nonce_account::verify_nonce_account,
process_instruction::MockInvokeContext, process_instruction::MockInvokeContext,
system_instruction::SystemError, system_instruction::SystemError,
}; };
use solana_program::hash::{hash, Hash};
fn with_test_keyed_account<F>(lamports: u64, signer: bool, f: F)
where
F: Fn(&KeyedAccount),
{
let pubkey = Pubkey::new_unique();
let account = create_account(lamports);
let keyed_account = KeyedAccount::new(&pubkey, signer, &account);
f(&keyed_account)
}
fn create_test_blockhash(seed: usize) -> (Hash, u64) { fn create_test_blockhash(seed: usize) -> (Hash, u64) {
( (

View File

@ -1,3 +1,4 @@
use crate::nonce_keyed_account::NonceKeyedAccount;
use log::*; use log::*;
use solana_sdk::{ use solana_sdk::{
account::{AccountSharedData, ReadableAccount, WritableAccount}, account::{AccountSharedData, ReadableAccount, WritableAccount},
@ -6,7 +7,6 @@ use solana_sdk::{
instruction::InstructionError, instruction::InstructionError,
keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount}, keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount},
nonce, nonce,
nonce_keyed_account::NonceKeyedAccount,
process_instruction::InvokeContext, process_instruction::InvokeContext,
program_utils::limited_deserialize, program_utils::limited_deserialize,
pubkey::Pubkey, pubkey::Pubkey,

View File

@ -33,7 +33,6 @@ pub mod keyed_account;
pub mod log; pub mod log;
pub mod native_loader; pub mod native_loader;
pub mod nonce_account; pub mod nonce_account;
pub mod nonce_keyed_account;
pub mod packet; pub mod packet;
pub mod poh_config; pub mod poh_config;
pub mod precompiles; pub mod precompiles;