Skip to content

Commit

Permalink
dapp-tests: integration: rework fixpoint roundtrips
Browse files Browse the repository at this point in the history
  • Loading branch information
d-xo committed Sep 22, 2021
1 parent 6b8a043 commit 75d204f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/dapp-tests/integration/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ test_to_fix_roundtrip() {
for _ in $(seq "$FUZZ_RUNS"); do
local input digits
input="$(uint256)"
digits="$(mod "$(uint8)" 77)" # 78 decimal digits in max uint256

length="${#input}"
digits="$(mod "$(uint8)" "$length")"

assert_equals "$input" "$(seth --from-fix "$digits" "$(seth --to-fix "$digits" "$input")")"
done
}
Expand All @@ -282,10 +285,10 @@ test_from_fix_roundtrip() {
for _ in $(seq "$FUZZ_RUNS"); do
local input digits
input="$(uint256)"

length="${#input}"
digits="$(mod "$(uint8)" 77)" # 78 decimal digits in max uint256
digits="$(mod "$(uint8)" "$length")"

[[ $digits -ge $length ]] && continue
whole_digits=$(bc <<< "$length - $digits" | tr -d '\\\n')
input="${input:0:whole_digits}.${input:$whole_digits:$length}"

Expand Down

0 comments on commit 75d204f

Please sign in to comment.