Repository navigation
Fix dynamic bytes and string assertEq equality - #1163
DicksonWu654 wants to merge 5 commits into
Conversation
|
@DicksonWu654The bug is real and the However, the new tests don't exercise the changed rules. Cheatcode-level assertion tests live in the end-to-end project ( function test_assertEq_bytes_leading_zero_err() public {
bytes memory a = hex"01";
bytes memory b = hex"0001";
vm.expectRevert("assertion failed");
assertEq(a, b);
}plus the Two related points:
|
|
@anvacaru sorry for the slow reply, and thanks for the really thorough review! Moved everything into Unit.t.sol, applied ==K to both Darray rules too (449e024 + f7741fd) and merged master. Two things differ from your example:
All 12 proofs pass locally on K 7.1.337, including the freshBytes(40) symbolic case. With the old |
Summary
bytesandstringpayloads as complete byte sequences with==KProblem
The dynamic
assertEqrules projected each decoded payload through#asWordbefore comparing it as an integer. Distinct ABI values can therefore collide:0x01and0x0001both project to integer1, allowing an unequalbytesorstringassertion to pass.Fix
Keep the ABI offsets and lengths as integers, but retain the decoded dynamic payloads as
Bytesand pass their full==Kequality result to#assert. This makes both content and length significant for thebytesandstringoverloads, including their message variants.Regression coverage
bytesvalues0x01and0x0001, with and without a message, are expected to failstringbyte sequences0x01and0x0001, with and without a message, are expected to fail0x0001values remain accepted for both types and both message formsValidation
git diff --check