michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
1.04k stars 273 forks source link

Integration test errors with "Server disconnected without sending a response." #222

Open ilmoi opened 2 years ago

ilmoi commented 2 years ago

Running this command:

poetry run pytest -vv tests/integration/test_async_http_client.py::test_get_signatures_for_address

Leads to this error:

============================================ test session starts =============================================
platform darwin -- Python 3.9.7, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /Users/ilmoi/Downloads/solana-py/.venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/ilmoi/Downloads/solana-py, configfile: pytest.ini
plugins: asyncio-0.16.0, docker-0.10.3, cov-3.0.0
collected 1 item

tests/integration/test_async_http_client.py::test_get_signatures_for_address FAILED                    [100%]

================================================== FAILURES ==================================================
______________________________________ test_get_signatures_for_address _______________________________________

test_http_client_async = <solana.rpc.async_api.AsyncClient object at 0x108c5ab50>

    @pytest.mark.integration
    @pytest.mark.asyncio
    async def test_get_signatures_for_address(test_http_client_async):
        """Test get signatures for addresses."""
        resp = await test_http_client_async.get_signatures_for_address(
            "Vote111111111111111111111111111111111111111", limit=1
        )
>       assert_valid_response(resp)

tests/integration/test_async_http_client.py:354:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

resp = {'id': 1, 'jsonrpc': '2.0', 'result': []}

    def assert_valid_response(resp: RPCResponse):
        """Assert valid RPCResponse."""
        assert resp["jsonrpc"] == "2.0"
        assert resp["id"]
>       assert resp["result"]
E       AssertionError

tests/integration/utils.py:12: AssertionError
--------------------------------------------- Captured log setup ---------------------------------------------
ERROR    solanaweb3.rpc.httprpc.HTTPClient:async_http.py:37 Health check failed with error: Server disconnected without sending a response.
ERROR    solanaweb3.rpc.httprpc.HTTPClient:async_http.py:37 Health check failed with error: Server disconnected without sending a response.
========================================== short test summary info ===========================================
FAILED tests/integration/test_async_http_client.py::test_get_signatures_for_address - AssertionError
============================================= 1 failed in 4.91s ==============================================

Not the case for all integration tests, eg the airdrop ones pass, so can't be a pure docker issue. Unit tests also all pass.

What might be causing this?

michaelhly commented 2 years ago

Does make test work? Perhaps the docker container did not start properly 🤔 ..

ilmoi commented 2 years ago

Weirdly... it does. Oh man this isn't helpful is it. Am getting an error for another test, but I saw that's already brought up in a different thread:

    @pytest.mark.asyncio
    @pytest.mark.integration
    async def test_multiple_subscriptions(
        stubbed_sender: Keypair,
        test_http_client_async: AsyncClient,
        multiple_subscriptions: List[RequestBody],
        websocket: SolanaWsClientProtocol,
    ):
        """Test subscribing to multiple feeds."""
        await test_http_client_async.request_airdrop(stubbed_sender.public_key, AIRDROP_AMOUNT)
        async for idx, message in asyncstdlib.enumerate(websocket):
            assert message.result is not None
            if idx == len(multiple_subscriptions) - 1:
                break
        balance = await test_http_client_async.get_balance(
            stubbed_sender.public_key,
        )
>       assert balance["result"]["value"] == AIRDROP_AMOUNT
E       assert 29986902600 == 10000000000
E         +29986902600
E         -10000000000

tests/integration/test_websockets.py:166: AssertionError

Any ideas on how I might be able to only run test_get_signatures_for_address or we stuck in docker black magic land?