From 2da674a9d32eb9ac53394b3e2d82e699fd5e8b5e Mon Sep 17 00:00:00 2001 From: lukacan Date: Fri, 28 Jun 2024 09:08:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20move=20fuzz=20to=20separate=20cr?= =?UTF-8?q?ate=20and=20update=20examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + Cargo.lock | 53 +++++++++++++++---- Cargo.toml | 2 +- crates/client/Cargo.toml | 18 ++----- crates/client/src/commander.rs | 2 +- crates/client/src/lib.rs | 33 ++++++------ .../fuzzer_generator.rs | 0 .../client/src/source_code_generators/mod.rs | 3 ++ .../program_client_generator.rs | 0 .../snapshot_generator.rs | 0 crates/client/src/test_generator.rs | 13 ++--- crates/client/tests/test_program_client.rs | 5 +- crates/fuzz/Cargo.toml | 39 ++++++++++++++ .../derive/display_ix/Cargo.toml | 0 .../derive/display_ix/src/lib.rs | 0 .../derive/fuzz_deserialize/Cargo.toml | 0 .../derive/fuzz_deserialize/src/lib.rs | 0 .../derive/fuzz_test_executor/Cargo.toml | 0 .../derive/fuzz_test_executor/src/lib.rs | 0 .../fuzzer => fuzz/src}/accounts_storage.rs | 2 +- .../src/fuzzer => fuzz/src}/data_builder.rs | 6 +-- .../{client/src/fuzzer => fuzz/src}/error.rs | 0 .../src/fuzzer => fuzz/src}/fuzzing_stats.rs | 0 .../src/fuzzer/mod.rs => fuzz/src/lib.rs} | 8 +-- .../src}/program_test_client_blocking.rs | 4 +- .../src/fuzzer => fuzz/src}/snapshot.rs | 8 +-- .../arbitrary-custom-types-4/Cargo.lock | 35 ++++++++---- .../fuzz_tests/fuzz_0/test_fuzz.rs | 2 +- .../arbitrary-limit-inputs-5/Cargo.lock | 35 ++++++++---- .../fuzz_tests/fuzz_0/test_fuzz.rs | 2 +- examples/fuzz-tests/hello_world/Cargo.lock | 35 ++++++++---- .../fuzz_tests/fuzz_0/test_fuzz.rs | 2 +- .../incorrect-integer-arithmetic-3/Cargo.lock | 35 ++++++++---- .../fuzz_tests/fuzz_0/test_fuzz.rs | 2 +- .../incorrect-ix-sequence-1/Cargo.lock | 35 ++++++++---- .../fuzz_tests/fuzz_0/test_fuzz.rs | 2 +- .../unauthorized-access-2/Cargo.lock | 35 ++++++++---- .../fuzz_tests/fuzz_0/test_fuzz.rs | 2 +- .../unchecked-arithmetic-0/Cargo.lock | 35 ++++++++---- .../fuzz_tests/fuzz_0/test_fuzz.rs | 2 +- 40 files changed, 312 insertions(+), 144 deletions(-) rename crates/client/src/{fuzzer => source_code_generators}/fuzzer_generator.rs (100%) create mode 100644 crates/client/src/source_code_generators/mod.rs rename crates/client/src/{ => source_code_generators}/program_client_generator.rs (100%) rename crates/client/src/{fuzzer => source_code_generators}/snapshot_generator.rs (100%) create mode 100644 crates/fuzz/Cargo.toml rename crates/{client => fuzz}/derive/display_ix/Cargo.toml (100%) rename crates/{client => fuzz}/derive/display_ix/src/lib.rs (100%) rename crates/{client => fuzz}/derive/fuzz_deserialize/Cargo.toml (100%) rename crates/{client => fuzz}/derive/fuzz_deserialize/src/lib.rs (100%) rename crates/{client => fuzz}/derive/fuzz_test_executor/Cargo.toml (100%) rename crates/{client => fuzz}/derive/fuzz_test_executor/src/lib.rs (100%) rename crates/{client/src/fuzzer => fuzz/src}/accounts_storage.rs (98%) rename crates/{client/src/fuzzer => fuzz/src}/data_builder.rs (98%) rename crates/{client/src/fuzzer => fuzz/src}/error.rs (100%) rename crates/{client/src/fuzzer => fuzz/src}/fuzzing_stats.rs (100%) rename crates/{client/src/fuzzer/mod.rs => fuzz/src/lib.rs} (66%) rename crates/{client/src/fuzzer => fuzz/src}/program_test_client_blocking.rs (98%) rename crates/{client/src/fuzzer => fuzz/src}/snapshot.rs (94%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b8e42dc..2e35045b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 incremented upon a breaking change and the patch version will be incremented for features. ## [dev] - Unreleased +- feat/fuzzing moved to separate crate trident-fuzz ([#175](https://github.com/Ackee-Blockchain/trident/pull/175)) - feat/unify dependencies provided by the Trident ([#172](https://github.com/Ackee-Blockchain/trident/pull/172)) - fix/in case of fuzzing failure throw error instead of only printing message ([#167](https://github.com/Ackee-Blockchain/trident/pull/167)) - del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171)) diff --git a/Cargo.lock b/Cargo.lock index e04b1647..0490b437 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2120,13 +2120,13 @@ dependencies = [ [[package]] name = "honggfuzz" -version = "0.5.55" +version = "0.5.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848e9c511092e0daa0a35a63e8e6e475a3e8f870741448b9f6028d69b142f18e" +checksum = "7c76b6234c13c9ea73946d1379d33186151148e0da231506b964b44f3d023505" dependencies = [ "arbitrary", "lazy_static", - "memmap2", + "memmap2 0.9.4", "rustc_version", ] @@ -2549,6 +2549,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.7.1" @@ -4031,7 +4040,7 @@ dependencies = [ "lazy_static", "log", "lz4", - "memmap2", + "memmap2 0.5.10", "modular-bitfield", "num-derive 0.3.3", "num-traits", @@ -4163,7 +4172,7 @@ dependencies = [ "bv", "bytemuck", "log", - "memmap2", + "memmap2 0.5.10", "modular-bitfield", "num_enum 0.6.1", "rand 0.8.5", @@ -4353,7 +4362,7 @@ dependencies = [ "im", "lazy_static", "log", - "memmap2", + "memmap2 0.5.10", "rustc_version", "serde", "serde_bytes", @@ -4758,7 +4767,7 @@ dependencies = [ "log", "lru", "lz4", - "memmap2", + "memmap2 0.5.10", "modular-bitfield", "num-derive 0.3.3", "num-traits", @@ -4834,7 +4843,7 @@ dependencies = [ "lazy_static", "libsecp256k1", "log", - "memmap2", + "memmap2 0.5.10", "num-derive 0.3.3", "num-traits", "num_enum 0.6.1", @@ -6017,7 +6026,6 @@ dependencies = [ "log", "pathdiff", "pretty_assertions", - "prettytable", "proc-macro2", "quinn-proto", "quote", @@ -6028,9 +6036,7 @@ dependencies = [ "serial_test", "shellexpand", "solana-account-decoder", - "solana-banks-client", "solana-cli-output", - "solana-program-runtime", "solana-program-test", "solana-sdk", "solana-transaction-status", @@ -6043,6 +6049,7 @@ dependencies = [ "trident-derive-displayix", "trident-derive-fuzz-deserialize", "trident-derive-fuzz-test-executor", + "trident-fuzz", "trident-test", ] @@ -6073,6 +6080,30 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trident-fuzz" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-syn", + "arbitrary", + "heck 0.4.1", + "prettytable", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "solana-banks-client", + "solana-program-runtime", + "solana-program-test", + "solana-sdk", + "spl-token", + "syn 1.0.109", + "thiserror", + "tokio", +] + [[package]] name = "trident-test" version = "0.3.2" diff --git a/Cargo.toml b/Cargo.toml index 9d8147d5..1f2cb53f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["crates/cli", "crates/client", "crates/test"] +members = ["crates/cli", "crates/client", "crates/test", "crates/fuzz"] exclude = ["examples/"] resolver = "1" diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index 022ab825..e3e8f6a4 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -8,12 +8,7 @@ readme = "../../README.md" description = "The trident_client crate helps you build and deploy an Anchor program to a local cluster and run a test suite against it." [features] -fuzzing = [ - "dep:solana-program-test", - "dep:honggfuzz", - "quinn-proto/arbitrary", - "dep:solana-program-runtime", -] +fuzzing = ["dep:solana-program-test", "dep:honggfuzz", "quinn-proto/arbitrary"] [build-dependencies] anyhow = { version = "1.0.45", features = ["std"], default-features = false } @@ -23,11 +18,11 @@ pretty_assertions = "1.1.0" [dependencies] # TRIDENT -trident-derive-displayix = { path = "./derive/display_ix", version = "0.0.1" } -trident-derive-fuzz-deserialize = { path = "./derive/fuzz_deserialize", version = "0.0.1" } -trident-derive-fuzz-test-executor = { path = "./derive/fuzz_test_executor", version = "0.0.1" } +trident-derive-displayix = { path = "../fuzz/derive/display_ix", version = "0.0.1" } +trident-derive-fuzz-deserialize = { path = "../fuzz/derive/fuzz_deserialize", version = "0.0.1" } +trident-derive-fuzz-test-executor = { path = "../fuzz/derive/fuzz_test_executor", version = "0.0.1" } trident-test = { path = "../test", version = "0.3.2" } - +trident-fuzz = { path = "../fuzz", version = "0.1.0" } # ANCHOR # INFO: Anchor-spl is here as dependency only to activate the idl-build feature, so that @@ -44,8 +39,6 @@ solana-transaction-status = { workspace = true } solana-account-decoder = { workspace = true } spl-token = { workspace = true } spl-associated-token-account = { workspace = true } -solana-banks-client = { workspace = true } -solana-program-runtime = { workspace = true, optional = true } solana-program-test = { workspace = true, optional = true } @@ -80,4 +73,3 @@ quinn-proto = { version = "0.10.6", optional = true } pathdiff = "0.2.1" indicatif = "0.17.8" regex = "1.10.3" -prettytable = "0.10.0" diff --git a/crates/client/src/commander.rs b/crates/client/src/commander.rs index 70b12c62..27208c78 100644 --- a/crates/client/src/commander.rs +++ b/crates/client/src/commander.rs @@ -17,8 +17,8 @@ use tokio::{ }; use crate::constants::*; -use crate::fuzzer::fuzzing_stats::FuzzingStatistics; use tokio::io::AsyncBufReadExt; +use trident_fuzz::fuzzing_stats::FuzzingStatistics; #[derive(Error, Debug)] pub enum Error { diff --git a/crates/client/src/lib.rs b/crates/client/src/lib.rs index a4f03f41..df0d0539 100644 --- a/crates/client/src/lib.rs +++ b/crates/client/src/lib.rs @@ -35,24 +35,24 @@ pub mod fuzzing { pub use trident_derive_fuzz_deserialize::FuzzDeserialize; pub use trident_derive_fuzz_test_executor::FuzzTestExecutor; + pub use trident_fuzz::convert_entry; + pub use trident_fuzz::fuzz_trident; + pub use trident_fuzz::show_account; /// trident macros - pub use super::fuzzer::*; - pub use crate::convert_entry; - pub use crate::fuzz_trident; - pub use crate::show_account; + pub use trident_fuzz::*; - pub use super::fuzzer::program_test_client_blocking::ProgramEntry; pub use solana_program_test::processor; + pub use trident_fuzz::program_test_client_blocking::ProgramEntry; - /// trident methods - pub use super::fuzzer::accounts_storage::*; - pub use super::fuzzer::data_builder::build_ix_fuzz_data; - pub use super::fuzzer::data_builder::*; - pub use super::fuzzer::error::*; - pub use super::fuzzer::fuzzing_stats::FuzzingStatistics; - pub use super::fuzzer::program_test_client_blocking::ProgramTestClientBlocking; - pub use super::fuzzer::snapshot::Snapshot; pub use super::temp_clone::*; + /// trident methods + pub use trident_fuzz::accounts_storage::*; + pub use trident_fuzz::data_builder::build_ix_fuzz_data; + pub use trident_fuzz::data_builder::*; + pub use trident_fuzz::error::*; + pub use trident_fuzz::fuzzing_stats::FuzzingStatistics; + pub use trident_fuzz::program_test_client_blocking::ProgramTestClientBlocking; + pub use trident_fuzz::snapshot::Snapshot; pub use std::cell::RefCell; pub use std::collections::HashMap; @@ -92,11 +92,10 @@ mod client; mod commander; mod config; mod error_reporter; -mod fuzzer; mod idl; mod keys; -mod program_client_generator; mod reader; +mod source_code_generators; mod temp_clone; mod test_generator; mod tester; @@ -108,12 +107,10 @@ pub mod ___private { pub use super::commander::Error; pub use super::commander::LocalnetHandle; pub use super::error_reporter::*; - pub use super::fuzzer::fuzzer_generator; - pub use super::fuzzer::snapshot_generator; pub use super::idl::*; pub use super::keys::*; - pub use super::program_client_generator::*; pub use super::reader::*; + pub use super::source_code_generators::*; pub use super::temp_clone::TempClone; pub use super::test_generator::ProgramData; pub use super::test_generator::TestGenerator; diff --git a/crates/client/src/fuzzer/fuzzer_generator.rs b/crates/client/src/source_code_generators/fuzzer_generator.rs similarity index 100% rename from crates/client/src/fuzzer/fuzzer_generator.rs rename to crates/client/src/source_code_generators/fuzzer_generator.rs diff --git a/crates/client/src/source_code_generators/mod.rs b/crates/client/src/source_code_generators/mod.rs new file mode 100644 index 00000000..1877329d --- /dev/null +++ b/crates/client/src/source_code_generators/mod.rs @@ -0,0 +1,3 @@ +pub mod fuzzer_generator; +pub mod program_client_generator; +pub mod snapshot_generator; diff --git a/crates/client/src/program_client_generator.rs b/crates/client/src/source_code_generators/program_client_generator.rs similarity index 100% rename from crates/client/src/program_client_generator.rs rename to crates/client/src/source_code_generators/program_client_generator.rs diff --git a/crates/client/src/fuzzer/snapshot_generator.rs b/crates/client/src/source_code_generators/snapshot_generator.rs similarity index 100% rename from crates/client/src/fuzzer/snapshot_generator.rs rename to crates/client/src/source_code_generators/snapshot_generator.rs diff --git a/crates/client/src/test_generator.rs b/crates/client/src/test_generator.rs index c312980b..73bce8e7 100644 --- a/crates/client/src/test_generator.rs +++ b/crates/client/src/test_generator.rs @@ -1,11 +1,12 @@ use crate::{ commander::{Commander, Error as CommanderError}, - fuzzer, idl::IdlProgram, - program_client_generator, }; -use crate::fuzzer::snapshot_generator::generate_snapshots_code; +use crate::source_code_generators::fuzzer_generator; +use crate::source_code_generators::program_client_generator; +use crate::source_code_generators::snapshot_generator; + use cargo_metadata::{camino::Utf8PathBuf, Package}; use fehler::{throw, throws}; use std::{fs::File, io::prelude::*}; @@ -491,7 +492,7 @@ impl TestGenerator { // create fuzz instructions file let fuzz_instructions_path = new_fuzz_test_dir.join(FUZZ_INSTRUCTIONS_FILE_NAME); - let program_fuzzer = fuzzer::fuzzer_generator::generate_source_code(&self.programs_data); + let program_fuzzer = fuzzer_generator::generate_source_code(&self.programs_data); let program_fuzzer = Commander::format_program_code(&program_fuzzer).await?; self.create_file(&fuzz_instructions_path, &program_fuzzer) @@ -499,8 +500,8 @@ impl TestGenerator { // // create accounts_snapshots file let accounts_snapshots_path = new_fuzz_test_dir.join(ACCOUNTS_SNAPSHOTS_FILE_NAME); - let fuzzer_snapshots = - generate_snapshots_code(&self.programs_data).map_err(Error::ReadProgramCodeFailed)?; + let fuzzer_snapshots = snapshot_generator::generate_snapshots_code(&self.programs_data) + .map_err(Error::ReadProgramCodeFailed)?; let fuzzer_snapshots = Commander::format_program_code(&fuzzer_snapshots).await?; self.create_file(&accounts_snapshots_path, &fuzzer_snapshots) diff --git a/crates/client/tests/test_program_client.rs b/crates/client/tests/test_program_client.rs index c9d8cc71..c1cc7a58 100644 --- a/crates/client/tests/test_program_client.rs +++ b/crates/client/tests/test_program_client.rs @@ -34,7 +34,10 @@ pub async fn generate_program_client() { let program_data = vec![program_data]; let use_modules: Vec = vec![syn::parse_quote! { use trident_client::*; }]; - let client_code = trident_client::___private::generate_source_code(&program_data, &use_modules); + let client_code = trident_client::___private::program_client_generator::generate_source_code( + &program_data, + &use_modules, + ); let client_code = trident_client::___private::Commander::format_program_code(&client_code).await?; diff --git a/crates/fuzz/Cargo.toml b/crates/fuzz/Cargo.toml new file mode 100644 index 00000000..704c8dc9 --- /dev/null +++ b/crates/fuzz/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "trident-fuzz" +version = "0.1.0" +edition = "2021" +repository = "https://github.com/Ackee-Blockchain/trident" +license-file = "../../LICENSE" +readme = "../../README.md" +description = "The trident_fuzz crate helps you to write Rust Fuzz Tests for your programs with Trident." + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +# SOLANA +solana-sdk = { workspace = true } +solana-banks-client = { workspace = true } +spl-token = { workspace = true } +solana-program-runtime = { workspace = true } +solana-program-test = { workspace = true } + +# ANCHOR +anchor-lang = { workspace = true, features = ["idl-build", "init-if-needed"] } +anchor-syn = { workspace = true } + + +# ARBITRARY +arbitrary = { version = "1.3.0", features = ["derive"] } + + +# MISC +thiserror = "1.0.30" +syn = { version = "1.0.109", features = ["visit"] } +proc-macro2 = { version = "1.0.66", default-features = false } +quote = "1.0.14" +heck = { version = "0.4.0", default-features = false } +regex = "1.10.3" +prettytable = "0.10.0" +serde = { version = "1.0.136", default-features = false } +serde_json = "1.0.72" +tokio = "1" diff --git a/crates/client/derive/display_ix/Cargo.toml b/crates/fuzz/derive/display_ix/Cargo.toml similarity index 100% rename from crates/client/derive/display_ix/Cargo.toml rename to crates/fuzz/derive/display_ix/Cargo.toml diff --git a/crates/client/derive/display_ix/src/lib.rs b/crates/fuzz/derive/display_ix/src/lib.rs similarity index 100% rename from crates/client/derive/display_ix/src/lib.rs rename to crates/fuzz/derive/display_ix/src/lib.rs diff --git a/crates/client/derive/fuzz_deserialize/Cargo.toml b/crates/fuzz/derive/fuzz_deserialize/Cargo.toml similarity index 100% rename from crates/client/derive/fuzz_deserialize/Cargo.toml rename to crates/fuzz/derive/fuzz_deserialize/Cargo.toml diff --git a/crates/client/derive/fuzz_deserialize/src/lib.rs b/crates/fuzz/derive/fuzz_deserialize/src/lib.rs similarity index 100% rename from crates/client/derive/fuzz_deserialize/src/lib.rs rename to crates/fuzz/derive/fuzz_deserialize/src/lib.rs diff --git a/crates/client/derive/fuzz_test_executor/Cargo.toml b/crates/fuzz/derive/fuzz_test_executor/Cargo.toml similarity index 100% rename from crates/client/derive/fuzz_test_executor/Cargo.toml rename to crates/fuzz/derive/fuzz_test_executor/Cargo.toml diff --git a/crates/client/derive/fuzz_test_executor/src/lib.rs b/crates/fuzz/derive/fuzz_test_executor/src/lib.rs similarity index 100% rename from crates/client/derive/fuzz_test_executor/src/lib.rs rename to crates/fuzz/derive/fuzz_test_executor/src/lib.rs diff --git a/crates/client/src/fuzzer/accounts_storage.rs b/crates/fuzz/src/accounts_storage.rs similarity index 98% rename from crates/client/src/fuzzer/accounts_storage.rs rename to crates/fuzz/src/accounts_storage.rs index 226623dc..03e893f1 100644 --- a/crates/client/src/fuzzer/accounts_storage.rs +++ b/crates/fuzz/src/accounts_storage.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use solana_sdk::{pubkey::Pubkey, signature::Keypair}; -use crate::fuzzer::{data_builder::FuzzClient, AccountId}; +use crate::{data_builder::FuzzClient, AccountId}; pub struct PdaStore { pub pubkey: Pubkey, diff --git a/crates/client/src/fuzzer/data_builder.rs b/crates/fuzz/src/data_builder.rs similarity index 98% rename from crates/client/src/fuzzer/data_builder.rs rename to crates/fuzz/src/data_builder.rs index b9d1238a..286f12a0 100644 --- a/crates/client/src/fuzzer/data_builder.rs +++ b/crates/fuzz/src/data_builder.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] -use anchor_client::anchor_lang::solana_program::account_info::{Account as Acc, AccountInfo}; -use anchor_client::anchor_lang::solana_program::hash::Hash; use anchor_lang::prelude::Rent; +use anchor_lang::solana_program::account_info::{Account as Acc, AccountInfo}; +use anchor_lang::solana_program::hash::Hash; use arbitrary::Arbitrary; use arbitrary::Unstructured; use solana_sdk::account::{Account, AccountSharedData}; @@ -15,7 +15,7 @@ use std::collections::HashMap; use std::error::Error; use std::fmt::Display; -use crate::fuzzer::error::*; +use crate::error::*; pub struct FuzzData { pub pre_ixs: Vec, diff --git a/crates/client/src/fuzzer/error.rs b/crates/fuzz/src/error.rs similarity index 100% rename from crates/client/src/fuzzer/error.rs rename to crates/fuzz/src/error.rs diff --git a/crates/client/src/fuzzer/fuzzing_stats.rs b/crates/fuzz/src/fuzzing_stats.rs similarity index 100% rename from crates/client/src/fuzzer/fuzzing_stats.rs rename to crates/fuzz/src/fuzzing_stats.rs diff --git a/crates/client/src/fuzzer/mod.rs b/crates/fuzz/src/lib.rs similarity index 66% rename from crates/client/src/fuzzer/mod.rs rename to crates/fuzz/src/lib.rs index b478cf71..4c2a43e6 100644 --- a/crates/client/src/fuzzer/mod.rs +++ b/crates/fuzz/src/lib.rs @@ -1,12 +1,8 @@ pub mod accounts_storage; pub mod data_builder; -pub mod fuzzer_generator; +pub mod error; pub mod fuzzing_stats; -#[cfg(feature = "fuzzing")] +// #[cfg(feature = "fuzzing")] pub mod program_test_client_blocking; pub mod snapshot; -pub mod snapshot_generator; - pub type AccountId = u8; - -pub mod error; diff --git a/crates/client/src/fuzzer/program_test_client_blocking.rs b/crates/fuzz/src/program_test_client_blocking.rs similarity index 98% rename from crates/client/src/fuzzer/program_test_client_blocking.rs rename to crates/fuzz/src/program_test_client_blocking.rs index 3ba74105..5cc4d455 100644 --- a/crates/client/src/fuzzer/program_test_client_blocking.rs +++ b/crates/fuzz/src/program_test_client_blocking.rs @@ -13,8 +13,8 @@ use solana_sdk::{ use spl_token::state::Mint; use tokio::runtime::Builder; -use crate::fuzzer::data_builder::FuzzClient; -use crate::fuzzer::error::*; +use crate::data_builder::FuzzClient; +use crate::error::*; pub type ProgramEntry = for<'info> fn( program_id: &Pubkey, diff --git a/crates/client/src/fuzzer/snapshot.rs b/crates/fuzz/src/snapshot.rs similarity index 94% rename from crates/client/src/fuzzer/snapshot.rs rename to crates/fuzz/src/snapshot.rs index 46d6c0a6..995ebcbf 100644 --- a/crates/client/src/fuzzer/snapshot.rs +++ b/crates/fuzz/src/snapshot.rs @@ -1,11 +1,11 @@ #![allow(dead_code)] // The Snapshot is constructed in the FuzzTestExecutor macro and is generated automatically -use anchor_client::anchor_lang::solana_program::account_info::Account as Acc; -use anchor_client::anchor_lang::solana_program::account_info::AccountInfo; +use anchor_lang::solana_program::account_info::Account as Acc; +use anchor_lang::solana_program::account_info::AccountInfo; use solana_sdk::{account::Account, instruction::AccountMeta}; -use crate::fuzzer::data_builder::{FuzzClient, FuzzDeserialize}; -use crate::fuzzer::error::*; +use crate::data_builder::{FuzzClient, FuzzDeserialize}; +use crate::error::*; pub struct Snapshot<'info, T> { before: Vec>, before_acc_inf: Vec>>, diff --git a/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.lock b/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.lock index ed4099fa..b417797a 100644 --- a/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.lock +++ b/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.lock @@ -6059,14 +6059,11 @@ dependencies = [ "heck 0.4.1", "honggfuzz", "indicatif", - "lazy_static", "log", "pathdiff", - "prettytable", "proc-macro2", "quinn-proto", "quote", - "rand 0.8.5", "regex", "rstest", "serde", @@ -6074,15 +6071,9 @@ dependencies = [ "serial_test", "shellexpand", "solana-account-decoder", - "solana-banks-client", - "solana-bpf-loader-program", "solana-cli-output", - "solana-program", - "solana-program-runtime", "solana-program-test", "solana-sdk", - "solana-sdk-macro", - "solana-system-program", "solana-transaction-status", "spl-associated-token-account", "spl-token", @@ -6093,6 +6084,7 @@ dependencies = [ "trident-derive-displayix", "trident-derive-fuzz-deserialize", "trident-derive-fuzz-test-executor", + "trident-fuzz", "trident-test", ] @@ -6123,12 +6115,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trident-fuzz" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-syn", + "arbitrary", + "heck 0.4.1", + "prettytable", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "solana-banks-client", + "solana-program-runtime", + "solana-program-test", + "solana-sdk", + "spl-token", + "syn 1.0.109", + "thiserror", + "tokio", +] + [[package]] name = "trident-test" version = "0.3.2" dependencies = [ "darling 0.13.4", - "proc-macro2", "quote", "syn 1.0.109", ] diff --git a/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index a5724c3d..ee2f1d14 100644 --- a/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -3,7 +3,7 @@ use arbitrary_custom_types_4::ID as PROGRAM_ID; use fuzz_instructions::arbitrary_custom_types_4_fuzz_instructions::FuzzInstruction; use fuzz_instructions::arbitrary_custom_types_4_fuzz_instructions::Initialize; use fuzz_instructions::arbitrary_custom_types_4_fuzz_instructions::Update; -use trident_client::{convert_entry, fuzz_trident, fuzzing::*}; +use trident_client::fuzzing::*; mod accounts_snapshots; mod fuzz_instructions; diff --git a/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.lock b/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.lock index 905b4c1f..e72692c4 100644 --- a/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.lock +++ b/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.lock @@ -6061,14 +6061,11 @@ dependencies = [ "heck 0.4.1", "honggfuzz", "indicatif", - "lazy_static", "log", "pathdiff", - "prettytable", "proc-macro2", "quinn-proto", "quote", - "rand 0.8.5", "regex", "rstest", "serde", @@ -6076,15 +6073,9 @@ dependencies = [ "serial_test", "shellexpand", "solana-account-decoder", - "solana-banks-client", - "solana-bpf-loader-program", "solana-cli-output", - "solana-program", - "solana-program-runtime", "solana-program-test", "solana-sdk", - "solana-sdk-macro", - "solana-system-program", "solana-transaction-status", "spl-associated-token-account", "spl-token", @@ -6095,6 +6086,7 @@ dependencies = [ "trident-derive-displayix", "trident-derive-fuzz-deserialize", "trident-derive-fuzz-test-executor", + "trident-fuzz", "trident-test", ] @@ -6125,12 +6117,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trident-fuzz" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-syn", + "arbitrary", + "heck 0.4.1", + "prettytable", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "solana-banks-client", + "solana-program-runtime", + "solana-program-test", + "solana-sdk", + "spl-token", + "syn 1.0.109", + "thiserror", + "tokio", +] + [[package]] name = "trident-test" version = "0.3.2" dependencies = [ "darling 0.13.4", - "proc-macro2", "quote", "syn 1.0.109", ] diff --git a/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index dd1c343e..446ca549 100644 --- a/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -2,7 +2,7 @@ use arbitrary_limit_inputs_5::entry; use arbitrary_limit_inputs_5::ID as PROGRAM_ID; use fuzz_instructions::arbitrary_limit_inputs_5_fuzz_instructions::FuzzInstruction; use fuzz_instructions::arbitrary_limit_inputs_5_fuzz_instructions::InitVesting; -use trident_client::{convert_entry, fuzz_trident, fuzzing::*}; +use trident_client::fuzzing::*; mod accounts_snapshots; mod fuzz_instructions; diff --git a/examples/fuzz-tests/hello_world/Cargo.lock b/examples/fuzz-tests/hello_world/Cargo.lock index 0a36493a..9ae2578c 100644 --- a/examples/fuzz-tests/hello_world/Cargo.lock +++ b/examples/fuzz-tests/hello_world/Cargo.lock @@ -6059,14 +6059,11 @@ dependencies = [ "heck 0.4.1", "honggfuzz", "indicatif", - "lazy_static", "log", "pathdiff", - "prettytable", "proc-macro2", "quinn-proto", "quote", - "rand 0.8.5", "regex", "rstest", "serde", @@ -6074,15 +6071,9 @@ dependencies = [ "serial_test", "shellexpand", "solana-account-decoder", - "solana-banks-client", - "solana-bpf-loader-program", "solana-cli-output", - "solana-program", - "solana-program-runtime", "solana-program-test", "solana-sdk", - "solana-sdk-macro", - "solana-system-program", "solana-transaction-status", "spl-associated-token-account", "spl-token", @@ -6093,6 +6084,7 @@ dependencies = [ "trident-derive-displayix", "trident-derive-fuzz-deserialize", "trident-derive-fuzz-test-executor", + "trident-fuzz", "trident-test", ] @@ -6123,12 +6115,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trident-fuzz" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-syn", + "arbitrary", + "heck 0.4.1", + "prettytable", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "solana-banks-client", + "solana-program-runtime", + "solana-program-test", + "solana-sdk", + "spl-token", + "syn 1.0.109", + "thiserror", + "tokio", +] + [[package]] name = "trident-test" version = "0.3.2" dependencies = [ "darling 0.13.4", - "proc-macro2", "quote", "syn 1.0.109", ] diff --git a/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index 03a294da..c239068c 100644 --- a/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -2,7 +2,7 @@ use fuzz_instructions::hello_world_fuzz_instructions::FuzzInstruction; use fuzz_instructions::hello_world_fuzz_instructions::Initialize; use hello_world::entry; use hello_world::ID as PROGRAM_ID; -use trident_client::{convert_entry, fuzz_trident, fuzzing::*}; +use trident_client::fuzzing::*; mod accounts_snapshots; mod fuzz_instructions; diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.lock b/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.lock index babc39bb..0373f44d 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.lock +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.lock @@ -6061,14 +6061,11 @@ dependencies = [ "heck 0.4.1", "honggfuzz", "indicatif", - "lazy_static", "log", "pathdiff", - "prettytable", "proc-macro2", "quinn-proto", "quote", - "rand 0.8.5", "regex", "rstest", "serde", @@ -6076,15 +6073,9 @@ dependencies = [ "serial_test", "shellexpand", "solana-account-decoder", - "solana-banks-client", - "solana-bpf-loader-program", "solana-cli-output", - "solana-program", - "solana-program-runtime", "solana-program-test", "solana-sdk", - "solana-sdk-macro", - "solana-system-program", "solana-transaction-status", "spl-associated-token-account", "spl-token", @@ -6095,6 +6086,7 @@ dependencies = [ "trident-derive-displayix", "trident-derive-fuzz-deserialize", "trident-derive-fuzz-test-executor", + "trident-fuzz", "trident-test", ] @@ -6125,12 +6117,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trident-fuzz" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-syn", + "arbitrary", + "heck 0.4.1", + "prettytable", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "solana-banks-client", + "solana-program-runtime", + "solana-program-test", + "solana-sdk", + "spl-token", + "syn 1.0.109", + "thiserror", + "tokio", +] + [[package]] name = "trident-test" version = "0.3.2" dependencies = [ "darling 0.13.4", - "proc-macro2", "quote", "syn 1.0.109", ] diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index 6f5e58db..13704dbc 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -2,7 +2,7 @@ use fuzz_instructions::incorrect_integer_arithmetic_3_fuzz_instructions::FuzzIns use fuzz_instructions::incorrect_integer_arithmetic_3_fuzz_instructions::InitVesting; use incorrect_integer_arithmetic_3::entry; use incorrect_integer_arithmetic_3::ID as PROGRAM_ID; -use trident_client::{convert_entry, fuzz_trident, fuzzing::*}; +use trident_client::fuzzing::*; mod accounts_snapshots; mod fuzz_instructions; diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.lock b/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.lock index b8f170c6..014ca308 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.lock +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.lock @@ -6059,14 +6059,11 @@ dependencies = [ "heck 0.4.1", "honggfuzz", "indicatif", - "lazy_static", "log", "pathdiff", - "prettytable", "proc-macro2", "quinn-proto", "quote", - "rand 0.8.5", "regex", "rstest", "serde", @@ -6074,15 +6071,9 @@ dependencies = [ "serial_test", "shellexpand", "solana-account-decoder", - "solana-banks-client", - "solana-bpf-loader-program", "solana-cli-output", - "solana-program", - "solana-program-runtime", "solana-program-test", "solana-sdk", - "solana-sdk-macro", - "solana-system-program", "solana-transaction-status", "spl-associated-token-account", "spl-token", @@ -6093,6 +6084,7 @@ dependencies = [ "trident-derive-displayix", "trident-derive-fuzz-deserialize", "trident-derive-fuzz-test-executor", + "trident-fuzz", "trident-test", ] @@ -6123,12 +6115,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trident-fuzz" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-syn", + "arbitrary", + "heck 0.4.1", + "prettytable", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "solana-banks-client", + "solana-program-runtime", + "solana-program-test", + "solana-sdk", + "spl-token", + "syn 1.0.109", + "thiserror", + "tokio", +] + [[package]] name = "trident-test" version = "0.3.2" dependencies = [ "darling 0.13.4", - "proc-macro2", "quote", "syn 1.0.109", ] diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index a2638ac1..a0b6b879 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -2,7 +2,7 @@ use fuzz_instructions::incorrect_ix_sequence_1_fuzz_instructions::FuzzInstructio use fuzz_instructions::incorrect_ix_sequence_1_fuzz_instructions::Initialize; use incorrect_ix_sequence_1::entry; use incorrect_ix_sequence_1::ID as PROGRAM_ID; -use trident_client::{convert_entry, fuzz_trident, fuzzing::*}; +use trident_client::fuzzing::*; mod accounts_snapshots; mod fuzz_instructions; diff --git a/examples/fuzz-tests/unauthorized-access-2/Cargo.lock b/examples/fuzz-tests/unauthorized-access-2/Cargo.lock index 28bb7ba5..1a11cc23 100644 --- a/examples/fuzz-tests/unauthorized-access-2/Cargo.lock +++ b/examples/fuzz-tests/unauthorized-access-2/Cargo.lock @@ -6052,14 +6052,11 @@ dependencies = [ "heck 0.4.1", "honggfuzz", "indicatif", - "lazy_static", "log", "pathdiff", - "prettytable", "proc-macro2", "quinn-proto", "quote", - "rand 0.8.5", "regex", "rstest", "serde", @@ -6067,15 +6064,9 @@ dependencies = [ "serial_test", "shellexpand", "solana-account-decoder", - "solana-banks-client", - "solana-bpf-loader-program", "solana-cli-output", - "solana-program", - "solana-program-runtime", "solana-program-test", "solana-sdk", - "solana-sdk-macro", - "solana-system-program", "solana-transaction-status", "spl-associated-token-account", "spl-token", @@ -6086,6 +6077,7 @@ dependencies = [ "trident-derive-displayix", "trident-derive-fuzz-deserialize", "trident-derive-fuzz-test-executor", + "trident-fuzz", "trident-test", ] @@ -6116,12 +6108,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trident-fuzz" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-syn", + "arbitrary", + "heck 0.4.1", + "prettytable", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "solana-banks-client", + "solana-program-runtime", + "solana-program-test", + "solana-sdk", + "spl-token", + "syn 1.0.109", + "thiserror", + "tokio", +] + [[package]] name = "trident-test" version = "0.3.2" dependencies = [ "darling 0.13.4", - "proc-macro2", "quote", "syn 1.0.109", ] diff --git a/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index 2d8eef58..f9189619 100644 --- a/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -1,6 +1,6 @@ use fuzz_instructions::unauthorized_access_2_fuzz_instructions::FuzzInstruction; use fuzz_instructions::unauthorized_access_2_fuzz_instructions::Initialize; -use trident_client::{convert_entry, fuzz_trident, fuzzing::*}; +use trident_client::fuzzing::*; use unauthorized_access_2::entry; use unauthorized_access_2::ID as PROGRAM_ID; mod accounts_snapshots; diff --git a/examples/fuzz-tests/unchecked-arithmetic-0/Cargo.lock b/examples/fuzz-tests/unchecked-arithmetic-0/Cargo.lock index 15e2a586..dc789acb 100644 --- a/examples/fuzz-tests/unchecked-arithmetic-0/Cargo.lock +++ b/examples/fuzz-tests/unchecked-arithmetic-0/Cargo.lock @@ -6052,14 +6052,11 @@ dependencies = [ "heck 0.4.1", "honggfuzz", "indicatif", - "lazy_static", "log", "pathdiff", - "prettytable", "proc-macro2", "quinn-proto", "quote", - "rand 0.8.5", "regex", "rstest", "serde", @@ -6067,15 +6064,9 @@ dependencies = [ "serial_test", "shellexpand", "solana-account-decoder", - "solana-banks-client", - "solana-bpf-loader-program", "solana-cli-output", - "solana-program", - "solana-program-runtime", "solana-program-test", "solana-sdk", - "solana-sdk-macro", - "solana-system-program", "solana-transaction-status", "spl-associated-token-account", "spl-token", @@ -6086,6 +6077,7 @@ dependencies = [ "trident-derive-displayix", "trident-derive-fuzz-deserialize", "trident-derive-fuzz-test-executor", + "trident-fuzz", "trident-test", ] @@ -6116,12 +6108,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trident-fuzz" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-syn", + "arbitrary", + "heck 0.4.1", + "prettytable", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "solana-banks-client", + "solana-program-runtime", + "solana-program-test", + "solana-sdk", + "spl-token", + "syn 1.0.109", + "thiserror", + "tokio", +] + [[package]] name = "trident-test" version = "0.3.2" dependencies = [ "darling 0.13.4", - "proc-macro2", "quote", "syn 1.0.109", ] diff --git a/examples/fuzz-tests/unchecked-arithmetic-0/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/unchecked-arithmetic-0/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index d913c9e4..29b1c0ca 100644 --- a/examples/fuzz-tests/unchecked-arithmetic-0/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/unchecked-arithmetic-0/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -1,6 +1,6 @@ use fuzz_instructions::unchecked_arithmetic_0_fuzz_instructions::FuzzInstruction; use fuzz_instructions::unchecked_arithmetic_0_fuzz_instructions::Initialize; -use trident_client::{convert_entry, fuzz_trident, fuzzing::*}; +use trident_client::fuzzing::*; use unchecked_arithmetic_0::entry; use unchecked_arithmetic_0::ID as PROGRAM_ID; mod accounts_snapshots;