Skip to content

Commit

Permalink
Properly close all test sessions used in async beacon tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fselmo committed Nov 9, 2022
1 parent fb49b6e commit 0207dd5
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/beacon/test_async_beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,40 @@ async def test_async_cl_beacon_get_genesis(async_beacon):
response = await async_beacon.get_genesis()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_hash_root(async_beacon):
response = await async_beacon.get_hash_root()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_fork_data(async_beacon):
response = await async_beacon.get_fork_data()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_finality_checkpoint(async_beacon):
response = await async_beacon.get_finality_checkpoint()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_validators(async_beacon):
response = await async_beacon.get_validators()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_validator(async_beacon):
Expand All @@ -74,72 +84,96 @@ async def test_async_cl_beacon_get_validator(async_beacon):
response = await async_beacon.get_validator(random_validator_pubkey)
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_validator_balances(async_beacon):
response = await async_beacon.get_validator_balances()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_epoch_committees(async_beacon):
response = await async_beacon.get_epoch_committees()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_block_headers(async_beacon):
response = await async_beacon.get_block_headers()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_block_header(async_beacon):
response = await async_beacon.get_block_header("head")
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_block(async_beacon):
response = await async_beacon.get_block("head")
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_block_root(async_beacon):
response = await async_beacon.get_block_root("head")
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_block_attestations(async_beacon):
response = await async_beacon.get_block_attestations("head")
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_attestations(async_beacon):
response = await async_beacon.get_attestations()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_attester_slashings(async_beacon):
response = await async_beacon.get_attester_slashings()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_proposer_slashings(async_beacon):
response = await async_beacon.get_proposer_slashings()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_beacon_get_voluntary_exits(async_beacon):
response = await async_beacon.get_voluntary_exits()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


# Config endpoint tests:

Expand All @@ -149,18 +183,24 @@ async def test_async_cl_config_get_fork_schedule(async_beacon):
response = await async_beacon.get_fork_schedule()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_config_get_spec(async_beacon):
response = await async_beacon.get_spec()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_config_get_deposit_contract(async_beacon):
response = await async_beacon.get_deposit_contract()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


# Debug endpoint tests:

Expand All @@ -170,12 +210,16 @@ async def test_async_cl_debug_get_beacon_state(async_beacon):
response = await async_beacon.get_beacon_state()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_debug_get_beacon_heads(async_beacon):
response = await async_beacon.get_beacon_heads()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


# Node endpoint tests:

Expand All @@ -185,32 +229,44 @@ async def test_async_cl_node_get_node_identity(async_beacon):
response = await async_beacon.get_node_identity()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_node_get_peers(async_beacon):
response = await async_beacon.get_peers()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_node_get_peer(async_beacon):
response = await async_beacon.get_peer("")
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_node_get_health(async_beacon):
response = await async_beacon.get_health()
assert response <= 206

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_node_get_version(async_beacon):
response = await async_beacon.get_version()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]


@pytest.mark.asyncio
async def test_async_cl_node_get_syncing(async_beacon):
response = await async_beacon.get_syncing()
_assert_valid_response(response)

[await session.close() for session in _async_session_cache._data.values()]

0 comments on commit 0207dd5

Please sign in to comment.