Merge commit integrating the deployer test fixes in an effort to get that green check.

pull/1741/head
jMyles 2020-08-31 15:31:53 -07:00
commit d2cb974bc1
11 changed files with 89 additions and 58 deletions

View File

@ -415,6 +415,15 @@ commands:
name: "Create directory for test reports"
command: mkdir reports
run_test_suite:
description: "Runs a group of tests, specified by name and contained in a file"
steps:
- run:
name: Running Test Suite
command: |
cat test-names.tmp | tr '\n' ' ' > test-names.txt
pytest -c .circleci/pytest.ini `cat test-names.txt`
prepare_dev_docker:
description: "access pre-build docker image"
steps:
@ -437,14 +446,12 @@ commands:
steps:
- store_test_results:
path: reports
- run:
name: Prepare test logs for storage as artifacts
command: |
mkdir -p ~/test-logs/
mv ~/.cache/nucypher/log/nucypher.log ~/test-logs/nucypher-container-$CIRCLE_NODE_INDEX.log
when: always
- store_artifacts:
path: ~/test-logs/
path: ~/.cache/nucypher/log/nucypher.log
destination: logs
- store_artifacts:
path: test-names.txt
destination: tests
- codecov
build_and_save_test_docker:
@ -517,9 +524,10 @@ jobs:
steps:
- prepare_environment
- run:
name: Integration Test Suite
name: Preparing Integration Test Suite
command: |
pytest -c .circleci/pytest.ini $(circleci tests glob "tests/integration/**/test_*.py" | circleci tests split --split-by=timings)
circleci tests glob "tests/integration/**/test_*.py" | circleci tests split --split-by=timings | tee test-names.tmp
- run_test_suite
- capture_test_results
unit:
@ -528,9 +536,10 @@ jobs:
steps:
- prepare_environment
- run:
name: Unit Test Suite
name: Preparing Unit Test Suite
command: |
pytest -c .circleci/pytest.ini $(circleci tests glob "tests/unit/**/test_*.py" | circleci tests split --split-by=timings)
circleci tests glob "tests/unit/**/test_*.py" | circleci tests split --split-by=timings | tee test-names.tmp
- run_test_suite
- capture_test_results
agents:
@ -539,9 +548,10 @@ jobs:
steps:
- prepare_environment
- run:
name: Blockchain Agent Tests
name: Preparing Blockchain Agent Tests
command: |
pytest -c .circleci/pytest.ini $(circleci tests glob "tests/acceptance/blockchain/agents/**/test_*.py" | circleci tests split --split-by=timings)
circleci tests glob "tests/acceptance/blockchain/agents/**/test_*.py" | circleci tests split --split-by=timings | tee test-names.tmp
- run_test_suite
- capture_test_results
actors:
@ -550,9 +560,10 @@ jobs:
steps:
- prepare_environment
- run:
name: Blockchain Actor Tests
name: Preparing Blockchain Actor Tests
command: |
pytest -c .circleci/pytest.ini $(circleci tests glob "tests/acceptance/blockchain/actors/**/test_*.py" | circleci tests split --split-by=timings)
circleci tests glob "tests/acceptance/blockchain/actors/**/test_*.py" | circleci tests split --split-by=timings | tee test-names.tmp
- run_test_suite
- capture_test_results
deployers:
@ -561,9 +572,10 @@ jobs:
steps:
- prepare_environment
- run:
name: Contract Deployer Tests
name: Preparing Contract Deployer Tests
command: |
pytest -c .circleci/pytest.ini $(circleci tests glob "tests/acceptance/blockchain/deployers/test_*.py" | circleci tests split --split-by=timings)
circleci tests glob "tests/acceptance/blockchain/deployers/test_*.py" | circleci tests split --split-by=timings | tee test-names.tmp
- run_test_suite
- capture_test_results
contracts:
@ -572,9 +584,10 @@ jobs:
steps:
- prepare_environment
- run:
name: Ethereum Contract Unit Tests
name: Preparing Ethereum Contract Unit Tests
command: |
pytest -c .circleci/pytest.ini $(circleci tests glob "tests/contracts/**/test_*.py" | circleci tests split --split-by=timings)
circleci tests glob "tests/contracts/**/test_*.py" | circleci tests split --split-by=timings | tee test-names.tmp
- run_test_suite
- capture_test_results
interfaces:
@ -583,9 +596,10 @@ jobs:
steps:
- prepare_environment
- run:
name: Tests for Blockhain interfaces, Crypto functions, Node Configuration and Datastore
name: Preparing Tests for Blockhain interfaces, Crypto functions, Node Configuration and Datastore
command: |
pytest -c .circleci/pytest.ini $(circleci tests glob "tests/acceptance/blockchain/interfaces" "tests/acceptance/blockchain/clients")
circleci tests glob "tests/acceptance/blockchain/interfaces" "tests/acceptance/blockchain/clients" | tee test-names.tmp
- run_test_suite
- capture_test_results
characters:
@ -594,9 +608,10 @@ jobs:
steps:
- prepare_environment
- run:
name: Character Tests
name: Preparing Character Tests
command: |
pytest -c .circleci/pytest.ini $(circleci tests glob "tests/acceptance/characters/**/test_*.py" "tests/learning/**/test_*.py" | circleci tests split --split-by=timings)
circleci tests glob "tests/acceptance/characters/**/test_*.py" "tests/learning/**/test_*.py" | circleci tests split --split-by=timings | tee test-names.tmp
- run_test_suite
- capture_test_results
cli:
@ -605,9 +620,10 @@ jobs:
steps:
- prepare_environment
- run:
name: Nucypher CLI Tests
name: Preparing Nucypher CLI Tests
command: |
pytest -c .circleci/pytest.ini $(circleci tests glob "tests/acceptance/cli/**/test_*.py" | circleci tests split --split-by=timings)
circleci tests glob "tests/acceptance/cli/**/test_*.py" | circleci tests split --split-by=timings | tee test-names.tmp
- run_test_suite
- capture_test_results
tests_ok:
@ -810,11 +826,6 @@ jobs:
pytest -c .circleci/pytest.ini --run-nightly --no-cov tests/acceptance/blockchain/agents/test_sampling_distribution.py
- store_test_results:
path: reports
- run:
name: Prepare test logs for storage as artifacts
command: |
mkdir -p ~/test-logs/
mv ~/.cache/nucypher/log/nucypher.log ~/test-logs/nucypher-container-$CIRCLE_NODE_INDEX.log
when: always
- store_artifacts:
path: ~/test-logs/
path: ~/.cache/nucypher/log/nucypher.log
destination: logs

