From 15f0a32208af5e8f617689bbae0415cb3d380897 Mon Sep 17 00:00:00 2001 From: Dylan Wilson Date: Wed, 15 Aug 2018 19:40:08 -0700 Subject: [PATCH] Remove unecessary generators --- .../test_filters_against_many_blocks.py | 60 +++++++------------ 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/tests/core/filtering/test_filters_against_many_blocks.py b/tests/core/filtering/test_filters_against_many_blocks.py index 715d5b7756..8e1745a4e4 100644 --- a/tests/core/filtering/test_filters_against_many_blocks.py +++ b/tests/core/filtering/test_filters_against_many_blocks.py @@ -5,9 +5,6 @@ to_tuple, ) -SEED = 50505050505 -random.seed(SEED) - @to_tuple def deploy_contracts(web3, contract, wait_for_transaction): @@ -19,25 +16,20 @@ def deploy_contracts(web3, contract, wait_for_transaction): def pad_with_transactions(w3): accounts = w3.eth.accounts - while True: - transact = yield - tx_hash = transact() - for tx_count in range(random.randint(0, 10)): - _from = accounts[random.randint(0, len(accounts) - 1)] - _to = accounts[random.randint(0, len(accounts) - 1)] - value = 50 + tx_count - w3.eth.sendTransaction({'from': _from, 'to': _to, 'value': value}) - yield tx_hash + for tx_count in range(random.randint(0, 10)): + _from = accounts[random.randint(0, len(accounts) - 1)] + _to = accounts[random.randint(0, len(accounts) - 1)] + value = 50 + tx_count + w3.eth.sendTransaction({'from': _from, 'to': _to, 'value': value}) def single_transaction(w3): accounts = w3.eth.accounts - while True: - _from = accounts[random.randint(0, len(accounts) - 1)] - _to = accounts[random.randint(0, len(accounts) - 1)] - value = 50 - tx_hash = w3.eth.sendTransaction({'from': _from, 'to': _to, 'value': value}) - yield tx_hash + _from = accounts[random.randint(0, len(accounts) - 1)] + _to = accounts[random.randint(0, len(accounts) - 1)] + value = 50 + tx_hash = w3.eth.sendTransaction({'from': _from, 'to': _to, 'value': value}) + return tx_hash def test_event_filter_new_events( @@ -57,30 +49,25 @@ def test_event_filter_new_events( expected_match_counter = 0 - tx_padder = pad_with_transactions(web3) - tx_padder.send(None) while web3.eth.blockNumber < 50: is_match = bool(random.randint(0, 1)) if is_match: expected_match_counter += 1 - tx_padder.send(matching_transact) - next(tx_padder) + matching_transact() + pad_with_transactions(web3) continue - tx_padder.send(non_matching_transact) - next(tx_padder) + non_matching_transact() + pad_with_transactions(web3) assert len(event_filter.get_new_entries()) == expected_match_counter -@pytest.mark.xfail +@pytest.mark.xfail("Suspected eth-tester bug") def test_block_filter(web3): block_filter = web3.eth.filter("latest") - tx_padder = pad_with_transactions(web3) - tx_padder.send(None) while web3.eth.blockNumber < 50: - tx_padder.send(lambda: "ok") - next(tx_padder) + pad_with_transactions(web3) assert len(block_filter.get_new_entries()) == web3.eth.blockNumber @@ -92,15 +79,14 @@ def test_transaction_filter_with_mining( transaction_counter = 0 - transact_once = single_transaction(web3) while transaction_counter < 100: - next(transact_once) + single_transaction(web3) transaction_counter += 1 assert len(transaction_filter.get_new_entries()) == transaction_counter -@pytest.mark.xfail +@pytest.mark.xfail("Suspected eth-tester bug") def test_transaction_filter_without_mining( web3): @@ -143,16 +129,14 @@ def gen_non_matching_transact(): expected_match_counter = 0 - tx_padder = pad_with_transactions(web3) - tx_padder.send(None) while web3.eth.blockNumber < 50: is_match = bool(random.randint(0, 1)) if is_match: expected_match_counter += 1 - tx_padder.send(matching_transact) - next(tx_padder) + matching_transact() + pad_with_transactions(web3) continue - tx_padder.send(next(non_matching_transact)) - next(tx_padder) + next(non_matching_transact)() + pad_with_transactions(web3) assert len(event_filter.get_new_entries()) == expected_match_counter