leighmcculloch · GitHub

The impl of Arbitrary for Error in soroban-env-host looks like this:

impl<'a> Arbitrary<'a> for Error {
    fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
        let scerror = ScError::arbitrary(u)?;
        let error = Error::from(scerror);
        // FIXME: fuzzer discovered that it can just return "InternalError" from
        // a contract to make the host think it had an InternalError. See
        // https://github.com/stellar/rs-soroban-env/issues/1175
        if error.is_code(ScErrorCode::InternalError) {
            Err(arbitrary::Error::IncorrectFormat)
        } else {
            Ok(error)
        }
    }
}

The tests currently don't expect any Arbitrary implementation to return an error if given enough bytes; and since proptest_val_cmp is failing, I am imagine that the proptest_arbitrary_interop crate isn't expecting the arbitrary method to fail either.

Since it is valid for arbitrary to fail, the arbitrary test suite can probably account for this in the run_test method used by all the tests. The propetest probably needs to be fixed in the proptest_arbitrary_interop crate.

I'll try to hack at it right now but maybe can't resolve it tonight.

Read the original on github.com ↗