Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pacrob committed Feb 27, 2024
1 parent 0f7fbb1 commit 4d09ec2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/core/contracts/test_extracting_event_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import copy
import pytest
import re

from eth_abi.exceptions import (
InsufficientDataBytes,
)
from eth_utils import (
is_same_address,
)
Expand Down Expand Up @@ -1025,6 +1029,39 @@ def test_receipt_processing_with_no_flag(indexed_event_contract, dup_txn_receipt
with pytest.warns(UserWarning, match="Expected 1 log topics. Got 0"):
returned_log = event_instance.process_receipt(dup_txn_receipt)
assert len(returned_log) == 0


def test_receipt_processing_catches_insufficientdatabytes_error(
w3, emitter, emitter_contract_event_ids, wait_for_transaction
):
txn_hash = emitter.functions.logListArgs([b"13"], [b"54"]).transact()
txn_receipt = wait_for_transaction(w3, txn_hash)
event_instance = emitter.events.LogListArgs()

# web3 doesn't generate logs with non-standard lengths, so we have to do it manually
txn_receipt_dict = copy.deepcopy(txn_receipt)
txn_receipt_dict["logs"][0] = dict(txn_receipt_dict["logs"][0])
txn_receipt_dict["logs"][0]["data"] = txn_receipt_dict["logs"][0]["data"][:-8]


assert len(event_instance.process_receipt(txn_receipt_dict)) == 0

with pytest.raises(InsufficientDataBytes):
returned_log = event_instance.process_receipt(txn_receipt_dict, errors=STRICT)
assert len(returned_log) == 0

assert len(event_instance.process_receipt(txn_receipt_dict, errors=WARN)) == 0
assert len(event_instance.process_receipt(txn_receipt_dict, errors=WARN, abi_decode_strict=False)) == 0

# processed_logs = event_instance.process_receipt(txn_receipt)
# assert len(processed_logs) == 1
# rich_log = processed_logs[0]

# event_instance = indexed_event_contract.events.LogSingleWithIndex()
# breakpoint()


# def test_receipt_processing_with_abi_strict_decode_flag(indexed_event_contract, dup_txn_receipt):


def test_single_log_processing_with_errors(indexed_event_contract, dup_txn_receipt):
Expand Down

0 comments on commit 4d09ec2

Please sign in to comment.