Skip to content

Commit

Permalink
Test for contract event logs
Browse files Browse the repository at this point in the history
  • Loading branch information
reedsa committed Feb 8, 2024
1 parent d178f2e commit 61de8ba
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/core/contracts/test_extracting_event_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,29 @@ def test_argument_extraction_strict_bytes_types(
assert event_data["event"] == "LogListArgs"


def test_get_logs_for_contract_event(
w3,
emitter,
wait_for_transaction,
):
txn_hash = emitter.functions.logListArgs([b"13"], [b"54"]).transact()
txn_receipt = wait_for_transaction(w3, txn_hash)

txn_hash2 = emitter.functions.logListArgs([b"14"], [b"55"]).transact()
txn_receipt2 = wait_for_transaction(w3, txn_hash2)

event_instance = emitter.events.LogListArgs()
block_number = w3.eth.block_number
logs = event_instance.get_logs(fromBlock=1, toBlock=block_number)
sorted_logs = sorted(
event_instance.get_logs(fromBlock=1, toBlock=block_number),
key=lambda l: l["logIndex"],
)

assert len(logs) == 2
assert logs == sorted_logs


@pytest.mark.parametrize(
"contract_fn,event_name,call_args,expected_args,warning_msg,process_receipt",
(
Expand Down

0 comments on commit 61de8ba

Please sign in to comment.