Page MenuHomePhabricator

[Chronik] Add test for disconnectpool
ClosedPublic

Authored by tobias_ruck on Jul 27 2024, 10:33.

Details

Reviewers
Fabien
bytesofman
Group Reviewers
Restricted Project
Commits
rABC49b888f4c71e: [Chronik] Add test for disconnectpool
Summary

Add a test to ensure txs and blocks are added to Chronik in the right order when doing a reorg with mempool txs present. If e.g. a mempool tx would be added before blocks, Chronik would crash under stome circumstances, which is currently not tested.

Test Plan

./test/functional/test_runner.py chronik_mempool_disconnectpool

Diff Detail

Event Timeline

tobias_ruck changed the visibility from "Public (No Login Required)" to "Restricted Project (Project)".Jul 27 2024, 10:34

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_mempool_disconnectpool.py ======

------- Stdout: -------
2024-07-27T11:42:54.088000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-chronik/test/tmp/test_runner_₿₵_🏃_20240727_113758/chronik_mempool_disconnectpool_268
2024-07-27T11:43:24.867000Z TestFramework.p2p (WARNING): Connection lost to 127.0.0.1:21413 due to [Errno 104] Connection reset by peer
2024-07-27T11:43:24.890000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 147, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 137, in _run_test_internal
    self.run_test()
  File "/work/test/functional/chronik_mempool_disconnectpool.py", line 94, in run_test
    peer.send_blocks_and_test([reorg_block1, reorg_block2], node)
  File "/work/test/functional/test_framework/p2p.py", line 912, in send_blocks_and_test
    test()
  File "/work/test/functional/test_framework/p2p.py", line 899, in test
    self.sync_with_ping(timeout=timeout)
  File "/work/test/functional/test_framework/p2p.py", line 705, in sync_with_ping
    self.wait_until(test_function, timeout=timeout)
  File "/work/test/functional/test_framework/p2p.py", line 581, in wait_until
    wait_until_helper(
  File "/work/test/functional/test_framework/util.py", line 280, in wait_until_helper
    if predicate():
  File "/work/test/functional/test_framework/p2p.py", line 578, in test_function
    assert self.is_connected
AssertionError
2024-07-27T11:43:24.944000Z TestFramework (INFO): Stopping nodes
[node 0] Cleaning up leftover process
------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/test_framework/authproxy.py", line 124, in _request
    self.__conn.request(method, path, postdata, headers)
  File "/usr/lib/python3.9/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1049, in _send_output
    self.send(chunk)
  File "/usr/lib/python3.9/http/client.py", line 971, in send
    self.sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/work/test/functional/chronik_mempool_disconnectpool.py", line 103, in <module>
    ChronikMempoolDisconnectPool().main()
  File "/work/test/functional/test_framework/test_framework.py", line 170, in main
    exit_code = self.shutdown()
  File "/work/test/functional/test_framework/test_framework.py", line 396, in shutdown
    self.stop_nodes()
  File "/work/test/functional/test_framework/test_framework.py", line 645, in stop_nodes
    node.stop_node(wait=wait, wait_until_stopped=False)
  File "/work/test/functional/test_framework/test_node.py", line 512, in stop_node
    self.stop(wait=wait)
  File "/work/test/functional/test_framework/coverage.py", line 46, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/work/test/functional/test_framework/authproxy.py", line 176, in __call__
    response, status = self._request(
  File "/work/test/functional/test_framework/authproxy.py", line 130, in _request
    self.__conn.request(method, path, postdata, headers)
  File "/usr/lib/python3.9/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1010, in _send_output
    self.send(msg)
  File "/usr/lib/python3.9/http/client.py", line 950, in send
    self.connect()
  File "/usr/lib/python3.9/http/client.py", line 921, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.9/socket.py", line 843, in create_connection
    raise err
  File "/usr/lib/python3.9/socket.py", line 831, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_mempool_disconnectpool.py

tobias_ruck edited the test plan for this revision. (Show Details)
tobias_ruck edited the summary of this revision. (Show Details)
tobias_ruck changed the visibility from "Restricted Project (Project)" to "Public (No Login Required)".

If e.g. a mempool tx would be added before blocks, Chronik would crash under stome circumstances, which is currently not tested.

this is still not tested...? at least, it does not look like we expect a crash?

is the point to prove that it doesn't crash in the scenario of this test file? are there still other known crash scenarios?

Yes, we wanna make sure we don't crash in this scenario. There might be others too, but I hadn't had the time to cover them yet, we might do so in the future and amend this test.

This revision is now accepted and ready to land.Aug 14 2024, 18:14
This revision was automatically updated to reflect the committed changes.