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

Deprecate fuzz_catch_panic #1365

Merged
merged 1 commit into from
Oct 8, 2024
Merged

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Oct 8, 2024

What

Deprecate fuzz_catch_panic, encouraging developers to use the try_ 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 a Result<Result<_,_>, Result<_,_>> developers can assert on. Developers in tests can then assert did the contract:

  1. Succeed and return the expected type, Ok(Ok(_))
  2. Error and return an expected contract error type as defined by a contracterror enum, Err(Ok(_))
  3. Succeed and return an unexpected type, Ok(Err(_))
  4. Error and return an abort (panic), or system / host error, or a contract error not included in the contracterror enum, Err(Err(_))

Known limitations

As far as I can tell the purposes of fuzz_catch_panic can be served by the Env try_invoke and the generated contract client try_ functions, but I'd be interested to hear from @brson to confirm if I'm missing any case where we'd want to keep fuzz_catch_panic.

Docs

The stellar-docs need updating as well.

@leighmcculloch leighmcculloch added this pull request to the merge queue Oct 8, 2024
Merged via the queue into main with commit 1cd3d5b Oct 8, 2024
16 checks passed
@leighmcculloch leighmcculloch deleted the deprecate-fuzz_catch_panic branch October 8, 2024 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants