-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an Arbitrary-friendly expression type for synth-wasm and fuzz
- Loading branch information
Showing
15 changed files
with
627 additions
and
68 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
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
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
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,33 @@ | ||
#![no_main] | ||
|
||
use soroban_env_host::{ | ||
budget::AsBudget, | ||
xdr::{ScErrorCode, ScErrorType}, | ||
Env, Host, Symbol, | ||
}; | ||
use soroban_synth_wasm::{Emit, ValExpr}; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|expr: ValExpr| { | ||
// fuzzed code goes here | ||
let wasm = expr.as_single_function_wasm_module("test"); | ||
let host = Host::test_host_with_recording_footprint(); | ||
host.enable_debug().unwrap(); | ||
let contract_id_obj = host.register_test_contract_wasm(wasm.as_slice()); | ||
host.as_budget().reset_unlimited().unwrap(); | ||
let res = host.call( | ||
contract_id_obj, | ||
Symbol::try_from_small_str("test").unwrap(), | ||
host.test_vec_obj::<u32>(&[]).unwrap(), | ||
); | ||
// Non-internal error-code returns are ok, we are interested in _panics_ and | ||
// internal errors. | ||
if let Err(hosterror) = res { | ||
if hosterror.error.is_code(ScErrorCode::InternalError) | ||
&& !hosterror.error.is_type(ScErrorType::Contract) | ||
{ | ||
panic!("got internal error: {:?}", hosterror) | ||
} | ||
} | ||
}); |
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
Oops, something went wrong.