-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚸 Improve ux during init, fenerate required parts in packages automat…
…ically, if code creation fails , do not generate any file
- Loading branch information
Showing
22 changed files
with
705 additions
and
454 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ pub use init::init; | |
|
||
mod clean; | ||
pub use clean::clean; | ||
|
||
mod howto; | ||
pub use howto::howto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use anyhow::Error; | ||
use fehler::throws; | ||
|
||
use crate::show_howto; | ||
|
||
#[throws] | ||
pub fn howto() { | ||
show_howto(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,35 @@ | ||
use std::path::Path; | ||
|
||
use anyhow::{bail, Error}; | ||
use fehler::throws; | ||
use trident_client::___private::TestGenerator; | ||
|
||
use crate::{_discover, show_howto}; | ||
|
||
pub const ANCHOR_TOML: &str = "Anchor.toml"; | ||
pub const TRIDENT_TOML: &str = "Trident.toml"; | ||
|
||
#[throws] | ||
pub async fn init() { | ||
pub async fn init(force: bool) { | ||
// look for Anchor.toml | ||
let root = if let Some(r) = _discover(ANCHOR_TOML)? { | ||
r | ||
} else { | ||
bail!("It does not seem that Anchor is initialized because the Anchor.toml file was not found in any parent directory!"); | ||
}; | ||
|
||
let mut generator: TestGenerator = TestGenerator::new_with_root(root); | ||
let mut generator: TestGenerator = TestGenerator::new_with_root(&root)?; | ||
|
||
generator.generate_fuzz().await?; | ||
if force { | ||
generator.initialize().await?; | ||
} else { | ||
let root_path = Path::new(&root).join(TRIDENT_TOML); | ||
if root_path.exists() { | ||
println!("It looks like Trident is already initialized as the Trident.toml was found in {} directory.",root); | ||
} else { | ||
generator.initialize().await?; | ||
} | ||
} | ||
|
||
show_howto(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
|
||
|
||
# New fuzz test template successfully added. | ||
# How To start fuzzing. | ||
|
||
## To start fuzzing, follow these steps: | ||
|
||
- Derive AccountsSnapshots for each account context in the program: | ||
- Initialize ***Trident*** using | ||
|
||
Include the following dependencies in the Cargo.toml of each program: | ||
```rust | ||
trident-derive-accounts-snapshots = "0.8.0" | ||
trident-fuzz = { version = "0.8.0", optional = true } | ||
```bash | ||
trident init | ||
``` | ||
|
||
- Add the fuzzing feature: | ||
```toml | ||
trident-fuzzing = ["dep:trident-fuzz"] | ||
- Derive ***AccountsSnapshots*** for each account context in the program: | ||
|
||
```rust | ||
use trident_derive_accounts_snapshots::AccountsSnapshots; | ||
|
||
#[derive(AccountsSnapshots, Accounts)] | ||
pub struct InitializeContext<'info> { | ||
// ... | ||
} | ||
|
||
``` | ||
|
||
- Link Account Context Aliases in the `fuzz_instructions.rs` with desired Snapshots | ||
For example: | ||
- Link Account Context Aliases in the ***fuzz_instructions.rs*** with desired Snapshots | ||
|
||
```rust | ||
use hello_world::trident_fuzz_initialize_context_snapshot::InitializeContextAlias; | ||
type InitializeFnSnapshot<'info> = InitializeContextAlias<'info>; | ||
``` | ||
|
||
- Implement the `todo!` placeholders in `fuzz_instructions.rs` based on the provided descriptions. | ||
- Implement the ***todo!*** placeholders in ***fuzz_instructions.rs*** based on the provided descriptions. | ||
|
||
- Run fuzzing with ***Honggfuzz*** or ***AFL*** | ||
|
||
```bash | ||
trident fuzz run-hfuzz | ||
``` | ||
|
||
```bash | ||
trident fuzz run-afl | ||
``` | ||
|
||
### For more details, refer to the Trident documentation: https://ackee.xyz/trident/docs/dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"trident_fuzz": "0.1.0", | ||
"trident_derive_accounts_snapshots": "0.0.1", | ||
"trident_client": "0.7.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.