Skip to content

Commit b67bf92

Browse files
committed
update documentation
1 parent 3c25ec1 commit b67bf92

File tree

1 file changed

+49
-10
lines changed

1 file changed

+49
-10
lines changed

README.md

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ SVM program test harness.
55
## Harness
66

77
The harness is designed to directly invoke the loaded executable program using
8-
the BPF Loader, bypassing any transaction sanitization and runtime checks, and
9-
instead directly processing the instruction with the BPF Loader.
8+
the rBPF VM, bypassing any transaction sanitization and runtime checks, and
9+
instead directly processing the instruction with the VM.
1010

1111
```rust
1212
let program_id = Pubkey::new_unique();
@@ -23,23 +23,20 @@ let instruction = Instruction::new_with_bytes(
2323
);
2424

2525
let accounts = vec![
26-
(key1, AccountSharedData::new(10_000, 0, &system_program::id())),
27-
(key2, AccountSharedData::new(10_000, 0, &system_program::id())),
26+
(key1, AccountSharedData::default()),
27+
(key2, AccountSharedData::default()),
2828
];
2929

3030
let mollusk = Mollusk::new(program_id, "my_program");
3131

3232
let result = mollusk.process_instruction(&instruction, &accounts);
3333
```
3434

35-
You can also use the `Checks` API provided by Mollusk for easy post-execution
35+
You can also use the `Check` API provided by Mollusk for easy post-execution
3636
checks, rather than writing them manually. The API method
3737
`process_and_validate_instruction` will still return the result, allowing you
3838
to perform further checks if you desire.
3939

40-
> Note: `Mollusk::default()` will use the System program as the program to
41-
> invoke.
42-
4340
```rust
4441
let sender = Pubkey::new_unique();
4542
let recipient = Pubkey::new_unique();
@@ -69,10 +66,14 @@ let checks = vec![
6966
.build(),
7067
];
7168

72-
Mollusk::default().process_and_validate_instruction(&instruction, &accounts, &checks);
69+
Mollusk::default().process_and_validate_instruction(
70+
&instruction,
71+
&accounts,
72+
&checks,
73+
);
7374
```
7475

75-
## Bencher
76+
## Compute Unit Bencher
7677

7778
Mollusk also offers a compute unit usage bencher for profiling a program's
7879
compute unit usage.
@@ -119,3 +120,41 @@ Mollusk will output bench details to the output directory in Markdown.
119120
| bench1 | 579 | -129 |
120121
| bench2 | 1,204 | +754 |
121122
| bench3 | 2,811 | +2,361 |
123+
124+
## Fuzz Fixture Support
125+
126+
Mollusk also has first-class support for generating fixtures from tests, which
127+
can be used for things like fuzzing.
128+
129+
There are two protobuf layouts supported by Mollusk:
130+
* [`org.mollusk.svm`](./fuzz/fixture/proto): The protobuf layouts defined by
131+
the Mollusk library, which map directly to the structure of a Mollusk unit
132+
test.
133+
* [`org.solana.sealevel.v1`](./fuzz/fixture-fd/proto): The protobuf layouts
134+
defined by Firedancer and used to test program instructions between targets
135+
on Firedancer and Agave.
136+
137+
Each protobuf layout has its own corresponding crate for all of the binding
138+
support: `mollusk-svm-fuzz-fixture` and `mollusk-svm-fuzz-fixture-firedancer`
139+
respectively.
140+
141+
The base library itself (`mollusk-svm`) provides support for working with
142+
fixtures directly from a Mollusk instance, via the `fuzz` and `fuzz-fd` feature
143+
flags, which can be used standalone or together.
144+
145+
When either fuzz-fixture feature flag is enabled, Mollusk can do the following:
146+
* Generate a fixture from a unit test.
147+
* Process a given fixture as a unit test.
148+
* Convert to and from fixtures to Mollusk tests and results.
149+
150+
To generate a fuzz fixture from a Mollusk unit test, provide the necessary
151+
environment variables alongside your call to `cargo test-sbf`, like so:
152+
153+
```
154+
EJECT_FUZZ_FIXTURES="my/fixtures/dir" cargo test-sbf ...
155+
```
156+
157+
JSON versions of fixtures are also supported.
158+
159+
See the documentation in [`harness/src/lib.rs`](./harness/src/lib.rs) for more
160+
information.

0 commit comments

Comments
 (0)