<commit_before>import pytest

from web3.utils.abi import (
    function_abi_to_4byte_selector,
)


@pytest.fixture(autouse=True)
def wait_for_first_block(web3, wait_for_block):
    wait_for_block(web3)


@pytest.fixture()
def math_contract(web3, MATH_ABI, MATH_CODE, MATH_RUNTIME, MATH_SOURCE,
                  wait_for_transaction):
    MathContract = web3.eth.contract(
        abi=MATH_ABI,
        code=MATH_CODE,
        code_runtime=MATH_RUNTIME,
        source=MATH_SOURCE,
    )
    deploy_txn = MathContract.deploy({'from': web3.eth.coinbase})
    deploy_receipt = wait_for_transaction(deploy_txn)

    assert deploy_receipt is not None
    contract_address = deploy_receipt['contractAddress']
    web3.isAddress(contract_address)

    _math_contract = MathContract(address=contract_address)
    return _math_contract


def test_eth_estimateGas(web3, math_contract):
    increment_abi = math_contract.find_matching_fn_abi('increment', [])
    call_data = function_abi_to_4byte_selector(increment_abi)
    gas_estimate = web3.eth.estimateGas({
        'to': math_contract.address,
        'from': web3.eth.coinbase,
        'data': call_data,
    })

    assert abs(gas_estimate - 21272) < 200<commit_msg>fix other estimate gas function<commit_after>import pytest

from web3.utils.abi import (
    function_abi_to_4byte_selector,
)


@pytest.fixture(autouse=True)
def wait_for_first_block(web3, wait_for_block):
    wait_for_block(web3)


@pytest.fixture()
def math_contract(web3, MATH_ABI, MATH_CODE, MATH_RUNTIME, MATH_SOURCE,
                  wait_for_transaction):
    MathContract = web3.eth.contract(
        abi=MATH_ABI,
        code=MATH_CODE,
        code_runtime=MATH_RUNTIME,
        source=MATH_SOURCE,
    )
    deploy_txn = MathContract.deploy({'from': web3.eth.coinbase})
    deploy_receipt = wait_for_transaction(deploy_txn)

    assert deploy_receipt is not None
    contract_address = deploy_receipt['contractAddress']
    web3.isAddress(contract_address)

    _math_contract = MathContract(address=contract_address)
    return _math_contract


def test_eth_estimateGas(web3, math_contract):
    increment_abi = math_contract.find_matching_fn_abi('increment', [])
    call_data = function_abi_to_4byte_selector(increment_abi)
    gas_estimate = web3.eth.estimateGas({
        'to': math_contract.address,
        'from': web3.eth.coinbase,
        'data': call_data,
    })

    try:
        assert abs(gas_estimate - 21272) < 200  # Geth
    except AssertionError:
        assert abs(gas_estimate - 42820) < 200  # TestRPC
        pass
{'fraction_non_alphanumeric': 0.09044834307992203, 'fraction_numerical': 0.01871345029239766, 'mean_word_length': 3.841509433962264, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '399560', 'n_tokens_mistral': 923, 'n_tokens_neox': 877, 'n_words': 135}