Reformat imports to a consistent style for imports
rustfmt.toml configuration: imports_granularity = "One" group_imports = "One"
This commit is contained in:
@@ -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]
|
||||
|
Reference in New Issue
Block a user