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

fix: small fixes for DynSolValue strategies #683

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: arbitrary for integer types
  • Loading branch information
klkvr committed Jul 4, 2024
commit ad7ffbf0e96f93fe45e9f02f5aaff373672fbd1f
10 changes: 10 additions & 0 deletions crates/dyn-abi/proptest-regressions/arbitrary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Seeds for failure cases proptest has generated in the past. It is
# automatically read and these particular cases re-run before any
# novel cases are generated.
#
# It is recommended to check this file in to source control so that
# everyone who runs the test benefits from these saved cases.
cc de8751d56f475233e49dbbe6a4aff294553e6152d874aea3a472a8d11004f799 # shrinks to bytes = [0, 0, 0, 24]
cc 5d629bdbb7a88bb18b2881e37de092a514711427a02eaa868e42a736d281e4f8 # shrinks to value = Int(0, 8)
cc 840a037239bc6da9189c193c5e5ac7157016d70b97e37e398adf8196310d7f1a # shrinks to bytes = [0, 0, 0, 24, 87, 160, 45, 46, 6, 152, 28, 233, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
cc 9ea2dc1c967e6193abcba4f4ebe248af405e9338d378a5b0b77f4b8330d11344 # shrinks to value = Int(33175087460508630782460469446745374746564684181783761617988838507891017121792, 256)
7 changes: 6 additions & 1 deletion crates/dyn-abi/src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,13 @@ fn int_strategy<T: Arbitrary>() -> impl Strategy<Value = (ValueOfStrategy<T::Str
#[inline]
fn adjust_int(mut int: I256, size: usize) -> I256 {
if size < 256 {
int &= (I256::ONE << size).wrapping_sub(I256::ONE);
if int.bit(size) {
int |= I256::MINUS_ONE - (I256::ONE << size).wrapping_sub(I256::ONE);
} else {
int &= (I256::ONE << size).wrapping_sub(I256::ONE);
}
}

int
}

Expand Down