mirror of https://github.com/nucypher/nucypher.git
Refine upgradeability test
parent
af5bb16fab
commit
0a518df17a
|
@ -62,8 +62,7 @@ def compile_sources(source_bundle: SourceBundle, version_check: bool = True) ->
|
||||||
remappings_config = prepare_remappings_configuration(base_path=source_bundle.base_path)
|
remappings_config = prepare_remappings_configuration(base_path=source_bundle.base_path)
|
||||||
solc_configuration['settings'].update(remappings_config)
|
solc_configuration['settings'].update(remappings_config)
|
||||||
|
|
||||||
ignore_version_check: bool = not version_check
|
version: VersionString = VersionString(SOLIDITY_COMPILER_VERSION) if version_check else None
|
||||||
version: VersionString = VersionString(SOLIDITY_COMPILER_VERSION) if ignore_version_check else None
|
|
||||||
allow_paths = [source_bundle.base_path, *source_bundle.other_paths]
|
allow_paths = [source_bundle.base_path, *source_bundle.other_paths]
|
||||||
compiler_output = __execute(compiler_version=version, input_config=solc_configuration, allow_paths=allow_paths)
|
compiler_output = __execute(compiler_version=version, input_config=solc_configuration, allow_paths=allow_paths)
|
||||||
return compiler_output
|
return compiler_output
|
||||||
|
|
|
@ -14,8 +14,7 @@ GNU Affero General Public License for more details.
|
||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from typing import Dict, Optional, List
|
from typing import Dict, Optional, List
|
||||||
|
|
||||||
from nucypher.blockchain.eth.sol.compile.config import OPTIMIZER_RUNS
|
from nucypher.blockchain.eth.sol.compile.config import OPTIMIZER_RUNS
|
||||||
|
@ -36,14 +35,16 @@ def __execute(compiler_version: VersionString, input_config: Dict, allow_paths:
|
||||||
raise DevelopmentInstallationRequired(importable_name='solcx')
|
raise DevelopmentInstallationRequired(importable_name='solcx')
|
||||||
|
|
||||||
# Prepare Solc Command
|
# Prepare Solc Command
|
||||||
solc_binary_path: str = get_executable(version=compiler_version)
|
solc_binary_path: Path = get_executable(version=compiler_version)
|
||||||
SOLC_LOGGER.info(f"Compiling with base path") # TODO: Add base path
|
SOLC_LOGGER.info(f"Compiling with base path") # TODO: Add base path
|
||||||
|
|
||||||
_allow_paths = ',' + ','.join(str(p) for p in allow_paths)
|
_allow_paths = ',' + ','.join(str(p) for p in allow_paths)
|
||||||
|
|
||||||
# Execute Compilation
|
# Execute Compilation
|
||||||
try:
|
try:
|
||||||
compiler_output = compile_standard(input_data=input_config, allow_paths=_allow_paths)
|
compiler_output = compile_standard(input_data=input_config,
|
||||||
|
allow_paths=_allow_paths,
|
||||||
|
solc_binary=solc_binary_path)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
raise CompilationError("The solidity compiler is not at the specified path. "
|
raise CompilationError("The solidity compiler is not at the specified path. "
|
||||||
"Check that the file exists and is executable.")
|
"Check that the file exists and is executable.")
|
||||||
|
|
|
@ -19,18 +19,18 @@ import contextlib
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
|
||||||
import requests
|
import requests
|
||||||
from web3.exceptions import ValidationError
|
from web3.exceptions import ValidationError
|
||||||
|
|
||||||
from nucypher.blockchain.eth.deployers import AdjudicatorDeployer, BaseContractDeployer, NucypherTokenDeployer, \
|
from nucypher.blockchain.eth.deployers import AdjudicatorDeployer, BaseContractDeployer, NucypherTokenDeployer, \
|
||||||
PolicyManagerDeployer, StakingEscrowDeployer
|
PolicyManagerDeployer, StakingEscrowDeployer, WorklockDeployer
|
||||||
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface, BlockchainInterfaceFactory
|
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface, BlockchainInterfaceFactory
|
||||||
from nucypher.blockchain.eth.registry import InMemoryContractRegistry
|
from nucypher.blockchain.eth.registry import InMemoryContractRegistry
|
||||||
from nucypher.blockchain.eth.sol.compile.constants import SOLIDITY_SOURCE_ROOT
|
from nucypher.blockchain.eth.sol.compile.constants import SOLIDITY_SOURCE_ROOT
|
||||||
from nucypher.blockchain.eth.sol.compile.types import SourceBundle
|
from nucypher.blockchain.eth.sol.compile.types import SourceBundle
|
||||||
from nucypher.crypto.powers import TransactingPower
|
from nucypher.crypto.powers import TransactingPower
|
||||||
from tests.constants import INSECURE_DEVELOPMENT_PASSWORD
|
from tests.constants import INSECURE_DEVELOPMENT_PASSWORD
|
||||||
|
from tests.fixtures import make_token_economics
|
||||||
from tests.utils.blockchain import free_gas_price_strategy
|
from tests.utils.blockchain import free_gas_price_strategy
|
||||||
|
|
||||||
USER = "nucypher"
|
USER = "nucypher"
|
||||||
|
@ -97,8 +97,7 @@ def deploy_earliest_contract(blockchain_interface: BlockchainDeployerInterface,
|
||||||
pass # Skip errors related to initialization
|
pass # Skip errors related to initialization
|
||||||
|
|
||||||
|
|
||||||
# FIXME: Needs Completion
|
def test_upgradeability(temp_dir_path):
|
||||||
def test_upgradeability(temp_dir_path, token_economics):
|
|
||||||
# Prepare remote source for compilation
|
# Prepare remote source for compilation
|
||||||
download_github_dir(GITHUB_SOURCE_LINK, temp_dir_path)
|
download_github_dir(GITHUB_SOURCE_LINK, temp_dir_path)
|
||||||
|
|
||||||
|
@ -118,6 +117,8 @@ def test_upgradeability(temp_dir_path, token_economics):
|
||||||
blockchain_interface.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD, account=origin)
|
blockchain_interface.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD, account=origin)
|
||||||
blockchain_interface.transacting_power.activate()
|
blockchain_interface.transacting_power.activate()
|
||||||
|
|
||||||
|
economics = make_token_economics(blockchain_interface)
|
||||||
|
|
||||||
# Check contracts with multiple versions
|
# Check contracts with multiple versions
|
||||||
raw_contracts = blockchain_interface._raw_contract_cache
|
raw_contracts = blockchain_interface._raw_contract_cache
|
||||||
contract_name = AdjudicatorDeployer.contract_name
|
contract_name = AdjudicatorDeployer.contract_name
|
||||||
|
@ -133,22 +134,42 @@ def test_upgradeability(temp_dir_path, token_economics):
|
||||||
# Prepare master version of contracts and upgrade to the latest
|
# Prepare master version of contracts and upgrade to the latest
|
||||||
registry = InMemoryContractRegistry()
|
registry = InMemoryContractRegistry()
|
||||||
|
|
||||||
token_deployer = NucypherTokenDeployer(registry=registry, deployer_address=origin)
|
token_deployer = NucypherTokenDeployer(registry=registry,
|
||||||
|
deployer_address=origin,
|
||||||
|
economics=economics)
|
||||||
token_deployer.deploy()
|
token_deployer.deploy()
|
||||||
|
|
||||||
staking_escrow_deployer = StakingEscrowDeployer(registry=registry, deployer_address=origin)
|
staking_escrow_deployer = StakingEscrowDeployer(registry=registry,
|
||||||
|
deployer_address=origin,
|
||||||
|
economics=economics)
|
||||||
deploy_earliest_contract(blockchain_interface, staking_escrow_deployer)
|
deploy_earliest_contract(blockchain_interface, staking_escrow_deployer)
|
||||||
|
|
||||||
|
policy_manager_deployer = None
|
||||||
|
if test_staking_escrow or test_policy_manager:
|
||||||
|
policy_manager_deployer = PolicyManagerDeployer(registry=registry,
|
||||||
|
deployer_address=origin,
|
||||||
|
economics=economics)
|
||||||
|
deploy_earliest_contract(blockchain_interface, policy_manager_deployer)
|
||||||
|
|
||||||
|
adjudicator_deployer = None
|
||||||
|
if test_staking_escrow or test_adjudicator:
|
||||||
|
adjudicator_deployer = AdjudicatorDeployer(registry=registry,
|
||||||
|
deployer_address=origin,
|
||||||
|
economics=economics)
|
||||||
|
deploy_earliest_contract(blockchain_interface, adjudicator_deployer)
|
||||||
|
|
||||||
if test_staking_escrow:
|
if test_staking_escrow:
|
||||||
|
worklock_deployer = WorklockDeployer(registry=registry,
|
||||||
|
deployer_address=origin,
|
||||||
|
economics=economics)
|
||||||
|
worklock_deployer.deploy()
|
||||||
|
# TODO prepare at least one staker before calling upgrade
|
||||||
staking_escrow_deployer.upgrade(contract_version="latest", confirmations=0)
|
staking_escrow_deployer.upgrade(contract_version="latest", confirmations=0)
|
||||||
|
|
||||||
if test_policy_manager:
|
if test_policy_manager:
|
||||||
policy_manager_deployer = PolicyManagerDeployer(registry=registry, deployer_address=origin)
|
|
||||||
deploy_earliest_contract(blockchain_interface, policy_manager_deployer)
|
|
||||||
policy_manager_deployer.upgrade(contract_version="latest", confirmations=0)
|
policy_manager_deployer.upgrade(contract_version="latest", confirmations=0)
|
||||||
|
|
||||||
if test_adjudicator:
|
if test_adjudicator:
|
||||||
adjudicator_deployer = AdjudicatorDeployer(registry=registry, deployer_address=origin)
|
|
||||||
deploy_earliest_contract(blockchain_interface, adjudicator_deployer)
|
|
||||||
adjudicator_deployer.upgrade(contract_version="latest", confirmations=0)
|
adjudicator_deployer.upgrade(contract_version="latest", confirmations=0)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue