Skip to content

Commit 4d09ec2

Browse files
committed
wip
1 parent 0f7fbb1 commit 4d09ec2

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/core/contracts/test_extracting_event_data.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import copy
12
import pytest
23
import re
34

5+
from eth_abi.exceptions import (
6+
InsufficientDataBytes,
7+
)
48
from eth_utils import (
59
is_same_address,
610
)
@@ -1025,6 +1029,39 @@ def test_receipt_processing_with_no_flag(indexed_event_contract, dup_txn_receipt
10251029
with pytest.warns(UserWarning, match="Expected 1 log topics. Got 0"):
10261030
returned_log = event_instance.process_receipt(dup_txn_receipt)
10271031
assert len(returned_log) == 0
1032+
1033+
1034+
def test_receipt_processing_catches_insufficientdatabytes_error(
1035+
w3, emitter, emitter_contract_event_ids, wait_for_transaction
1036+
):
1037+
txn_hash = emitter.functions.logListArgs([b"13"], [b"54"]).transact()
1038+
txn_receipt = wait_for_transaction(w3, txn_hash)
1039+
event_instance = emitter.events.LogListArgs()
1040+
1041+
# web3 doesn't generate logs with non-standard lengths, so we have to do it manually
1042+
txn_receipt_dict = copy.deepcopy(txn_receipt)
1043+
txn_receipt_dict["logs"][0] = dict(txn_receipt_dict["logs"][0])
1044+
txn_receipt_dict["logs"][0]["data"] = txn_receipt_dict["logs"][0]["data"][:-8]
1045+
1046+
1047+
assert len(event_instance.process_receipt(txn_receipt_dict)) == 0
1048+
1049+
with pytest.raises(InsufficientDataBytes):
1050+
returned_log = event_instance.process_receipt(txn_receipt_dict, errors=STRICT)
1051+
assert len(returned_log) == 0
1052+
1053+
assert len(event_instance.process_receipt(txn_receipt_dict, errors=WARN)) == 0
1054+
assert len(event_instance.process_receipt(txn_receipt_dict, errors=WARN, abi_decode_strict=False)) == 0
1055+
1056+
# processed_logs = event_instance.process_receipt(txn_receipt)
1057+
# assert len(processed_logs) == 1
1058+
# rich_log = processed_logs[0]
1059+
1060+
# event_instance = indexed_event_contract.events.LogSingleWithIndex()
1061+
# breakpoint()
1062+
1063+
1064+
# def test_receipt_processing_with_abi_strict_decode_flag(indexed_event_contract, dup_txn_receipt):
10281065

10291066

10301067
def test_single_log_processing_with_errors(indexed_event_contract, dup_txn_receipt):

0 commit comments

Comments
 (0)