Add everything feature
This commit is contained in:
@ -79,7 +79,9 @@ _ scripts/cargo-for-all-lock-files.sh +"$rust_stable" audit "${cargo_audit_ignor
|
|||||||
cd "$project"
|
cd "$project"
|
||||||
_ cargo +"$rust_stable" fmt -- --check
|
_ cargo +"$rust_stable" fmt -- --check
|
||||||
_ cargo +"$rust_nightly" test
|
_ cargo +"$rust_nightly" test
|
||||||
_ cargo +"$rust_nightly" clippy -- --deny=warnings --allow=clippy::missing_safety_doc
|
_ cargo +"$rust_nightly" clippy -- --deny=warnings \
|
||||||
|
--allow=clippy::missing_safety_doc \
|
||||||
|
--allow=clippy::stable_sort_primitive
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,14 @@ edition = "2018"
|
|||||||
[features]
|
[features]
|
||||||
# On-chain program specific dependencies
|
# On-chain program specific dependencies
|
||||||
program = []
|
program = []
|
||||||
# Dependencies that are not compatible or needed for on-chain programs
|
# Everything includes functionality that is not compatible or needed for on-chain programs
|
||||||
default = [
|
default = [
|
||||||
|
"everything"
|
||||||
|
]
|
||||||
|
everything = [
|
||||||
"assert_matches",
|
"assert_matches",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"chrono",
|
"chrono",
|
||||||
"curve25519-dalek",
|
|
||||||
"generic-array",
|
"generic-array",
|
||||||
"memmap",
|
"memmap",
|
||||||
"rand",
|
"rand",
|
||||||
@ -66,6 +68,9 @@ libsecp256k1 = { version = "0.3.5", optional = true }
|
|||||||
sha3 = { version = "0.9.1", optional = true }
|
sha3 = { version = "0.9.1", optional = true }
|
||||||
digest = { version = "0.9.0", optional = true }
|
digest = { version = "0.9.0", optional = true }
|
||||||
|
|
||||||
|
[target.'cfg(not(target_arch = "bpf"))'.dependencies]
|
||||||
|
curve25519-dalek = { version = "2.1.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
curve25519-dalek = "2.1.0"
|
curve25519-dalek = "2.1.0"
|
||||||
tiny-bip39 = "0.7.0"
|
tiny-bip39 = "0.7.0"
|
||||||
|
@ -213,9 +213,9 @@ atomic_example_impls! { AtomicI64 }
|
|||||||
atomic_example_impls! { AtomicIsize }
|
atomic_example_impls! { AtomicIsize }
|
||||||
atomic_example_impls! { AtomicBool }
|
atomic_example_impls! { AtomicBool }
|
||||||
|
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
use generic_array::{ArrayLength, GenericArray};
|
use generic_array::{ArrayLength, GenericArray};
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
impl<T: Default, U: ArrayLength<T>> AbiExample for GenericArray<T, U> {
|
impl<T: Default, U: ArrayLength<T>> AbiExample for GenericArray<T, U> {
|
||||||
fn example() -> Self {
|
fn example() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
@ -413,14 +413,14 @@ impl<T: std::cmp::Ord + AbiExample> AbiExample for BTreeSet<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
impl AbiExample for memmap::MmapMut {
|
impl AbiExample for memmap::MmapMut {
|
||||||
fn example() -> Self {
|
fn example() -> Self {
|
||||||
memmap::MmapMut::map_anon(1).expect("failed to map the data file")
|
memmap::MmapMut::map_anon(1).expect("failed to map the data file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
impl AbiExample for std::path::PathBuf {
|
impl AbiExample for std::path::PathBuf {
|
||||||
fn example() -> Self {
|
fn example() -> Self {
|
||||||
std::path::PathBuf::from(String::example())
|
std::path::PathBuf::from(String::example())
|
||||||
|
@ -90,7 +90,7 @@ impl Hash {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// New random hash value for tests and benchmarks.
|
/// New random hash value for tests and benchmarks.
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub fn new_rand<R: ?Sized>(rng: &mut R) -> Self
|
pub fn new_rand<R: ?Sized>(rng: &mut R) -> Self
|
||||||
where
|
where
|
||||||
R: rand::Rng,
|
R: rand::Rng,
|
||||||
|
@ -104,25 +104,25 @@ macro_rules! program_stubs {
|
|||||||
pub mod serialize_utils;
|
pub mod serialize_utils;
|
||||||
|
|
||||||
// Modules not usable by on-chain programs
|
// Modules not usable by on-chain programs
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod client;
|
pub mod client;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod genesis_config;
|
pub mod genesis_config;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod hard_forks;
|
pub mod hard_forks;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod secp256k1;
|
pub mod secp256k1;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod shred_version;
|
pub mod shred_version;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod signature;
|
pub mod signature;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod signers;
|
pub mod signers;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod system_transaction;
|
pub mod system_transaction;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub mod transport;
|
pub mod transport;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -170,7 +170,7 @@ pub fn create_account(lamports: u64) -> RefCell<account::Account> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience function for working with keyed accounts in tests
|
/// Convenience function for working with keyed accounts in tests
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub fn with_test_keyed_account<F>(lamports: u64, signer: bool, f: F)
|
pub fn with_test_keyed_account<F>(lamports: u64, signer: bool, f: F)
|
||||||
where
|
where
|
||||||
F: Fn(&KeyedAccount),
|
F: Fn(&KeyedAccount),
|
||||||
|
@ -5,7 +5,7 @@ use thiserror::Error;
|
|||||||
|
|
||||||
#[cfg(feature = "program")]
|
#[cfg(feature = "program")]
|
||||||
use crate::info;
|
use crate::info;
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(all(feature = "everything", not(feature = "program")))]
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
/// Reasons the program may fail
|
/// Reasons the program may fail
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
#[cfg(all(feature = "program", target_arch = "bpf"))]
|
|
||||||
use crate::entrypoint::SUCCESS;
|
|
||||||
#[cfg(not(all(feature = "program", target_arch = "bpf")))]
|
|
||||||
use crate::hash::Hasher;
|
|
||||||
use crate::{decode_error::DecodeError, hash::hashv};
|
use crate::{decode_error::DecodeError, hash::hashv};
|
||||||
use num_derive::{FromPrimitive, ToPrimitive};
|
use num_derive::{FromPrimitive, ToPrimitive};
|
||||||
#[cfg(not(feature = "program"))]
|
|
||||||
use std::error;
|
|
||||||
use std::{convert::TryFrom, fmt, mem, str::FromStr};
|
use std::{convert::TryFrom, fmt, mem, str::FromStr};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
@ -130,7 +124,7 @@ impl Pubkey {
|
|||||||
// not supported
|
// not supported
|
||||||
#[cfg(not(all(feature = "program", target_arch = "bpf")))]
|
#[cfg(not(all(feature = "program", target_arch = "bpf")))]
|
||||||
{
|
{
|
||||||
let mut hasher = Hasher::default();
|
let mut hasher = crate::hash::Hasher::default();
|
||||||
for seed in seeds.iter() {
|
for seed in seeds.iter() {
|
||||||
if seed.len() > MAX_SEED_LEN {
|
if seed.len() > MAX_SEED_LEN {
|
||||||
return Err(PubkeyError::MaxSeedLengthExceeded);
|
return Err(PubkeyError::MaxSeedLengthExceeded);
|
||||||
@ -170,7 +164,7 @@ impl Pubkey {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
match result {
|
match result {
|
||||||
SUCCESS => Ok(Pubkey::new(&bytes)),
|
crate::entrypoint::SUCCESS => Ok(Pubkey::new(&bytes)),
|
||||||
_ => Err(result.into()),
|
_ => Err(result.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +188,7 @@ impl Pubkey {
|
|||||||
panic!("Unable to find a viable program address bump seed");
|
panic!("Unable to find a viable program address bump seed");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub fn new_rand() -> Self {
|
pub fn new_rand() -> Self {
|
||||||
Self::new(&rand::random::<[u8; 32]>())
|
Self::new(&rand::random::<[u8; 32]>())
|
||||||
}
|
}
|
||||||
@ -236,8 +230,8 @@ impl fmt::Display for Pubkey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub fn write_pubkey_file(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn error::Error>> {
|
pub fn write_pubkey_file(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
let printable = format!("{}", pubkey);
|
let printable = format!("{}", pubkey);
|
||||||
@ -252,8 +246,8 @@ pub fn write_pubkey_file(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn er
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "program"))]
|
#[cfg(feature = "everything")]
|
||||||
pub fn read_pubkey_file(infile: &str) -> Result<Pubkey, Box<dyn error::Error>> {
|
pub fn read_pubkey_file(infile: &str) -> Result<Pubkey, Box<dyn std::error::Error>> {
|
||||||
let f = std::fs::File::open(infile.to_string())?;
|
let f = std::fs::File::open(infile.to_string())?;
|
||||||
let printable: String = serde_json::from_reader(f)?;
|
let printable: String = serde_json::from_reader(f)?;
|
||||||
Ok(Pubkey::from_str(&printable)?)
|
Ok(Pubkey::from_str(&printable)?)
|
||||||
@ -434,7 +428,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_read_write_pubkey() -> Result<(), Box<dyn error::Error>> {
|
fn test_read_write_pubkey() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let filename = "test_pubkey.json";
|
let filename = "test_pubkey.json";
|
||||||
let pubkey = Pubkey::new_rand();
|
let pubkey = Pubkey::new_rand();
|
||||||
write_pubkey_file(filename, pubkey)?;
|
write_pubkey_file(filename, pubkey)?;
|
||||||
|
Reference in New Issue
Block a user