Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/core/contracts/test_extracting_event_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,3 +1332,30 @@ def test_receipt_processing_catches_insufficientdatabytes_error_by_default(
with pytest.raises(InsufficientDataBytes):
returned_log = event_instance.process_receipt(txn_receipt_dict, errors=STRICT)
assert len(returned_log) == 0


def test_process_log_with_abi_not_set(w3, emitter, wait_for_transaction):
# process_log should not crash when .abi is None
txn_hash = emitter.functions.logListArgs([b"13"], [b"54"]).transact()
txn_receipt = wait_for_transaction(w3, txn_hash)

event_instance = emitter.events.LogListArgs

# .abi can be None if the event is accessed without proper initialization
event_instance.abi = None

rich_log = event_instance.process_log(txn_receipt["logs"][0])
assert rich_log["event"] == "LogListArgs"


def test_process_receipt_with_abi_not_set(w3, emitter, wait_for_transaction):
# process_receipt should not crash when .abi is None
txn_hash = emitter.functions.logListArgs([b"13"], [b"54"]).transact()
txn_receipt = wait_for_transaction(w3, txn_hash)

event_instance = emitter.events.LogListArgs
event_instance.abi = None

processed_logs = event_instance.process_receipt(txn_receipt)
assert len(processed_logs) == 1
assert processed_logs[0]["event"] == "LogListArgs"
4 changes: 2 additions & 2 deletions web3/contract/base_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _parse_logs(

for log in txn_receipt["logs"]:
try:
rich_log = get_event_data(self.w3.codec, self.abi, log)
rich_log = get_event_data(self.w3.codec, self._get_event_abi(), log)
except (
MismatchedABI,
LogTopicError,
Expand Down Expand Up @@ -271,7 +271,7 @@ def _parse_logs(

@combomethod
def process_log(self, log: LogReceipt) -> EventData:
return get_event_data(self.w3.codec, self.abi, log)
return get_event_data(self.w3.codec, self._get_event_abi(), log)

@combomethod
def _get_event_filter_params(
Expand Down