Reorganize semantic tests for calldata and abicoder#16483
Reorganize semantic tests for calldata and abicoder#16483
Conversation
6095512 to
f20af71
Compare
| // revertStrings: debug | ||
| // ---- | ||
| // f((int16,uint8,bytes2)): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab" -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab" | ||
| // f((int16,uint8,bytes2)): 0xff010, 0xff, "ab" -> FAILURE |
There was a problem hiding this comment.
Looks like we actually have no message for this validation, so revertStrings: debug does nothing here.
solidity/libsolidity/codegen/YulUtilFunctions.cpp
Line 4088 in 80d5c53
This is in validatorFunction(), used by ABI utilities. It was likely missed when error messages were added, because it sits in YulUtilFunctions. I think we should give it a message.
There was a problem hiding this comment.
I agree. There is probably more case which should have a message. Maybe it would be good to scan the code looking for revert(0, 0) pattern.
There was a problem hiding this comment.
I would add an issue to not forget to implement this in the future.
|
In any case, this test could be covering some ancient, long fixed bug, but in isolation it looks a bit worthless and weird (why unused |
| } | ||
| } | ||
| // ==== | ||
| // revertStrings: debug |
There was a problem hiding this comment.
Maybe we should make it the default in tests? It's not enabled normally due to gas reasons, but I don't see a strong reason not to always have these messages in tests.
There was a problem hiding this comment.
I agree. It would be much more clear what is the exact failure.
rodiazet
left a comment
There was a problem hiding this comment.
LGTM. Some comments or rather questions added and I proposed to move one test.
There was a problem hiding this comment.
This test is a copy of test/libsolidity/semanticTests/array/calldata_array_bounds_check_nested_bytes.sol Shouldn't this be moved to test/libsolidity/semanticTests/abicoder/calldataDecoding/array
There was a problem hiding this comment.
This test is a copy of
test/libsolidity/semanticTests/array/calldata_array_bounds_check_nested_bytes.sol
Yes, that's why I kept only one of them.
Shouldn't this be moved to
test/libsolidity/semanticTests/abicoder/calldataDecoding/array
Well, we have many tests that would fit in more than one place. When it comes to calldata arrays, for example, there is a big overlap between array behavior and calldata decoding. This case IMO is more about the former. The test checks that accessing an element past the end of the array reverts. This is not specific to calldata and happens with all kinds of arrays (note that it's Panic, not Error).
...ibsolidity/semanticTests/abicoder/validation/array_exceeds_calldatasize_no_revert_string.sol
Show resolved
Hide resolved
| } | ||
| } | ||
| // ==== | ||
| // revertStrings: debug |
There was a problem hiding this comment.
I agree. It would be much more clear what is the exact failure.
| // revertStrings: debug | ||
| // ---- | ||
| // f((function)): "01234567890123456789abcd" -> 1 | ||
| // f((function)): "01234567890123456789abcdX" -> FAILURE |
There was a problem hiding this comment.
Why this failure has not message?
There was a problem hiding this comment.
Same reason as in https://github.com/argotorg/solidity/pull/16483/files#r2829800249. It fails in validatorFunction().
| // revertStrings: debug | ||
| // ---- | ||
| // f((int16,uint8,bytes2)): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab" -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01, 0xff, "ab" | ||
| // f((int16,uint8,bytes2)): 0xff010, 0xff, "ab" -> FAILURE |
There was a problem hiding this comment.
I agree. There is probably more case which should have a message. Maybe it would be good to scan the code looking for revert(0, 0) pattern.
f20af71 to
d45a45e
Compare
d45a45e to
0df51f7
Compare
Still not sure what to do about it, but for now I decided to move it to |
- The test does seem to pass now via both pipelines.
0df51f7 to
8b17183
Compare
This is just a refactor in preparation for fixing a bug in calldata validation. I needed to figure out what we have coverage for and since our tests for this are all over the place, I did some renaming and reorganization of the test dirs.
Summary of changes:
abiEncodeDecode/,abiEncoderV1/,abiEncoderV2/,calldata/undersemanticTests/all had random subsets of ABI encoding and calldata tests. I merged them all into a singleabicoder/dir with subdirs for validation, cleanup, structs, arrays, etc. Also moved some tests fromarrays/andstructs/there.abicoderpragma cover both v1 and v2 since isoltest inserts a pragma depending on whether it runs with or without--abiencoderv1. Those with v2 pragma cover only v2. Those with v1 pragma cover v1 via evmasm and v2 via Yul (since the compiler ignores the pragma via Yul).compileViaYul: false. Another mixed tabs and spaces. Etc.