def test_store_and_verify_services( fs_reload_deployer: FakeFilesystem, deployer: ContractDeployer, deployed_service_info: DeployedContracts, token_address: HexAddress, ) -> None: """ Store some service contract deployment information and verify them """ fs_reload_deployer.add_real_directory( contracts_precompiled_path(version=None).parent) deployed_contracts_info = deployed_service_info deployer.verify_service_contracts_deployment_data( token_address=token_address, deployed_contracts_info=deployed_contracts_info, user_deposit_whole_balance_limit=DEPOSIT_LIMIT, ) deployer.store_and_verify_deployment_info_services( token_address=token_address, deployed_contracts_info=deployed_contracts_info, user_deposit_whole_balance_limit=DEPOSIT_LIMIT, )
def test_deploy_script_service(web3: Web3, deployed_service_info: DeployedContracts, token_address: HexAddress) -> None: """ Run deploy_service_contracts() used in the deployment script This checks if deploy_service_contracts() works correctly in the happy case. """ gas_limit = 5860000 deployer = ContractDeployer(web3=web3, private_key=FAUCET_PRIVATE_KEY, gas_limit=gas_limit, gas_price=1, wait=10) token_supply = 10000000 assert isinstance(token_address, str) deposit_limit = token_supply // 2 deployed_service_contracts = deployed_service_info deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_service_contracts, ) with pytest.raises(RuntimeError): assert EMPTY_ADDRESS != token_address deployer.verify_service_contracts_deployment_data( token_address=EMPTY_ADDRESS, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_service_contracts, ) deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["contracts_version"] = "0.0.0" with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["chain_id"] = deployed_service_contracts["chain_id"] + 1 with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["contracts"][CONTRACT_SERVICE_REGISTRY][ "constructor_arguments"] = [EMPTY_ADDRESS] with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) original = deployed_info_fail["contracts"][CONTRACT_USER_DEPOSIT][ "constructor_arguments"] deployed_info_fail["contracts"][CONTRACT_USER_DEPOSIT][ "constructor_arguments"] += original with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["contracts"][CONTRACT_USER_DEPOSIT][ "constructor_arguments"][0] = EMPTY_ADDRESS with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["contracts"][CONTRACT_USER_DEPOSIT][ "constructor_arguments"][1] = (deposit_limit + 1) with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) original = deployed_info_fail["contracts"][CONTRACT_MONITORING_SERVICE][ "constructor_arguments"] deployed_info_fail["contracts"][CONTRACT_MONITORING_SERVICE][ "constructor_arguments"] += original with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["contracts"][CONTRACT_MONITORING_SERVICE][ "constructor_arguments"][0] = EMPTY_ADDRESS with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["contracts"][CONTRACT_MONITORING_SERVICE][ "constructor_arguments"][2] = EMPTY_ADDRESS with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["contracts"][CONTRACT_ONE_TO_N][ "constructor_arguments"][0] = EMPTY_ADDRESS with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["contracts"][CONTRACT_ONE_TO_N][ "constructor_arguments"][1] = EMPTY_ADDRESS with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) deployed_info_fail = deepcopy(deployed_service_contracts) original = deployed_info_fail["contracts"][CONTRACT_ONE_TO_N][ "constructor_arguments"] deployed_info_fail["contracts"][CONTRACT_ONE_TO_N][ "constructor_arguments"] += original with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) def test_missing_deployment(contract_name: str) -> None: deployed_info_fail = deepcopy(deployed_service_contracts) deployed_info_fail["contracts"][contract_name][ "address"] = EMPTY_ADDRESS with pytest.raises(RuntimeError): deployer.verify_service_contracts_deployment_data( token_address=token_address, user_deposit_whole_balance_limit=deposit_limit, deployed_contracts_info=deployed_info_fail, ) for contract_name in [ CONTRACT_SERVICE_REGISTRY, CONTRACT_MONITORING_SERVICE, CONTRACT_ONE_TO_N, CONTRACT_USER_DEPOSIT, ]: test_missing_deployment(contract_name)