Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Deprecate
fuzz_catch_panic
, encouraging developers to use thetry_
invoke functions instead.Why
The fuzz_catch_panic function catches panics that occur when the contract fails and generates a panic. It is necessary to often catch panics when testing contracts because contract errors are populated up to the test as a panic when called from their regular client invoking function.
However, contract clients, and the env, also have
try_
variants of each function for calling a contract. When the try variant is used, panics and contract errors are caught and molded into aResult<Result<_,_>, Result<_,_>>
developers can assert on. Developers in tests can then assert did the contract:Ok(Ok(_))
contracterror
enum,Err(Ok(_))
Ok(Err(_))
contracterror
enum,Err(Err(_))
Known limitations
As far as I can tell the purposes of
fuzz_catch_panic
can be served by theEnv
try_invoke
and the generated contract clienttry_
functions, but I'd be interested to hear from @brson to confirm if I'm missing any case where we'd want to keepfuzz_catch_panic
.Docs
The stellar-docs need updating as well.