mirror of https://github.com/nucypher/nucypher.git
Reusable, session-scoped testerchain PoC: Deployers test time down 37%
parent
bca9f21222
commit
1e431741e3
|
@ -369,7 +369,7 @@ jobs:
|
|||
|
||||
deployers:
|
||||
<<: *python_36_base
|
||||
parallelism: 4
|
||||
parallelism: 2
|
||||
steps:
|
||||
- prepare_environment
|
||||
- run:
|
||||
|
|
|
@ -29,7 +29,9 @@ from nucypher.blockchain.eth.deployers import (
|
|||
|
||||
|
||||
@pytest.mark.slow()
|
||||
def test_adjudicator_deployer(testerchain, slashing_economics):
|
||||
def test_adjudicator_deployer(session_testerchain, slashing_economics):
|
||||
testerchain = session_testerchain
|
||||
|
||||
origin = testerchain.etherbase_account
|
||||
|
||||
token_deployer = NucypherTokenDeployer(blockchain=testerchain, deployer_address=origin)
|
||||
|
|
|
@ -24,8 +24,8 @@ from nucypher.blockchain.eth.deployers import UserEscrowDeployer, UserEscrowProx
|
|||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def user_escrow_proxy(agency):
|
||||
token_agent, staking_agent, policy_agent = agency
|
||||
def user_escrow_proxy(session_agency):
|
||||
token_agent, staking_agent, policy_agent = session_agency
|
||||
testerchain = policy_agent.blockchain
|
||||
deployer = testerchain.etherbase_account
|
||||
|
||||
|
@ -39,8 +39,8 @@ def user_escrow_proxy(agency):
|
|||
|
||||
|
||||
@pytest.mark.slow()
|
||||
def test_deploy_and_allocate(agency, user_escrow_proxy, token_economics):
|
||||
token_agent, staking_agent, policy_agent = agency
|
||||
def test_deploy_and_allocate(session_agency, user_escrow_proxy, token_economics):
|
||||
token_agent, staking_agent, policy_agent = session_agency
|
||||
testerchain = policy_agent.blockchain
|
||||
origin = testerchain.etherbase_account
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ from nucypher.blockchain.eth.deployers import (NucypherTokenDeployer,
|
|||
|
||||
|
||||
@pytest.mark.slow()
|
||||
def test_deploy_ethereum_contracts(testerchain):
|
||||
def test_deploy_ethereum_contracts(session_testerchain):
|
||||
testerchain = session_testerchain
|
||||
|
||||
origin, *everybody_else = testerchain.client.accounts
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ from nucypher.blockchain.eth.deployers import (
|
|||
)
|
||||
|
||||
|
||||
def test_policy_manager_deployer(testerchain):
|
||||
def test_policy_manager_deployer(session_testerchain):
|
||||
testerchain = session_testerchain
|
||||
origin, *everybody_else = testerchain.client.accounts
|
||||
|
||||
token_deployer = NucypherTokenDeployer(blockchain=testerchain, deployer_address=origin)
|
||||
|
|
|
@ -20,7 +20,8 @@ from nucypher.blockchain.eth.agents import StakingEscrowAgent
|
|||
from nucypher.blockchain.eth.deployers import NucypherTokenDeployer, StakingEscrowDeployer, DispatcherDeployer
|
||||
|
||||
|
||||
def test_staking_escrow_deployer_and_agent(testerchain):
|
||||
def test_staking_escrow_deployer_and_agent(session_testerchain):
|
||||
testerchain = session_testerchain
|
||||
origin, *everybody_else = testerchain.client.accounts
|
||||
|
||||
# The big day...
|
||||
|
|
|
@ -21,7 +21,8 @@ from nucypher.blockchain.eth.deployers import NucypherTokenDeployer
|
|||
from nucypher.blockchain.eth.interfaces import EthereumContractRegistry
|
||||
|
||||
|
||||
def test_token_deployer_and_agent(testerchain):
|
||||
def test_token_deployer_and_agent(session_testerchain):
|
||||
testerchain = session_testerchain
|
||||
origin = testerchain.etherbase_account
|
||||
|
||||
# Trying to get token from blockchain before it's been published fails
|
||||
|
|
|
@ -29,7 +29,9 @@ user_escrow_contracts = list()
|
|||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def user_escrow_proxy_deployer(testerchain):
|
||||
def user_escrow_proxy_deployer(session_testerchain, session_agency):
|
||||
print("ENTER USER ESCROW")
|
||||
testerchain = session_testerchain
|
||||
deployer = testerchain.etherbase_account
|
||||
user_escrow_proxy_deployer = UserEscrowProxyDeployer(deployer_address=deployer,
|
||||
blockchain=testerchain)
|
||||
|
@ -37,7 +39,8 @@ def user_escrow_proxy_deployer(testerchain):
|
|||
|
||||
|
||||
@pytest.mark.slow()
|
||||
def test_user_escrow_deployer(agency, testerchain, user_escrow_proxy_deployer):
|
||||
def test_user_escrow_deployer(session_testerchain, session_agency, user_escrow_proxy_deployer):
|
||||
testerchain = session_testerchain
|
||||
deployer_account = testerchain.etherbase_account
|
||||
secret_hash = keccak_digest(USER_ESCROW_PROXY_DEPLOYMENT_SECRET.encode())
|
||||
_escrow_proxy_deployments_txhashes = user_escrow_proxy_deployer.deploy(secret_hash=secret_hash)
|
||||
|
@ -52,7 +55,8 @@ def test_user_escrow_deployer(agency, testerchain, user_escrow_proxy_deployer):
|
|||
|
||||
|
||||
@pytest.mark.slow()
|
||||
def test_deploy_multiple(testerchain, agency, user_escrow_proxy_deployer):
|
||||
def test_deploy_multiple(session_testerchain, session_agency, user_escrow_proxy_deployer):
|
||||
testerchain = session_testerchain
|
||||
deployer_account = testerchain.etherbase_account
|
||||
|
||||
linker_deployer = LibraryLinkerDeployer(blockchain=testerchain,
|
||||
|
@ -84,7 +88,9 @@ def test_deploy_multiple(testerchain, agency, user_escrow_proxy_deployer):
|
|||
|
||||
|
||||
@pytest.mark.slow()
|
||||
def test_upgrade_user_escrow_proxy(testerchain, agency, user_escrow_proxy_deployer):
|
||||
def test_upgrade_user_escrow_proxy(session_testerchain, session_agency, user_escrow_proxy_deployer):
|
||||
testerchain = session_testerchain
|
||||
agency = session_agency
|
||||
old_secret = USER_ESCROW_PROXY_DEPLOYMENT_SECRET.encode()
|
||||
new_secret = 'new' + USER_ESCROW_PROXY_DEPLOYMENT_SECRET
|
||||
new_secret_hash = keccak_digest(new_secret.encode())
|
||||
|
|
|
@ -359,8 +359,7 @@ def solidity_compiler():
|
|||
yield compiler
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def testerchain():
|
||||
def _make_testerchain():
|
||||
"""
|
||||
https://github.com/ethereum/eth-tester # available-backends
|
||||
"""
|
||||
|
@ -373,15 +372,36 @@ def testerchain():
|
|||
password=INSECURE_DEVELOPMENT_PASSWORD,
|
||||
account=testerchain.deployer_address)
|
||||
testerchain.transacting_power.activate()
|
||||
return testerchain
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def testerchain():
|
||||
testerchain = _make_testerchain()
|
||||
yield testerchain
|
||||
testerchain.disconnect()
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def _session_testerchain(): # ... boring name...BOOH!
|
||||
testerchain = _make_testerchain()
|
||||
yield testerchain
|
||||
testerchain.disconnect()
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def agency(testerchain):
|
||||
"""Launch all Nucypher ethereum contracts"""
|
||||
def session_testerchain(_session_testerchain):
|
||||
testerchain = _session_testerchain
|
||||
testerchain.registry.clear()
|
||||
# TODO: Check also that there's enough ETH/NU for everyone
|
||||
yield testerchain
|
||||
testerchain.registry.clear()
|
||||
|
||||
|
||||
def _make_agency(testerchain):
|
||||
"""
|
||||
Launch the big three contracts on provided chain,
|
||||
make agents for each and return them.
|
||||
"""
|
||||
origin = testerchain.etherbase_account
|
||||
|
||||
token_deployer = NucypherTokenDeployer(blockchain=testerchain, deployer_address=origin)
|
||||
|
@ -415,7 +435,24 @@ def agency(testerchain):
|
|||
# Other advantages is that it's closer to how agents should be use (i.e., there
|
||||
# are no fixtures IRL) and it's more extensible (e.g., AdjudicatorAgent)
|
||||
|
||||
yield token_agent, staking_agent, policy_agent
|
||||
return token_agent, staking_agent, policy_agent
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def agency(testerchain):
|
||||
agents = _make_agency(testerchain)
|
||||
yield agents
|
||||
testerchain.registry.clear()
|
||||
Agency.clear()
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def session_agency(_session_testerchain):
|
||||
testerchain = _session_testerchain
|
||||
testerchain.registry.clear()
|
||||
agents = _make_agency(testerchain)
|
||||
yield agents
|
||||
testerchain.registry.clear()
|
||||
Agency.clear()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue