Skip to content

Commit

Permalink
Make createFilter test more robust
Browse files Browse the repository at this point in the history
Previously ethereum#730 was not being caught, because the
topic parameter was being overrided with the value
None
  • Loading branch information
dylanjw committed Apr 9, 2018
1 parent df74df3 commit d47975d
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions tests/core/filtering/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from eth_utils import (
apply_key_map,
encode_hex,
event_signature_to_log_topic,
)
Expand Down Expand Up @@ -113,17 +114,10 @@ def return_filter_by_api(
return contract.eventFilter(*args)
elif api_style == 'v4':
event_name = args[0]
argument_filters = args[1].get('filter', {})
topics = args[1].get('topics')
fromBlock = args[1].get('fromBlock', 'latest')
toBlock = args[1].get('toBlock')
address = args[1].get('address')
return getattr(contract.events, event_name).createFilter(
argument_filters=argument_filters,
topics=topics,
fromBlock=fromBlock,
toBlock=toBlock,
address=address)
kwargs = apply_key_map({'filter': 'argument_filters'}, args[1])
if 'fromBlock' not in kwargs:
kwargs['fromBlock'] = 'latest'
return getattr(contract.events, event_name).createFilter(**kwargs)
else:
raise ValueError("api_style must be 'v3 or v4'")

Expand Down

0 comments on commit d47975d

Please sign in to comment.