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

Test expected failures in ethereum common tests #404

Open
germsvel opened this issue Sep 4, 2018 · 0 comments
Open

Test expected failures in ethereum common tests #404

germsvel opened this issue Sep 4, 2018 · 0 comments

Comments

@germsvel
Copy link
Contributor

germsvel commented Sep 4, 2018

There are some tests in ethereum common tests that have expected failures.

For example, the wrongCoinbase test is supposed with different failures for each of the forks: Byzantium is supposed to have an invalidStateRoot while Homestead is supposed to have a invalidReceiptsStateRoot,

        "blocks" : [
            {
                "expectExceptionByzantium" : "InvalidStateRoot",
                "expectExceptionConstantinople" : "InvalidStateRoot",
                "expectExceptionEIP150" : "InvalidReceiptsStateRoot",
                "expectExceptionEIP158" : "InvalidReceiptsStateRoot",
                "expectExceptionFrontier" : "InvalidReceiptsStateRoot",
                "expectExceptionHomestead" : "InvalidReceiptsStateRoot",
                "rlp" : "0xf90262f901f9a014b085f5fcae99fc3cde27ca8e54519d5d993a..."
            }
        ],

We currently only use the value found under rlp key from that block hash in the json file. We ignore the rest of the values like the expectExceptionByzantium mentioned above.

We should assert that we are seeing the expected errors.

Other implementations

py-evm has a partial implementation where it makes sure that at least an error is raised (doesn't seem to check the exact error). That can be seen in their blockchain test

I include a copy of the code here in case that file changes by the time we decide to add these tests:

        if should_be_good_block:
            (block, mined_block, block_rlp) = apply_fixture_block_to_chain(block_fixture, chain)
            assert_mined_block_unchanged(block, mined_block)
        else:
            try:
                apply_fixture_block_to_chain(block_fixture, chain)
            except (TypeError, rlp.DecodingError, rlp.DeserializationError, ValidationError) as err:
                # failure is expected on this bad block
                pass
            else:
                raise AssertionError("Block should have caused a validation error")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants