mirror of https://github.com/nucypher/nucypher.git
Merge pull request #1318 from szotov/tests-optimization
Contracts tests time optimizationpull/1360/head
commit
07af77d74d
|
@ -20,6 +20,7 @@ import os
|
|||
from typing import List, Tuple
|
||||
|
||||
import maya
|
||||
from eth_tester.exceptions import TransactionFailed
|
||||
from twisted.logger import Logger
|
||||
from web3 import Web3
|
||||
|
||||
|
@ -265,5 +266,7 @@ class TesterBlockchain(BlockchainDeployerInterface):
|
|||
"""Wait for a transaction receipt and return it"""
|
||||
timeout = timeout or self.TIMEOUT
|
||||
result = self.w3.eth.waitForTransactionReceipt(txhash, timeout=timeout)
|
||||
if result.status == 0:
|
||||
raise TransactionFailed()
|
||||
return result
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ def test_testerchain_creation(testerchain, another_testerchain):
|
|||
assert 'tester' in chain.provider_uri
|
||||
|
||||
# ... and that there are already some blocks mined
|
||||
chain.w3.eth.web3.testing.mine(1)
|
||||
assert chain.w3.eth.blockNumber > 0
|
||||
|
||||
# Check that we have enough test accounts
|
||||
|
|
|
@ -23,6 +23,8 @@ import tempfile
|
|||
|
||||
import maya
|
||||
import pytest
|
||||
from eth_tester import PyEVMBackend
|
||||
|
||||
from constant_sorrow.constants import NON_PAYMENT
|
||||
from sqlalchemy.engine import create_engine
|
||||
from twisted.logger import Logger
|
||||
|
@ -366,6 +368,14 @@ def _make_testerchain():
|
|||
eth._utils.headers.GAS_LIMIT_MINIMUM = TEST_GAS_LIMIT
|
||||
eth._utils.headers.GENESIS_GAS_LIMIT = TEST_GAS_LIMIT
|
||||
eth.vm.forks.frontier.headers.GENESIS_GAS_LIMIT = TEST_GAS_LIMIT
|
||||
|
||||
# Monkey patch to prevent gas estimates
|
||||
def _get_buffered_gas_estimate(web3, transaction, gas_buffer=100000):
|
||||
return TEST_GAS_LIMIT
|
||||
|
||||
import web3
|
||||
web3.eth.get_buffered_gas_estimate = _get_buffered_gas_estimate
|
||||
|
||||
# Create the blockchain
|
||||
testerchain = TesterBlockchain(eth_airdrop=True, free_transactions=True)
|
||||
BlockchainInterfaceFactory.register_interface(interface=testerchain)
|
||||
|
@ -387,6 +397,11 @@ def _testerchain():
|
|||
def testerchain(_testerchain):
|
||||
testerchain = _testerchain
|
||||
|
||||
# Reset chain state
|
||||
pyevm_backend = testerchain.provider.ethereum_tester.backend
|
||||
snapshot = pyevm_backend.chain.get_canonical_block_by_number(0).hash
|
||||
pyevm_backend.revert_to_snapshot(snapshot)
|
||||
|
||||
coinbase, *addresses = testerchain.client.accounts
|
||||
|
||||
for address in addresses:
|
||||
|
|
Loading…
Reference in New Issue