wake icon indicating copy to clipboard operation
wake copied to clipboard

WebSocketTimeoutException when running coverage

Open khegeman opened this issue 2 years ago • 2 comments

I am trying to run coverage using the following command woke fuzz tests/test_fuzz.py --coverage 1 -n 1

I get the following error WebSocketTimeoutException: Connection timed out

There is a long call stack printed out, I see this message which seems to indicate that coverage is trying to do a debug_trace_call to anvil.

│   2009 │   │   try:                                                                              │
│   2010 │   │   │   coverage_handler = get_coverage_handler()                                     │
│   2011 │   │   │   if coverage_handler is not None and self._debug_trace_call_supported:         │
│ ❱ 2012 │   │   │   │   ret = self._chain_interface.debug_trace_call(tx_params, block)            │
│   2013 │   │   │   │   coverage_handler.add_coverage(tx_params, self, ret)                       │
│   2014 │   │   │   │   output = bytes.fromhex(ret["returnValue"][2:])                            │
│   2015 │   │   │   │   if ret["failed"]:     

I also get a web socket timeout when running with woke test tests/test_fuzz.py --coverage

I am running this on linux / Python 3.10.11. woke 3.4.2

khegeman avatar Jun 24 '23 13:06 khegeman

Hi @khegeman, there is a possibility that Anvil crashes or generating the debug trace log takes longer than the timeout set in Woke.

To debug the issue, let's use woke test tests/test_fuzz.py --coverage, which should behave the same, just launch a single test instance. Because of this, you can launch Anvil in your terminal and then connect to it using an HTTP / WebSocket URI (see https://ackeeblockchain.com/woke/docs/latest/testing-framework/getting-started/#connecting-to-a-chain). This way you can observe if the Anvil instance works correctly.

You can also try to increase the timeout, it's under [testing] section in the TOML config file, see https://ackeeblockchain.com/woke/docs/latest/configuration/#configuration-options.

michprev avatar Jun 30 '23 09:06 michprev

Hi @khegeman, there is a possibility that Anvil crashes or generating the debug trace log takes longer than the timeout set in Woke.

To debug the issue, let's use woke test tests/test_fuzz.py --coverage, which should behave the same, just launch a single test instance. Because of this, you can launch Anvil in your terminal and then connect to it using an HTTP / WebSocket URI (see https://ackeeblockchain.com/woke/docs/latest/testing-framework/getting-started/#connecting-to-a-chain). This way you can observe if the Anvil instance works correctly.

You can also try to increase the timeout, it's under [testing] section in the TOML config file, see https://ackeeblockchain.com/woke/docs/latest/configuration/#configuration-options.

It works correctly for me with the following changes :

decorating my test with @default_chain.connect("ws://localhost:8555")

Running anvil with anvil -p 8555

and then woke test tests/test_fuzz.py --coverage also works with woke fuzz tests/test_fuzz.py --coverage 1 -n 1

khegeman avatar Jul 04 '23 22:07 khegeman