Merge pull request #2321 from KPrasch/main

Fixes #2316; CI timeout for deploy CLI tests
pull/2074/head
K Prasch 2020-09-30 21:44:41 -07:00 committed by GitHub
commit 8a8c42ca4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 29 deletions

View File

@ -69,7 +69,9 @@ from nucypher.cli.literature import (
SUCCESSFUL_SAVE_MULTISIG_TX_PROPOSAL,
SUCCESSFUL_UPGRADE,
UNKNOWN_CONTRACT_NAME,
IDENTICAL_REGISTRY_WARNING, DEPLOYER_IS_NOT_OWNER, CONFIRM_VERSIONED_UPGRADE
IDENTICAL_REGISTRY_WARNING,
DEPLOYER_IS_NOT_OWNER,
CONFIRM_VERSIONED_UPGRADE
)
from nucypher.cli.options import (
group_options,
@ -462,7 +464,7 @@ def contracts(general_config, actor_options, mode, activate, gas, ignore_deploye
deployment_parameters = {}
if parameters:
with open(parameters) as json_file:
deployment_parameters = json.load(json_file) # TODO: Seems like this is bypassing existing flow in economics.py
deployment_parameters = json.load(json_file)
#
# Deploy Single Contract (Amend Registry)

View File

@ -0,0 +1,28 @@
"""
This file is part of nucypher.
nucypher is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
nucypher is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import pytest
from nucypher.blockchain.eth.clients import EthereumClient
@pytest.fixture(scope='function', autouse=True)
def monkeypatch_confirmations(testerchain, monkeypatch):
def block_until_enough_confirmations(ethclient: EthereumClient, transaction_hash, *args, **kwargs):
ethclient.log.debug(f'Confirmations mocked - instantly confirmed {kwargs.get("confirmations")} blocks!')
return testerchain.wait_for_receipt(txhash=transaction_hash)
monkeypatch.setattr(EthereumClient, 'block_until_enough_confirmations', block_until_enough_confirmations)

View File

@ -15,33 +15,25 @@
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
import json
import os
import pytest
from nucypher.blockchain.eth.networks import NetworksInventory
from nucypher.config.constants import TEMPORARY_DOMAIN
from nucypher.blockchain.eth.agents import NucypherTokenAgent
from nucypher.blockchain.eth.clients import EthereumClient
from nucypher.blockchain.eth.interfaces import BlockchainInterface
from nucypher.blockchain.eth.networks import NetworksInventory
from nucypher.blockchain.eth.registry import LocalContractRegistry
from nucypher.blockchain.eth.sol.compile import SOLIDITY_COMPILER_VERSION
from nucypher.cli.commands.deploy import deploy
from nucypher.config.constants import TEMPORARY_DOMAIN
from tests.constants import TEST_PROVIDER_URI, YES_ENTER
PLANNED_UPGRADES = 4
CONTRACTS_TO_UPGRADE = ('StakingEscrow', 'PolicyManager', 'Adjudicator', 'StakingInterface')
@pytest.fixture(autouse=True)
def monkeypatch_confirmations(testerchain, monkeypatch):
def monkey_block_until_enough_confirmations(client, transaction_hash, timeout, confirmations):
receipt = testerchain.wait_for_receipt(txhash=transaction_hash)
return receipt
monkeypatch.setattr(EthereumClient, 'block_until_enough_confirmations', monkey_block_until_enough_confirmations)
@pytest.fixture(scope="module")
def registry_filepath(temp_dir_path):
return os.path.join(temp_dir_path, 'nucypher-test-autodeploy.json')

View File

@ -19,29 +19,33 @@
import os
import pytest
from nucypher.blockchain.eth.agents import (AdjudicatorAgent, ContractAgency, PolicyManagerAgent, StakingEscrowAgent)
from nucypher.blockchain.eth.clients import EthereumClient
from nucypher.blockchain.eth.constants import (ADJUDICATOR_CONTRACT_NAME, DISPATCHER_CONTRACT_NAME,
NUCYPHER_TOKEN_CONTRACT_NAME, POLICY_MANAGER_CONTRACT_NAME,
STAKING_ESCROW_CONTRACT_NAME)
from nucypher.blockchain.eth.agents import (
AdjudicatorAgent,
ContractAgency,
PolicyManagerAgent,
StakingEscrowAgent
)
from nucypher.blockchain.eth.constants import (
ADJUDICATOR_CONTRACT_NAME,
DISPATCHER_CONTRACT_NAME,
NUCYPHER_TOKEN_CONTRACT_NAME,
POLICY_MANAGER_CONTRACT_NAME,
STAKING_ESCROW_CONTRACT_NAME
)
from nucypher.blockchain.eth.deployers import StakingEscrowDeployer
from nucypher.blockchain.eth.registry import InMemoryContractRegistry, LocalContractRegistry
from nucypher.cli.commands.deploy import deploy
from nucypher.config.constants import TEMPORARY_DOMAIN
from tests.constants import (INSECURE_DEVELOPMENT_PASSWORD, TEST_PROVIDER_URI, YES_ENTER)
from tests.constants import (
INSECURE_DEVELOPMENT_PASSWORD,
TEST_PROVIDER_URI,
YES_ENTER
)
ALTERNATE_REGISTRY_FILEPATH = '/tmp/nucypher-test-registry-alternate.json'
ALTERNATE_REGISTRY_FILEPATH_2 = '/tmp/nucypher-test-registry-alternate-2.json'
@pytest.fixture(autouse=True)
def monkeypatch_confirmations(testerchain, monkeypatch):
def monkey_block_until_enough_confirmations(client, transaction_hash, timeout, confirmations):
receipt = testerchain.wait_for_receipt(txhash=transaction_hash)
return receipt
monkeypatch.setattr(EthereumClient, 'block_until_enough_confirmations', monkey_block_until_enough_confirmations)
def test_nucypher_deploy_inspect_no_deployments(click_runner, testerchain, new_local_registry):
status_command = ('inspect',
@ -93,7 +97,7 @@ def test_nucypher_deploy_inspect_fully_deployed(click_runner, agency_local_regis
assert policy_agent.owner in result.output
assert adjudicator_agent.owner in result.output
minimum, default, maximum = 10, 10, 10 # TODO: Fix with skipped test see Issue #2314
minimum, default, maximum = 10, 10, 10
assert 'Range' in result.output
assert f"{minimum} wei" in result.output
assert f"{default} wei" in result.output
@ -184,7 +188,6 @@ def test_bare_contract_deployment_to_alternate_registry(click_runner, agency_loc
# TODO: test to validate retargetting via multisig, specifically, building the transaction
def test_manual_proxy_retargeting(monkeypatch, testerchain, click_runner, token_economics):
# A local, alternate filepath registry exists

View File

@ -20,6 +20,7 @@ import json
import os
import pytest
from nucypher.blockchain.eth.clients import EthereumClient
from nucypher.blockchain.eth.agents import (
MultiSigAgent
)