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

Handle arbitrary::Error::IncorrectFormat #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

brson
Copy link

@brson brson commented Nov 11, 2023

This is a fix for stellar/rs-soroban-sdk#1141, the basic problem described stellar/rs-soroban-sdk#1140 (comment)

If Arbitrary::arbitrary receives bytes it can't use it may return Error::IncorrectFormat. At present, if this happens the proptest will fail.

This patch uses the reject_local mechanism on the proptest test runner to reject these cases and try again. reject_local will eventually return an error if too many cases are rejected.

(I think we can probably do something similar for the random bytes buffer size, automatically increasing the buffer if Arbitrary returns NotEnoughData, but I have not done that yet).

@brson
Copy link
Author

brson commented Nov 11, 2023

If you could publish a point release with just this fix that would be helpful, though I am looking at some further improvements.

Copy link

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻

@graydon
Copy link
Owner

graydon commented Nov 14, 2023

@brson I'm happy to merge this if it makes things more robust and doesn't make future debugging worse (eg. by masking failures); but I should also mention that the underlying bug (stellar/rs-soroban-env#1175) is very high on my list and likely something I'll fix in the next couple days anyways. So like .. not sure how you'd prefer to proceed. Is it better to just wait for that and then unwind all the workarounds put in place because of it?

(I'm very sorry to have caused those)

@brson
Copy link
Author

brson commented Nov 15, 2023

@graydon I think this patch is probably an improvement regardless of whether stellar/rs-soroban-env#1175 is resolved to not have arbitrary return this error code. ISTM that it is valid for arbitrary to fail in this way, and there are other strategies in the proptest crate that do this loop for similar reasons.

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.

None yet

3 participants