View File

@ -20,7 +20,7 @@ All ``nucypher worklock`` commands share a similar structure:
.. code::
(nucypher)$ nucypher worklock <COMMAND> [OPTIONS] --network <NETWORK> --provider <YOUR PROVIDER URI>
(nucypher)$ nucypher worklock <COMMAND> [OPTIONS] --provider <YOUR PROVIDER URI>
Replace ``<YOUR PROVIDER URI>`` with a valid node web3 node provider string, for example:
@ -29,6 +29,9 @@ Replace ``<YOUR PROVIDER URI>`` with a valid node web3 node provider string, for
- ``https://<host>`` - HTTP(S)-based JSON-RPC server
- ``wss://<host>:8080`` - Websocket(Secure)-based JSON-RPC server
If you're using a network different than NuCypher ``mainnet`` (like for example our ``ibex`` testnet),
you can include the ``--network <NETWORK>`` option to any WorkLock command.
Show current WorkLock information
---------------------------------
@ -36,7 +39,7 @@ You can obtain information about the current state of WorkLock by running:
.. code::
(nucypher)$ nucypher worklock status --network <NETWORK> --provider <YOUR PROVIDER URI>
(nucypher)$ nucypher worklock status --provider <YOUR PROVIDER URI>
The following is an example output of the ``status`` command (hypothetical values):
@ -50,8 +53,6 @@ The following is an example output of the ``status`` command (hypothetical value
\ /\ /| (_) || | | < | |____| (_) || (__ | <
\/ \/ \___/ |_| |_|\_\\_____/ \___/ \___||_|\_\
══ <NETWORK> ══
Reading Latest Chaindata...
Time
@ -130,7 +131,7 @@ If you want to see specific information about your current escrow, you can speci
.. code::
(nucypher)$ nucypher worklock status --participant-address <YOUR PARTICIPANT ADDRESS> --network <NETWORK> --provider <YOUR PROVIDER URI>
(nucypher)$ nucypher worklock status --participant-address <YOUR PARTICIPANT ADDRESS> --provider <YOUR PROVIDER URI>
The following output is an example of what is included when ``--participant-address`` is used
@ -196,7 +197,7 @@ You can place an escrow to WorkLock by running:
.. code::
(nucypher)$ nucypher worklock escrow --network <NETWORK> --provider <YOUR PROVIDER URI>
(nucypher)$ nucypher worklock escrow --provider <YOUR PROVIDER URI>
Recall that there's a minimum escrow amount needed to participate in WorkLock.
@ -209,7 +210,7 @@ You can cancel an escrow to WorkLock by running:
.. code::
(nucypher)$ nucypher worklock cancel-escrow --network <NETWORK> --provider <YOUR PROVIDER URI>
(nucypher)$ nucypher worklock cancel-escrow --provider <YOUR PROVIDER URI>
Claim your stake
@ -219,14 +220,14 @@ Once the allocation window is open, you can claim your NU as a stake in NuCypher
.. code::
(nucypher)$ nucypher worklock claim --network <NETWORK> --provider <YOUR PROVIDER URI>
(nucypher)$ nucypher worklock claim --provider <YOUR PROVIDER URI>
Once allocated, you can check that the stake was created successfully by running:
.. code::
(nucypher)$ nucypher status stakers --staking-address <YOUR PARTICIPANT ADDRESS> --network {network} --provider <YOUR PROVIDER URI>
(nucypher)$ nucypher status stakers --staking-address <YOUR PARTICIPANT ADDRESS> --provider <YOUR PROVIDER URI>
Check remaining work
@ -236,7 +237,7 @@ If you have a stake created from WorkLock, you can check how much work is pendin
.. code::
(nucypher)$ nucypher worklock remaining-work --network <NETWORK> --provider <YOUR PROVIDER URI>
(nucypher)$ nucypher worklock remaining-work --provider <YOUR PROVIDER URI>
Refund locked ETH
@ -246,4 +247,4 @@ If you've committed some work, you are able to refund proportional part of ETH y
.. code::
(nucypher)$ nucypher worklock refund --network <NETWORK> --provider <YOUR PROVIDER URI>
(nucypher)$ nucypher worklock refund --provider <YOUR PROVIDER URI>

View File

@ -22,7 +22,7 @@ class NetworksInventory: # TODO: See #1564
IBEX = 'ibex'
UNKNOWN = 'unknown' # TODO: Is there a better way to signal an unknown network?
DEFAULT = UNKNOWN # TODO: This assumes we DON'T have a default. Is that OK? - #1496
DEFAULT = MAINNET
__to_ethereum_chain_id = {
MAINNET: 1, # Ethereum Mainnet

View File

@ -82,6 +82,7 @@ from nucypher.cli.options import (
option_etherscan,
option_force,
option_hw_wallet,
option_network,
option_poa,
option_provider_uri,
option_signer_uri
@ -110,7 +111,6 @@ option_registry_outfile = click.option('--registry-outfile', help="Output path f
option_target_address = click.option('--target-address', help="Address of the target contract", type=EIP55_CHECKSUM_ADDRESS)
option_gas = click.option('--gas', help="Operate with a specified gas per-transaction limit", type=click.IntRange(min=1))
option_gas_strategy = click.option('--gas-strategy', help="Operate with a specified gas price strategy", type=click.STRING) # TODO: GAS_STRATEGY_CHOICES
option_network = click.option('--network', help="Name of NuCypher network", type=click.Choice(NetworksInventory.NETWORKS))
option_ignore_deployed = click.option('--ignore-deployed', help="Ignore already deployed contracts if exist.", is_flag=True)
option_ignore_solidity_version = click.option('--ignore-solidity-check', help="Ignore solidity version compatibility check", is_flag=True)
@ -253,7 +253,7 @@ def deploy():
@group_general_config
@option_config_root
@option_registry_outfile
@option_network
@option_network(default=NetworksInventory.DEFAULT, validate=True) # TODO: See 2214
@option_force
def download_registry(general_config, config_root, registry_outfile, network, force):
"""Download the latest registry."""

View File

@ -25,6 +25,7 @@ from nucypher.blockchain.eth.constants import (
POLICY_MANAGER_CONTRACT_NAME,
STAKING_ESCROW_CONTRACT_NAME
)
from nucypher.blockchain.eth.networks import NetworksInventory
from nucypher.blockchain.eth.utils import datetime_at_period
from nucypher.cli.config import group_general_config
from nucypher.cli.options import (
@ -70,7 +71,7 @@ group_registry_options = group_options(
poa=option_poa,
light=option_light,
registry_filepath=option_registry_filepath,
network=option_network(),
network=option_network(default=NetworksInventory.DEFAULT, validate=True), # TODO: See 2214
provider_uri=option_provider_uri(default=os.environ.get(NUCYPHER_ENVVAR_PROVIDER_URI)),
)

View File

@ -24,6 +24,7 @@ from web3 import Web3
from nucypher.blockchain.eth.actors import Bidder
from nucypher.blockchain.eth.agents import ContractAgency, WorkLockAgent
from nucypher.blockchain.eth.networks import NetworksInventory
from nucypher.blockchain.eth.signers import Signer, ClefSigner
from nucypher.blockchain.eth.token import NU
from nucypher.blockchain.eth.utils import prettify_eth_amount
@ -143,7 +144,7 @@ group_worklock_options = group_options(
participant_address=option_bidder_address,
signer_uri=option_signer_uri,
provider_uri=option_provider_uri(required=True, default=os.environ.get(NUCYPHER_ENVVAR_PROVIDER_URI)),
network=option_network(required=True),
network=option_network(default=NetworksInventory.DEFAULT, validate=True), # TODO: See 2214
registry_filepath=option_registry_filepath,
)

View File

@ -22,10 +22,12 @@ import functools
import os
from nucypher.blockchain.eth.constants import NUCYPHER_CONTRACT_NAMES
from nucypher.blockchain.eth.networks import NetworksInventory
from nucypher.cli.types import (
EIP55_CHECKSUM_ADDRESS,
EXISTING_READABLE_FILE,
NETWORK_PORT,
NuCypherNetworkName,
WEI
)
from nucypher.utilities.logging import Logger
@ -97,11 +99,13 @@ def option_message_kit(required: bool = False):
required=required)
def option_network(required: bool = False, default=os.environ.get("NUCYPHER_NETWORK")):
def option_network(required: bool = False,
default: str = None, # TODO: NetworksInventory.DEFAULT is not a good default for the moment -- 2214
validate: bool = False):
return click.option(
'--network',
help="Nucypher Network/Domain Name",
type=click.STRING,
help="NuCypher Network/Domain Name",
type=NuCypherNetworkName(validate=validate),
required=required,
default=default)

View File

@ -84,8 +84,22 @@ class DecimalRange(DecimalType):
return rv
# NuCypher
NETWORK_DOMAIN = click.Choice(choices=NetworksInventory.NETWORKS)
class NuCypherNetworkName(click.ParamType):
name = 'nucypher_network_name'
def __init__(self, validate: bool = True):
self.validate = bool(validate)
def convert(self, value, param, ctx):
if self.validate:
network = str(value).lower()
if network not in NetworksInventory.NETWORKS:
self.fail(f"'{value}' is not a NuCypher Network. Valid options are: {list(NetworksInventory.NETWORKS)}")
else:
return network
else:
return value
# Ethereum
EIP55_CHECKSUM_ADDRESS = ChecksumAddress()

View File

@ -65,4 +65,4 @@ MAX_UPLOAD_CONTENT_LENGTH = 1024 * 50
# Dev Mode
TEMPORARY_DOMAIN = ":TEMPORARY_DOMAIN:" # for use with `--dev` node runtimes
TEMPORARY_DOMAIN = ":temporary-domain:" # for use with `--dev` node runtimes

View File

@ -18,7 +18,7 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
import pytest
from nucypher.blockchain.economics import EconomicsFactory
from nucypher.blockchain.economics import EconomicsFactory, BaseEconomics
from nucypher.blockchain.eth.agents import WorkLockAgent
from nucypher.blockchain.eth.constants import WORKLOCK_CONTRACT_NAME
from nucypher.blockchain.eth.deployers import WorklockDeployer
@ -49,7 +49,7 @@ def test_worklock_deployment(worklock_deployer,
# Ensure nucypher APIs implementing economics are usable without a worklock deployment.
economics = EconomicsFactory.retrieve_from_blockchain(registry=test_registry)
assert economics.bidding_start_date == NotImplemented
assert economics.bidding_start_date == BaseEconomics._default_bidding_start_date
# Deploy
assert worklock_deployer.contract_name == WORKLOCK_CONTRACT_NAME
@ -57,7 +57,7 @@ def test_worklock_deployment(worklock_deployer,
# Verify economics are updated
economics = EconomicsFactory.retrieve_from_blockchain(registry=test_registry)
assert economics.bidding_start_date != NotImplemented
assert economics.bidding_start_date != BaseEconomics._default_bidding_start_date
# deployment steps must match expected number of steps
steps = worklock_deployer.deployment_steps

View File

@ -69,7 +69,6 @@ def test_ursula_and_local_keystore_signer_integration(click_runner,
ursula_config_path = config_root_path / UrsulaConfiguration.generate_filename()
stakeholder_config_path = config_root_path / StakeHolderConfiguration.generate_filename()
worker_account, password, mock_keystore_path = mock_funded_account_password_keystore
mock_signer_uri = f'keystore:{mock_keystore_path}'
#
# Stakeholder Steps