Skip to content

Commit

Permalink
Merge pull request #985 from dylanjw/filter-param-check
Browse files Browse the repository at this point in the history
Add test to verify client consistency with None topic args
  • Loading branch information
dylanjw authored Aug 6, 2018
2 parents 899a991 + 79b2970 commit 13af169
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/integration/parity/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def test_eth_getTransactionReceipt_unmined(self, web3, unlocked_account):
assert receipt is not None
assert receipt['blockHash'] is None

def test_eth_getLogs_with_logs_none_topic_args(self, web3):
pytest.xfail("Parity matches None to asbent values")
super().test_eth_getLogs_with_logs_none_topic_args(web3)

@flaky(max_runs=MAX_FLAKY_RUNS)
def test_eth_call_old_contract_state(self, web3, math_contract, unlocked_account):
start_block = web3.eth.getBlock('latest')
Expand Down
48 changes: 48 additions & 0 deletions web3/utils/module_testing/eth_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,57 @@ def assert_contains_log(result):
"fromBlock": 0,
"address": emitter_contract_address,
}

def test_eth_getLogs_with_logs_topic_args(
self,
web3,
block_with_txn_with_log,
emitter_contract_address,
txn_hash_with_log):
def assert_contains_log(result):
assert len(result) == 1
log_entry = result[0]
assert log_entry['blockNumber'] == block_with_txn_with_log['number']
assert log_entry['blockHash'] == block_with_txn_with_log['hash']
assert log_entry['logIndex'] == 0
assert is_same_address(log_entry['address'], emitter_contract_address)
assert log_entry['transactionIndex'] == 0
assert log_entry['transactionHash'] == HexBytes(txn_hash_with_log)

# Test with None event sig

filter_params = {
"fromBlock": 0,
"topics": [
None,
'0x000000000000000000000000000000000000000000000000000000000000d431'],
}

result = web3.eth.getLogs(filter_params)
assert_contains_log(result)

# Test with None indexed arg
filter_params = {
"fromBlock": 0,
"topics": [
'0x057bc32826fbe161da1c110afcdcae7c109a8b69149f727fc37a603c60ef94ca',
None],
}
result = web3.eth.getLogs(filter_params)
assert_contains_log(result)

def test_eth_getLogs_with_logs_none_topic_args(
self,
web3):
# Test with None overflowing
filter_params = {
"fromBlock": 0,
"topics": [None, None, None],
}

result = web3.eth.getLogs(filter_params)
assert len(result) == 0

def test_eth_call_old_contract_state(self, web3, math_contract, unlocked_account):
start_block = web3.eth.getBlock('latest')
block_num = start_block.number
Expand Down

0 comments on commit 13af169

Please sign in to comment.