From 72f8b49501b1d2ed8c76d1a656f09898b71c4e5b Mon Sep 17 00:00:00 2001 From: szotov Date: Wed, 21 Aug 2019 09:18:13 +0300 Subject: [PATCH] Monkey patch to prevent gas adjustment in tests --- nucypher/utilities/sandbox/constants.py | 2 +- tests/fixtures.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nucypher/utilities/sandbox/constants.py b/nucypher/utilities/sandbox/constants.py index 051fb07e8..f23de97d7 100644 --- a/nucypher/utilities/sandbox/constants.py +++ b/nucypher/utilities/sandbox/constants.py @@ -144,7 +144,7 @@ MOCK_URSULA_DB_FILEPATH = ':memory:' # Gas # -TEST_GAS_LIMIT = 1_000_000_000 # Yes, One Billion. +TEST_GAS_LIMIT = 6_200_000 # gas PYEVM_GAS_LIMIT = TEST_GAS_LIMIT # TODO: move elsewhere (used to set pyevm gas limit in tests)? diff --git a/tests/fixtures.py b/tests/fixtures.py index e31ceeae9..595511ff2 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -62,7 +62,8 @@ from nucypher.utilities.sandbox.constants import (DEVELOPMENT_ETH_AIRDROP_AMOUNT NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK, TEMPORARY_DOMAIN, TEST_PROVIDER_URI, - INSECURE_DEVELOPMENT_PASSWORD, MOCK_REGISTRY_FILEPATH) + INSECURE_DEVELOPMENT_PASSWORD, MOCK_REGISTRY_FILEPATH, + TEST_GAS_LIMIT) from nucypher.utilities.sandbox.middleware import MockRestMiddleware from nucypher.utilities.sandbox.policy import generate_random_label from nucypher.utilities.sandbox.ursula import (make_decentralized_ursulas, @@ -369,6 +370,11 @@ def _make_testerchain(): """ https://github.com/ethereum/eth-tester # available-backends """ + # Monkey patch to prevent gas adjustment + import eth + 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 # Create the blockchain testerchain = TesterBlockchain(eth_airdrop=True, free_transactions=True) BlockchainInterfaceFactory.register_interface(interface=testerchain)