Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/toml params for fuzzer #106

Merged
merged 9 commits into from
Nov 8, 2023
2 changes: 1 addition & 1 deletion crates/cli/src/command/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub async fn fuzz(root: Option<String>, subcmd: FuzzCommand) {
}
};

let commander = Commander::with_root(root.clone());
let mut commander = Commander::with_root(root.clone());
Ikrk marked this conversation as resolved.
Show resolved Hide resolved

match subcmd {
FuzzCommand::Run {
Expand Down
6 changes: 4 additions & 2 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{config::CONFIG, Reader, TempClone};
use crate::{config::Config, Reader, TempClone};
use anchor_client::{
anchor_lang::{
prelude::System, solana_program::program_pack::Pack, AccountDeserialize, Id,
Expand Down Expand Up @@ -78,14 +78,16 @@ impl Client {
/// Set `retry` to `true` when you want to wait for up to 15 seconds until
/// the localnet is running (until 30 retries with 500ms delays are performed).
pub async fn is_localnet_running(&self, retry: bool) -> bool {
let config = Config::new();

let rpc_client = self
.anchor_client
.program(System::id())
.unwrap()
.async_rpc();

for _ in 0..(if retry {
CONFIG.test.validator_startup_timeout / RETRY_LOCALNET_EVERY_MILLIS
config.test.validator_startup_timeout / RETRY_LOCALNET_EVERY_MILLIS
} else {
1
}) {
Expand Down
14 changes: 12 additions & 2 deletions crates/client/src/commander.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::config::Config;
use crate::{
idl::{self, Idl},
program_client_generator,
Expand Down Expand Up @@ -150,15 +151,24 @@ impl Commander {
throw!(Error::TestingFailed);
}
}

/// Runs fuzzer on the given target.
#[throws]
pub async fn run_fuzzer(&self, target: String) {
pub async fn run_fuzzer(&mut self, target: String) {
Ikrk marked this conversation as resolved.
Show resolved Hide resolved
let mut config = Config::new();

if let Ok(var) = std::env::var("HFUZZ_RUN_ARGS") {
config.merge_with_cli(&var)
}

let env_variables = config.get_env_variables();

let cur_dir = Path::new(&self.root.to_string()).join(TESTS_WORKSPACE);
if !cur_dir.try_exists()? {
throw!(Error::NotInitialized);
}

let mut child = Command::new("cargo")
.env("HFUZZ_RUN_ARGS", env_variables)
.current_dir(cur_dir)
.arg("hfuzz")
.arg("run")
Expand Down
Loading
Loading