ethereum / trinity

The Trinity client for the Ethereum network
https://trinity.ethereum.org
MIT License
474 stars 145 forks source link

Add `pytest tests/plugins` in CI and fix it #464

Closed hwwhww closed 5 years ago

hwwhww commented 5 years ago

What is wrong?

  1. Currently tests/plugins is not covered in CI.
  2. I tried to run it on my local side but it failed.
tests/plugins/eth2/beacon/test_beacon_plugin.py F                                                                                                                        [ 20%]
tests/plugins/tx_pool/test_default_transaction_validator.py ....                                                                                                         [100%]

=================================================================================== FAILURES ===================================================================================
__________________________________________________________________________ test_plugin_boot[command0] __________________________________________________________________________

async_process_runner = <trinity.tools.async_process_runner.AsyncProcessRunner object at 0x1126ef908>, command = ('trinity-beacon',)

    @pytest.mark.parametrize(
        'command',
        (
            ('trinity-beacon',),
        )
    )
    @pytest.mark.asyncio
    async def test_plugin_boot(async_process_runner, command):
        await async_process_runner.run(command, timeout_sec=30)
>       assert await contains_all(async_process_runner.stderr, {
            "Running server",
        })
E       assert False

async_process_runner = <trinity.tools.async_process_runner.AsyncProcessRunner object at 0x1126ef908>
command    = ('trinity-beacon',)

tests/plugins/eth2/beacon/test_beacon_plugin.py:16: AssertionError
----------------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------------
b'usage: trinity-beacon [-h] [--version] [--trinity-root-dir TRINITY_ROOT_DIR]\n'
b'                      [--port PORT] [-l LEVEL]\n'
b'                      [--stderr-log-level STDERR_LOG_LEVEL]\n'
b'                      [--file-log-level FILE_LOG_LEVEL]\n'
b'                      [--network-id NETWORK_ID | --ropsten]\n'
b'                      [--preferred-node PREFERRED_NODES] [--discv5]\n'
b'                      [--max-peers MAX_PEERS] [--genesis GENESIS]\n'
b'                      [--data-dir DATA_DIR] [--nodekey NODEKEY] [--profile]\n'
b'                      [--disable-rpc] [--disable-discovery]\n'
b'                      [--bootstrap_nodes BOOTSTRAP_NODES]\n'
b'                      [--beacon-nodekey BEACON_NODEKEY]\n'
b'                      {attach,fix-unclean-shutdown} ...\n'
b'trinity-beacon: error: \n'
b'It appears that /private/var/folders/l2/cr5gmc3j7qjf8lx63s4lys400000gn/T/pyt--hwwang/763/test_plugin_boot_command0_0/t/mainnet does not exist. Trinity does not attempt to create directories outside of its root path. Either manually create the path or ensure you are using a data directory inside the XDG_TRINITY_ROOT path\n'
b''
========================================================================== slowest 50 test durations ===========================================================================
1.65s call     tests/plugins/eth2/beacon/test_beacon_plugin.py::test_plugin_boot[command0]
0.02s call     tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[1-FrontierTransaction-None-SpuriousDragonTransaction]
0.02s call     tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[6-HomesteadTransaction-FrontierTransaction-SpuriousDragonTransaction]
0.01s call     tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[None-SpuriousDragonTransaction-HomesteadTransaction-SpuriousDragonTransaction]
0.01s call     tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[5-HomesteadTransaction-FrontierTransaction-SpuriousDragonTransaction]
0.01s setup    tests/plugins/eth2/beacon/test_beacon_plugin.py::test_plugin_boot[command0]
0.00s setup    tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[1-FrontierTransaction-None-SpuriousDragonTransaction]
0.00s setup    tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[6-HomesteadTransaction-FrontierTransaction-SpuriousDragonTransaction]
0.00s setup    tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[None-SpuriousDragonTransaction-HomesteadTransaction-SpuriousDragonTransaction]
0.00s setup    tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[5-HomesteadTransaction-FrontierTransaction-SpuriousDragonTransaction]
0.00s teardown tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[None-SpuriousDragonTransaction-HomesteadTransaction-SpuriousDragonTransaction]
0.00s teardown tests/plugins/eth2/beacon/test_beacon_plugin.py::test_plugin_boot[command0]
0.00s teardown tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[6-HomesteadTransaction-FrontierTransaction-SpuriousDragonTransaction]
0.00s teardown tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[5-HomesteadTransaction-FrontierTransaction-SpuriousDragonTransaction]
0.00s teardown tests/plugins/tx_pool/test_default_transaction_validator.py::test_tx_class_resolution[1-FrontierTransaction-None-SpuriousDragonTransaction]
====================================================================== 1 failed, 4 passed in 1.91 seconds ======================================================================
Task was destroyed but it is pending!
task: <Task pending coro=<AsyncProcessRunner.kill_after_timeout() running at /Users/hwwang/ethereum/trinity/trinity/tools/async_process_runner.py:62> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x1126cec48>()]>>

How can it be fixed

Fill this in if you know how to fix it.

cburgdorf commented 5 years ago

Looks like this has been fixed by https://github.com/ethereum/trinity/commit/1633355d1f4988f4be273ecafb266eafac478aa3 (Thanks @gsmadi !)