Skip to content

Commit ded9760

Browse files
committed
Make tests better
1 parent 857839e commit ded9760

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

docs/contracts.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ and the arguments are ambiguous.
489489
>>> identity_func(1, True).call()
490490
1
491491
492-
493492
Contract Functions
494493
------------------
495494

tests/core/contracts/test_extracting_event_data.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ def test_event_processing_with_strict_error_flag(
296296

297297

298298
@pytest.mark.parametrize(
299-
'errors,rich_log_length,expected_args',
299+
'errors,rich_log_length',
300300
(
301-
(EventLogErrorFlags.discard, 0, None),
302-
(EventLogErrorFlags.ignore, 1, {'arg0': 12345}),
301+
(EventLogErrorFlags.discard, 0),
302+
(EventLogErrorFlags.ignore, 1),
303303
)
304304
)
305305
def test_event_processing_with_caught_errors(
@@ -308,7 +308,6 @@ def test_event_processing_with_caught_errors(
308308
indexed_event_contract,
309309
wait_for_transaction,
310310
errors,
311-
expected_args,
312311
rich_log_length):
313312

314313
emitter_fn = indexed_event_contract.functions.logTwoEvents
@@ -322,14 +321,16 @@ def test_event_processing_with_caught_errors(
322321

323322
event_instance = indexed_event_contract.events.LogSingleWithIndex()
324323

325-
rich_logs = event_instance.processReceipt(dup_txn_receipt, errors=errors)
324+
returned_logs = event_instance.processReceipt(dup_txn_receipt, errors=errors)
326325

327-
assert len(rich_logs) == rich_log_length
326+
assert len(returned_logs) == rich_log_length
328327

329-
if len(rich_logs) >= 1:
330-
rich_log = rich_logs[0]
328+
if len(returned_logs) == 0:
329+
assert returned_logs == ()
330+
elif len(returned_logs) == 1:
331+
returned_log = returned_logs[0]
331332

332-
assert rich_log['blockHash'] == dup_txn_receipt['blockHash']
333-
assert rich_log['blockNumber'] == dup_txn_receipt['blockNumber']
334-
assert rich_log['transactionIndex'] == dup_txn_receipt['transactionIndex']
335-
assert is_same_address(rich_log['address'], event_contract.address)
333+
assert returned_log == dup_txn_receipt['logs'][0]
334+
assert is_same_address(returned_log['address'], event_contract.address)
335+
else:
336+
raise Exception('Unreachable!')

0 commit comments

Comments
 (0)