ethereum / tests

Common tests for all Ethereum implementations
MIT License
560 stars 319 forks source link

Common tests for ABI encoding #691

Open ayrat555 opened 4 years ago

ayrat555 commented 4 years ago

RLP tests are very useful for developing RLP implementations. Why doesn't this repo have common tests for Contract ABI aside from three basic tests?

winsvega commented 4 years ago

looks like more of a solidity field. here some tests: https://github.com/ethereum/solidity/blob/develop/test/libsolidity/ABIEncoderTests.cpp

ayrat555 commented 4 years ago

I don't think this issue should be closed. Solidity is a part of Ethereum. People are writing the implementation of ABI in different languages so they should have a test set to test against

ayrat555 commented 4 years ago

We had bugs in Elixir implementation for a couple of years

winsvega commented 4 years ago

@chriseth

chriseth commented 4 years ago

@ayrat555 which format are you proposing that could be language-independent?

ayrat555 commented 4 years ago

@chriseth I think any representation will work. If people won't like it, they can just convert to any format they want. the problem is in absence of tests, not its representation.

About test structure. I think something like RLP tests will work:

chriseth commented 4 years ago

We could start with some tests for an existing ABI encoder implementation.

ayrat555 commented 4 years ago

It would be great. The same tests can be used for decoder tests

encode(types, params) == output
decode(types, output) == params
axic commented 4 years ago

Have a look at the earlier discussion (#118) too. I also think there was a relevant issue on the Solidity repository from 2-3-4 years ago.

ayrat555 commented 4 years ago

It seems it didn't get far

winsvega commented 4 years ago

ok. had an overview of existing tests. we actually have a lot of structure tests here. for rlp,difficulty,transactions,genesis whatever which are not being run on the actual client.

I push the idea of having a test framework/ test suite. preferably rpc protocol through which I can manage and execute all this tests. (currently it is only the state test generation that is done that way)

But it seems that people prefere to have their own parser for this smaller tests. It is fine to have it this test repository. However we really lack of contributors to develop those tests.

@ayrat555 if you have a project and need ABI tests feel free to contribute json tests to this repo.

ayrat555 commented 4 years ago

Recently I've been fixing bugs for Elixir implementation (https://github.com/poanetwork/ex_abi) so I have a lot of test cases. Which format do you want for them?

winsvega commented 4 years ago

https://github.com/ethereum/tests/tree/develop/ABITests

ayrat555 commented 4 years ago

I knew about these tests. I think they are not complete

winsvega commented 4 years ago

Yes. I mean this is the format. If you have more tests please share.

q9f commented 2 years ago

This is kind of a chicken and egg problem, if you want to write an ABI encoder/decoder it is ofter very useful to look at spec tests. The given tests are barely scratching the complexity of ABI. So, for more complex cases, such as nested, dynamically sized arrays, I can just hope that my encoder works, because there is little to test against.