Reformat imports to a consistent style for imports
rustfmt.toml configuration: imports_granularity = "One" group_imports = "One"
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
use crate::{
|
||||
clock::Epoch, program_error::ProgramError, program_memory::sol_memset, pubkey::Pubkey,
|
||||
};
|
||||
use std::{
|
||||
cell::{Ref, RefCell, RefMut},
|
||||
cmp, fmt,
|
||||
rc::Rc,
|
||||
use {
|
||||
crate::{
|
||||
clock::Epoch, program_error::ProgramError, program_memory::sol_memset, pubkey::Pubkey,
|
||||
},
|
||||
std::{
|
||||
cell::{Ref, RefCell, RefMut},
|
||||
cmp, fmt,
|
||||
rc::Rc,
|
||||
},
|
||||
};
|
||||
|
||||
/// Account information
|
||||
|
@ -1,8 +1,10 @@
|
||||
//! The `blake3` module provides functions for creating hashes.
|
||||
use crate::sanitize::Sanitize;
|
||||
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
|
||||
use std::{convert::TryFrom, fmt, mem, str::FromStr};
|
||||
use thiserror::Error;
|
||||
use {
|
||||
crate::sanitize::Sanitize,
|
||||
borsh::{BorshDeserialize, BorshSchema, BorshSerialize},
|
||||
std::{convert::TryFrom, fmt, mem, str::FromStr},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
/// Size of hash
|
||||
pub const HASH_BYTES: usize = 32;
|
||||
|
@ -8,13 +8,15 @@
|
||||
//! upgradeable programs which still have a functioning authority. For more
|
||||
//! information refer to `loader_upgradeable_instruction.rs`
|
||||
|
||||
use crate::{
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
|
||||
pubkey::Pubkey,
|
||||
system_instruction, sysvar,
|
||||
use {
|
||||
crate::{
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
|
||||
pubkey::Pubkey,
|
||||
system_instruction, sysvar,
|
||||
},
|
||||
bincode::serialized_size,
|
||||
};
|
||||
use bincode::serialized_size;
|
||||
|
||||
crate::declare_id!("BPFLoaderUpgradeab1e11111111111111111111111");
|
||||
|
||||
|
@ -13,8 +13,7 @@ pub trait DecodeError<E> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use num_derive::FromPrimitive;
|
||||
use {super::*, num_derive::FromPrimitive};
|
||||
|
||||
#[test]
|
||||
fn test_decode_custom_error_to_enum() {
|
||||
|
@ -2,17 +2,18 @@
|
||||
//! BPFLoader. For more information see './bpf_loader.rs'
|
||||
|
||||
extern crate alloc;
|
||||
use crate::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey};
|
||||
use alloc::vec::Vec;
|
||||
use std::{
|
||||
alloc::Layout,
|
||||
cell::RefCell,
|
||||
mem::size_of,
|
||||
ptr::null_mut,
|
||||
rc::Rc,
|
||||
// Hide Result from bindgen gets confused about generics in non-generic type declarations
|
||||
result::Result as ResultGeneric,
|
||||
slice::{from_raw_parts, from_raw_parts_mut},
|
||||
use {
|
||||
crate::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey},
|
||||
alloc::vec::Vec,
|
||||
std::{
|
||||
alloc::Layout,
|
||||
cell::RefCell,
|
||||
mem::size_of,
|
||||
ptr::null_mut,
|
||||
rc::Rc,
|
||||
result::Result as ResultGeneric,
|
||||
slice::{from_raw_parts, from_raw_parts_mut},
|
||||
},
|
||||
};
|
||||
|
||||
pub type ProgramResult = ResultGeneric<(), ProgramError>;
|
||||
@ -354,8 +355,7 @@ pub unsafe fn deserialize<'a>(input: *mut u8) -> (&'a Pubkey, Vec<AccountInfo<'a
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use std::alloc::GlobalAlloc;
|
||||
use {super::*, std::alloc::GlobalAlloc};
|
||||
|
||||
#[test]
|
||||
fn test_bump_allocator() {
|
||||
|
@ -4,15 +4,16 @@
|
||||
//! './bpf_loader_deprecated.rs'
|
||||
|
||||
extern crate alloc;
|
||||
use crate::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey};
|
||||
use alloc::vec::Vec;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
mem::size_of,
|
||||
rc::Rc,
|
||||
// Hide Result from bindgen gets confused about generics in non-generic type declarations
|
||||
result::Result as ResultGeneric,
|
||||
slice::{from_raw_parts, from_raw_parts_mut},
|
||||
use {
|
||||
crate::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey},
|
||||
alloc::vec::Vec,
|
||||
std::{
|
||||
cell::RefCell,
|
||||
mem::size_of,
|
||||
rc::Rc,
|
||||
result::Result as ResultGeneric,
|
||||
slice::{from_raw_parts, from_raw_parts_mut},
|
||||
},
|
||||
};
|
||||
|
||||
pub type ProgramResult = ResultGeneric<(), ProgramError>;
|
||||
|
@ -62,8 +62,7 @@ pub fn activate_with_lamports(
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use solana_program::clock::Slot;
|
||||
use {super::*, solana_program::clock::Slot};
|
||||
|
||||
#[test]
|
||||
fn feature_sizeof() {
|
||||
|
@ -1,9 +1,8 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
use crate::clock::DEFAULT_MS_PER_SLOT;
|
||||
use crate::ed25519_program;
|
||||
use crate::message::Message;
|
||||
use crate::secp256k1_program;
|
||||
use log::*;
|
||||
use {
|
||||
crate::{clock::DEFAULT_MS_PER_SLOT, ed25519_program, message::Message, secp256k1_program},
|
||||
log::*,
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Clone, Debug, AbiExample)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@ -176,8 +175,10 @@ impl FeeRateGovernor {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{pubkey::Pubkey, system_instruction};
|
||||
use {
|
||||
super::*,
|
||||
crate::{pubkey::Pubkey, system_instruction},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_fee_rate_governor_burn() {
|
||||
|
@ -1,10 +1,12 @@
|
||||
//! The `hash` module provides functions for creating SHA-256 hashes.
|
||||
|
||||
use crate::sanitize::Sanitize;
|
||||
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{convert::TryFrom, fmt, mem, str::FromStr};
|
||||
use thiserror::Error;
|
||||
use {
|
||||
crate::sanitize::Sanitize,
|
||||
borsh::{BorshDeserialize, BorshSchema, BorshSerialize},
|
||||
sha2::{Digest, Sha256},
|
||||
std::{convert::TryFrom, fmt, mem, str::FromStr},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub const HASH_BYTES: usize = 32;
|
||||
/// Maximum string length of a base58 encoded hash
|
||||
|
@ -1,12 +1,13 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
//! Defines a composable Instruction type and a memory-efficient CompiledInstruction.
|
||||
|
||||
use crate::sanitize::Sanitize;
|
||||
use crate::{pubkey::Pubkey, short_vec};
|
||||
use bincode::serialize;
|
||||
use borsh::BorshSerialize;
|
||||
use serde::Serialize;
|
||||
use thiserror::Error;
|
||||
use {
|
||||
crate::{pubkey::Pubkey, sanitize::Sanitize, short_vec},
|
||||
bincode::serialize,
|
||||
borsh::BorshSerialize,
|
||||
serde::Serialize,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
/// Reasons the runtime might have rejected an instruction.
|
||||
///
|
||||
|
@ -1,8 +1,10 @@
|
||||
use crate::sanitize::Sanitize;
|
||||
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
|
||||
use sha3::{Digest, Keccak256};
|
||||
use std::{convert::TryFrom, fmt, mem, str::FromStr};
|
||||
use thiserror::Error;
|
||||
use {
|
||||
crate::sanitize::Sanitize,
|
||||
borsh::{BorshDeserialize, BorshSchema, BorshSerialize},
|
||||
sha3::{Digest, Keccak256},
|
||||
std::{convert::TryFrom, fmt, mem, str::FromStr},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub const HASH_BYTES: usize = 32;
|
||||
/// Maximum string length of a base58 encoded hash
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::instruction::InstructionError;
|
||||
use thiserror::Error;
|
||||
use {crate::instruction::InstructionError, thiserror::Error};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum LamportsError {
|
||||
|
@ -1,21 +1,23 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
//! A library for generating a message from a sequence of instructions
|
||||
|
||||
use crate::sanitize::{Sanitize, SanitizeError};
|
||||
use crate::serialize_utils::{
|
||||
append_slice, append_u16, append_u8, read_pubkey, read_slice, read_u16, read_u8,
|
||||
use {
|
||||
crate::{
|
||||
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
|
||||
hash::Hash,
|
||||
instruction::{AccountMeta, CompiledInstruction, Instruction},
|
||||
message::MessageHeader,
|
||||
pubkey::Pubkey,
|
||||
sanitize::{Sanitize, SanitizeError},
|
||||
serialize_utils::{
|
||||
append_slice, append_u16, append_u8, read_pubkey, read_slice, read_u16, read_u8,
|
||||
},
|
||||
short_vec, system_instruction, system_program, sysvar,
|
||||
},
|
||||
itertools::Itertools,
|
||||
lazy_static::lazy_static,
|
||||
std::{convert::TryFrom, str::FromStr},
|
||||
};
|
||||
use crate::{
|
||||
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
|
||||
hash::Hash,
|
||||
instruction::{AccountMeta, CompiledInstruction, Instruction},
|
||||
message::MessageHeader,
|
||||
pubkey::Pubkey,
|
||||
short_vec, system_instruction, system_program, sysvar,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use lazy_static::lazy_static;
|
||||
use std::{convert::TryFrom, str::FromStr};
|
||||
|
||||
lazy_static! {
|
||||
// Copied keys over since direct references create cyclical dependency.
|
||||
@ -526,9 +528,11 @@ impl Message {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(deprecated)]
|
||||
use super::*;
|
||||
use crate::{hash, instruction::AccountMeta, message::MESSAGE_HEADER_LENGTH};
|
||||
use std::collections::HashSet;
|
||||
use {
|
||||
super::*,
|
||||
crate::{hash, instruction::AccountMeta, message::MESSAGE_HEADER_LENGTH},
|
||||
std::collections::HashSet,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_message_unique_program_ids() {
|
||||
|
@ -114,7 +114,8 @@ impl MappedMessage {
|
||||
/// Returns true if the account at the specified index is called as a program by an instruction
|
||||
pub fn is_key_called_as_program(&self, key_index: usize) -> bool {
|
||||
if let Ok(key_index) = u8::try_from(key_index) {
|
||||
self.message.instructions
|
||||
self.message
|
||||
.instructions
|
||||
.iter()
|
||||
.any(|ix| ix.program_id_index == key_index)
|
||||
} else {
|
||||
@ -131,9 +132,11 @@ impl MappedMessage {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{instruction::CompiledInstruction, message::MessageHeader, system_program, sysvar};
|
||||
use itertools::Itertools;
|
||||
use {
|
||||
super::*,
|
||||
crate::{instruction::CompiledInstruction, message::MessageHeader, system_program, sysvar},
|
||||
itertools::Itertools,
|
||||
};
|
||||
|
||||
fn create_test_mapped_message() -> (MappedMessage, [Pubkey; 6]) {
|
||||
let key0 = Pubkey::new_unique();
|
||||
@ -279,13 +282,11 @@ mod tests {
|
||||
num_readonly_unsigned_accounts: 0,
|
||||
},
|
||||
account_keys: vec![key0],
|
||||
instructions: vec![
|
||||
CompiledInstruction {
|
||||
program_id_index: 2,
|
||||
accounts: vec![1],
|
||||
data: vec![],
|
||||
}
|
||||
],
|
||||
instructions: vec![CompiledInstruction {
|
||||
program_id_index: 2,
|
||||
accounts: vec![1],
|
||||
data: vec![],
|
||||
}],
|
||||
..v0::Message::default()
|
||||
},
|
||||
mapped_addresses: MappedAddresses {
|
||||
|
@ -10,13 +10,10 @@ mod non_bpf_modules {
|
||||
pub mod v0;
|
||||
mod versions;
|
||||
|
||||
pub use mapped::*;
|
||||
pub use sanitized::*;
|
||||
pub use versions::*;
|
||||
pub use {mapped::*, sanitized::*, versions::*};
|
||||
}
|
||||
|
||||
pub use legacy::Message;
|
||||
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
pub use non_bpf_modules::*;
|
||||
|
||||
|
@ -300,10 +300,12 @@ impl SanitizedMessage {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
message::v0,
|
||||
use {
|
||||
super::*,
|
||||
crate::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
message::v0,
|
||||
},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
@ -127,8 +127,7 @@ impl Message {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::message::VersionedMessage;
|
||||
use {super::*, crate::message::VersionedMessage};
|
||||
|
||||
fn simple_message() -> Message {
|
||||
Message {
|
||||
|
@ -10,7 +10,7 @@ use {
|
||||
serde::{
|
||||
de::{self, Deserializer, SeqAccess, Visitor},
|
||||
ser::{SerializeTuple, Serializer},
|
||||
{Deserialize, Serialize},
|
||||
Deserialize, Serialize,
|
||||
},
|
||||
std::fmt,
|
||||
};
|
||||
@ -243,10 +243,12 @@ impl<'de> Deserialize<'de> for VersionedMessage {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
message::v0::AddressMapIndexes,
|
||||
use {
|
||||
super::*,
|
||||
crate::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
message::v0::AddressMapIndexes,
|
||||
},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
@ -1,6 +1,8 @@
|
||||
use super::Versions;
|
||||
use crate::{fee_calculator::FeeCalculator, hash::Hash, pubkey::Pubkey};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use {
|
||||
super::Versions,
|
||||
crate::{fee_calculator::FeeCalculator, hash::Hash, pubkey::Pubkey},
|
||||
serde_derive::{Deserialize, Serialize},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)]
|
||||
pub struct Data {
|
||||
|
@ -1,6 +1,5 @@
|
||||
mod current;
|
||||
pub use current::{Data, State};
|
||||
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
||||
|
@ -1,9 +1,11 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
use crate::{decode_error::DecodeError, instruction::InstructionError, msg, pubkey::PubkeyError};
|
||||
use borsh::maybestd::io::Error as BorshIoError;
|
||||
use num_traits::{FromPrimitive, ToPrimitive};
|
||||
use std::convert::TryFrom;
|
||||
use thiserror::Error;
|
||||
use {
|
||||
crate::{decode_error::DecodeError, instruction::InstructionError, msg, pubkey::PubkeyError},
|
||||
borsh::maybestd::io::Error as BorshIoError,
|
||||
num_traits::{FromPrimitive, ToPrimitive},
|
||||
std::convert::TryFrom,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
/// Reasons the program may fail
|
||||
#[derive(Clone, Debug, Deserialize, Eq, Error, PartialEq, Serialize)]
|
||||
|
@ -2,12 +2,14 @@
|
||||
|
||||
#![cfg(not(target_arch = "bpf"))]
|
||||
|
||||
use crate::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, instruction::Instruction,
|
||||
program_error::UNSUPPORTED_SYSVAR, pubkey::Pubkey,
|
||||
use {
|
||||
crate::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, instruction::Instruction,
|
||||
program_error::UNSUPPORTED_SYSVAR, pubkey::Pubkey,
|
||||
},
|
||||
itertools::Itertools,
|
||||
std::sync::{Arc, RwLock},
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref SYSCALL_STUBS: Arc<RwLock<Box<dyn SyscallStubs>>> = Arc::new(RwLock::new(Box::new(DefaultSyscallStubs {})));
|
||||
|
@ -393,8 +393,7 @@ impl fmt::Display for Pubkey {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::str::from_utf8;
|
||||
use {super::*, std::str::from_utf8};
|
||||
|
||||
#[test]
|
||||
fn test_new_unique() {
|
||||
|
@ -1,6 +1,8 @@
|
||||
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
|
||||
use core::convert::TryFrom;
|
||||
use thiserror::Error;
|
||||
use {
|
||||
borsh::{BorshDeserialize, BorshSchema, BorshSerialize},
|
||||
core::convert::TryFrom,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Error)]
|
||||
pub enum Secp256k1RecoverError {
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
use crate::pubkey::Pubkey;
|
||||
use crate::sanitize::SanitizeError;
|
||||
use crate::{pubkey::Pubkey, sanitize::SanitizeError};
|
||||
|
||||
pub fn append_u16(buf: &mut Vec<u8>, data: u16) {
|
||||
let start = buf.len();
|
||||
|
@ -1,10 +1,12 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
use serde::{
|
||||
de::{self, Deserializer, SeqAccess, Visitor},
|
||||
ser::{self, SerializeTuple, Serializer},
|
||||
{Deserialize, Serialize},
|
||||
use {
|
||||
serde::{
|
||||
de::{self, Deserializer, SeqAccess, Visitor},
|
||||
ser::{self, SerializeTuple, Serializer},
|
||||
Deserialize, Serialize,
|
||||
},
|
||||
std::{convert::TryFrom, fmt, marker::PhantomData},
|
||||
};
|
||||
use std::{convert::TryFrom, fmt, marker::PhantomData};
|
||||
|
||||
/// Same as u16, but serialized with 1 to 3 bytes. If the value is above
|
||||
/// 0x7f, the top bit is set and the remaining value is stored in the next
|
||||
@ -265,9 +267,11 @@ pub fn decode_shortu16_len(bytes: &[u8]) -> Result<(usize, usize), ()> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use assert_matches::assert_matches;
|
||||
use bincode::{deserialize, serialize};
|
||||
use {
|
||||
super::*,
|
||||
assert_matches::assert_matches,
|
||||
bincode::{deserialize, serialize},
|
||||
};
|
||||
|
||||
/// Return the serialized length.
|
||||
fn encode_len(len: u16) -> Vec<u8> {
|
||||
|
@ -2,8 +2,10 @@
|
||||
//!
|
||||
//! this account carries the Bank's most recent bank hashes for some N parents
|
||||
//!
|
||||
use crate::hash::Hash;
|
||||
use std::{iter::FromIterator, ops::Deref};
|
||||
use {
|
||||
crate::hash::Hash,
|
||||
std::{iter::FromIterator, ops::Deref},
|
||||
};
|
||||
|
||||
pub const MAX_ENTRIES: usize = 512; // about 2.5 minutes to get your vote in
|
||||
|
||||
@ -54,8 +56,7 @@ impl Deref for SlotHashes {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::hash::hash;
|
||||
use {super::*, crate::hash::hash};
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
|
@ -3,8 +3,7 @@
|
||||
//! slot history
|
||||
//!
|
||||
pub use crate::clock::Slot;
|
||||
use bv::BitVec;
|
||||
use bv::BitsMut;
|
||||
use bv::{BitVec, BitsMut};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Serialize, Deserialize, PartialEq)]
|
||||
@ -86,8 +85,7 @@ impl SlotHistory {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use log::*;
|
||||
use {super::*, log::*};
|
||||
|
||||
#[test]
|
||||
fn slot_history_test1() {
|
||||
|
@ -1,14 +1,14 @@
|
||||
use {
|
||||
crate::stake::{
|
||||
config,
|
||||
program::id,
|
||||
state::{Authorized, Lockup, StakeAuthorize, StakeState},
|
||||
},
|
||||
crate::{
|
||||
clock::{Epoch, UnixTimestamp},
|
||||
decode_error::DecodeError,
|
||||
instruction::{AccountMeta, Instruction},
|
||||
pubkey::Pubkey,
|
||||
stake::{
|
||||
config,
|
||||
program::id,
|
||||
state::{Authorized, Lockup, StakeAuthorize, StakeState},
|
||||
},
|
||||
system_instruction, sysvar,
|
||||
},
|
||||
log::*,
|
||||
@ -680,8 +680,7 @@ pub fn set_lockup_checked(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::instruction::InstructionError;
|
||||
use {super::*, crate::instruction::InstructionError};
|
||||
|
||||
#[test]
|
||||
fn test_custom_error_decode() {
|
||||
|
@ -3,7 +3,6 @@
|
||||
//! this account carries history about stake activations and de-activations
|
||||
//!
|
||||
pub use crate::clock::Epoch;
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
pub const MAX_ENTRIES: usize = 512; // it should never take as many as 512 epochs to warm up or cool down
|
||||
|
@ -1,15 +1,17 @@
|
||||
#[allow(deprecated)]
|
||||
use crate::sysvar::recent_blockhashes;
|
||||
use crate::{
|
||||
decode_error::DecodeError,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
nonce,
|
||||
pubkey::Pubkey,
|
||||
system_program,
|
||||
sysvar::rent,
|
||||
use {
|
||||
crate::{
|
||||
decode_error::DecodeError,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
nonce,
|
||||
pubkey::Pubkey,
|
||||
system_program,
|
||||
sysvar::rent,
|
||||
},
|
||||
num_derive::{FromPrimitive, ToPrimitive},
|
||||
thiserror::Error,
|
||||
};
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug, Serialize, Clone, PartialEq, FromPrimitive, ToPrimitive)]
|
||||
pub enum SystemError {
|
||||
@ -573,9 +575,11 @@ pub fn authorize_nonce_account(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::instruction::{Instruction, InstructionError};
|
||||
use num_traits::ToPrimitive;
|
||||
use {
|
||||
super::*,
|
||||
crate::instruction::{Instruction, InstructionError},
|
||||
num_traits::ToPrimitive,
|
||||
};
|
||||
|
||||
fn get_keys(instruction: &Instruction) -> Vec<Pubkey> {
|
||||
instruction.accounts.iter().map(|x| x.pubkey).collect()
|
||||
|
@ -1,7 +1,6 @@
|
||||
//! This account contains the clock slot, epoch, and leader_schedule_epoch
|
||||
//!
|
||||
pub use crate::clock::Clock;
|
||||
|
||||
use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar};
|
||||
|
||||
crate::declare_sysvar_id!("SysvarC1ock11111111111111111111111111111111", Clock);
|
||||
|
@ -1,7 +1,6 @@
|
||||
//! This account contains the current cluster rent
|
||||
//!
|
||||
pub use crate::epoch_schedule::EpochSchedule;
|
||||
|
||||
use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar};
|
||||
|
||||
crate::declare_sysvar_id!("SysvarEpochSchedu1e111111111111111111111111", EpochSchedule);
|
||||
|
@ -118,9 +118,11 @@ pub fn get_instruction_relative(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{instruction::AccountMeta, message::Message, pubkey::Pubkey};
|
||||
use std::convert::TryFrom;
|
||||
use {
|
||||
super::*,
|
||||
crate::{instruction::AccountMeta, message::Message, pubkey::Pubkey},
|
||||
std::convert::TryFrom,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_load_store_instruction() {
|
||||
|
@ -1,7 +1,9 @@
|
||||
//! named accounts for synthesized data accounts for bank state, etc.
|
||||
//!
|
||||
use crate::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey};
|
||||
use lazy_static::lazy_static;
|
||||
use {
|
||||
crate::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey},
|
||||
lazy_static::lazy_static,
|
||||
};
|
||||
|
||||
pub mod clock;
|
||||
pub mod epoch_schedule;
|
||||
@ -140,9 +142,11 @@ macro_rules! impl_sysvar_get {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{clock::Epoch, program_error::ProgramError, pubkey::Pubkey};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use {
|
||||
super::*,
|
||||
crate::{clock::Epoch, program_error::ProgramError, pubkey::Pubkey},
|
||||
std::{cell::RefCell, rc::Rc},
|
||||
};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Serialize, Deserialize, Debug, Default, PartialEq)]
|
||||
|
@ -1,12 +1,14 @@
|
||||
#![allow(deprecated)]
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
use crate::{
|
||||
declare_deprecated_sysvar_id,
|
||||
fee_calculator::FeeCalculator,
|
||||
hash::{hash, Hash},
|
||||
sysvar::Sysvar,
|
||||
use {
|
||||
crate::{
|
||||
declare_deprecated_sysvar_id,
|
||||
fee_calculator::FeeCalculator,
|
||||
hash::{hash, Hash},
|
||||
sysvar::Sysvar,
|
||||
},
|
||||
std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref},
|
||||
};
|
||||
use std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref};
|
||||
|
||||
#[deprecated(
|
||||
since = "1.9.0",
|
||||
@ -161,8 +163,7 @@ pub fn create_test_recent_blockhashes(start: usize) -> RecentBlockhashes {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::clock::MAX_PROCESSING_AGE;
|
||||
use {super::*, crate::clock::MAX_PROCESSING_AGE};
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::assertions_on_constants)]
|
||||
|
@ -1,7 +1,6 @@
|
||||
//! This account contains the current cluster rent
|
||||
//!
|
||||
pub use crate::rent::Rent;
|
||||
|
||||
use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar};
|
||||
|
||||
crate::declare_sysvar_id!("SysvarRent111111111111111111111111111111111", Rent);
|
||||
|
@ -3,7 +3,6 @@
|
||||
//! this account carries the Bank's most recent bank hashes for some N parents
|
||||
//!
|
||||
pub use crate::slot_hashes::SlotHashes;
|
||||
|
||||
use crate::{account_info::AccountInfo, program_error::ProgramError, sysvar::Sysvar};
|
||||
|
||||
crate::declare_sysvar_id!("SysvarS1otHashes111111111111111111111111111", SlotHashes);
|
||||
@ -22,8 +21,10 @@ impl Sysvar for SlotHashes {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{clock::Slot, hash::Hash, slot_hashes::MAX_ENTRIES};
|
||||
use {
|
||||
super::*,
|
||||
crate::{clock::Slot, hash::Hash, slot_hashes::MAX_ENTRIES},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_size_of() {
|
||||
|
@ -3,12 +3,11 @@
|
||||
//! this account carries a bitvector of slots present over the past
|
||||
//! epoch
|
||||
//!
|
||||
use crate::sysvar::Sysvar;
|
||||
pub use crate::{
|
||||
account_info::AccountInfo, program_error::ProgramError, slot_history::SlotHistory,
|
||||
};
|
||||
|
||||
use crate::sysvar::Sysvar;
|
||||
|
||||
crate::declare_sysvar_id!("SysvarS1otHistory11111111111111111111111111", SlotHistory);
|
||||
|
||||
impl Sysvar for SlotHistory {
|
||||
|
@ -3,7 +3,6 @@
|
||||
//! this account carries history about stake activations and de-activations
|
||||
//!
|
||||
pub use crate::stake_history::StakeHistory;
|
||||
|
||||
use crate::sysvar::Sysvar;
|
||||
|
||||
crate::declare_sysvar_id!("SysvarStakeHistory1111111111111111111111111", StakeHistory);
|
||||
@ -18,8 +17,7 @@ impl Sysvar for StakeHistory {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::stake_history::*;
|
||||
use {super::*, crate::stake_history::*};
|
||||
|
||||
#[test]
|
||||
fn test_size_of() {
|
||||
|
Reference in New Issue
Block a user