Skip to content

Commit

Permalink
snekcase async methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pacrob committed Dec 20, 2022
1 parent a9fac74 commit 949a125
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tests/core/filtering/test_contract_get_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_async_contract_get_available_events(


@pytest.mark.asyncio
async def test_async_contract_getLogs_all(
async def test_async_contract_get_logs_all(
async_w3,
async_emitter,
async_wait_for_transaction,
Expand All @@ -117,14 +117,14 @@ async def test_async_contract_getLogs_all(
txn_hash = await contract.functions.logNoArgs(event_id).transact()
await async_wait_for_transaction(async_w3, txn_hash)

contract_logs = await contract.events.LogNoArguments.getLogs()
contract_logs = await contract.events.LogNoArguments.get_logs()
log_entries = list(contract_logs)
assert len(log_entries) == 1
assert log_entries[0]["transactionHash"] == txn_hash


@pytest.mark.asyncio
async def test_async_contract_getLogs_range(
async def test_async_contract_get_logs_range(
async_w3,
async_emitter,
async_wait_for_transaction,
Expand All @@ -141,21 +141,25 @@ async def test_async_contract_getLogs_range(
eth_block_number = await async_w3.eth.block_number
assert eth_block_number == 3

contract_logs = await contract.events.LogNoArguments.getLogs()
contract_logs = await contract.events.LogNoArguments.get_logs()
log_entries = list(contract_logs)
assert len(log_entries) == 1

contract_logs = await contract.events.LogNoArguments.getLogs(fromBlock=2, toBlock=3)
contract_logs = await contract.events.LogNoArguments.get_logs(
from_block=2, to_block=3
)
log_entries = list(contract_logs)
assert len(log_entries) == 1

contract_logs = await contract.events.LogNoArguments.getLogs(fromBlock=1, toBlock=2)
contract_logs = await contract.events.LogNoArguments.get_logs(
from_block=1, to_block=2
)
log_entries = list(contract_logs)
assert len(log_entries) == 0


@pytest.mark.asyncio
async def test_async_contract_getLogs_argument_filter(
async def test_async_contract_get_logs_argument_filter(
async_w3, async_emitter, async_wait_for_transaction, emitter_event_ids
):

Expand All @@ -181,19 +185,19 @@ async def test_async_contract_getLogs_argument_filter(
for txn_hash in txn_hashes:
await async_wait_for_transaction(async_w3, txn_hash)

all_logs = await contract.events.LogTripleWithIndex.getLogs(fromBlock=1)
all_logs = await contract.events.LogTripleWithIndex.get_logs(from_block=1)
assert len(all_logs) == 4

# Filter all entries where arg1 in (1, 2)
partial_logs = await contract.events.LogTripleWithIndex.getLogs(
fromBlock=1,
partial_logs = await contract.events.LogTripleWithIndex.get_logs(
from_block=1,
argument_filters={"arg1": [1, 2]},
)
assert len(partial_logs) == 2

# Filter all entries where arg0 == 1
partial_logs = await contract.events.LogTripleWithIndex.getLogs(
fromBlock=1,
partial_logs = await contract.events.LogTripleWithIndex.get_logs(
from_block=1,
argument_filters={"arg0": 1},
)
assert len(partial_logs) == 4

0 comments on commit 949a125

Please sign in to comment.