From d47975d61e618552e5a32e37a58ae9e2429539f6 Mon Sep 17 00:00:00 2001 From: Dylan Wilson Date: Fri, 6 Apr 2018 18:42:52 -0700 Subject: [PATCH] Make createFilter test more robust Previously #730 was not being caught, because the topic parameter was being overrided with the value None --- tests/core/filtering/conftest.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tests/core/filtering/conftest.py b/tests/core/filtering/conftest.py index d69e7fc95a..bba29d8f58 100644 --- a/tests/core/filtering/conftest.py +++ b/tests/core/filtering/conftest.py @@ -3,6 +3,7 @@ import pytest from eth_utils import ( + apply_key_map, encode_hex, event_signature_to_log_topic, ) @@ -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'")