def another_testerchain(solidity_compiler): testerchain = _TesterBlockchain(eth_airdrop=True, free_transactions=True, light=True) testerchain.deployer_address = testerchain.etherbase_account assert testerchain.is_light yield testerchain
def test_rapid_deployment(token_economics): compiler = SolidityCompiler() allocation_registry = InMemoryAllocationRegistry() blockchain = _TesterBlockchain(eth_airdrop=False, test_accounts=4, compiler=compiler) # TODO: #1092 - TransactingPower blockchain.transacting_power = BlockchainPower( blockchain=blockchain, account=blockchain.etherbase_account) deployer_address = blockchain.etherbase_account deployer = Deployer(blockchain=blockchain, deployer_address=deployer_address) deployer.deploy_network_contracts( staker_secret=STAKING_ESCROW_DEPLOYMENT_SECRET, policy_secret=POLICY_MANAGER_DEPLOYMENT_SECRET, adjudicator_secret=ADJUDICATOR_DEPLOYMENT_SECRET, user_escrow_proxy_secret=USER_ESCROW_PROXY_DEPLOYMENT_SECRET) all_yall = blockchain.unassigned_accounts # Start with some hard-coded cases... allocation_data = [{ 'address': all_yall[1], 'amount': token_economics.maximum_allowed_locked, 'duration': ONE_YEAR_IN_SECONDS }, { 'address': all_yall[2], 'amount': token_economics.minimum_allowed_locked, 'duration': ONE_YEAR_IN_SECONDS * 2 }, { 'address': all_yall[3], 'amount': token_economics.minimum_allowed_locked * 100, 'duration': ONE_YEAR_IN_SECONDS * 3 }] # Pile on the rest for _ in range(NUMBER_OF_ALLOCATIONS_IN_TESTS - len(allocation_data)): random_password = ''.join( random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(16)) acct = w3.eth.account.create(random_password) beneficiary_address = acct.address amount = random.randint(token_economics.minimum_allowed_locked, token_economics.maximum_allowed_locked) duration = random.randint( token_economics.minimum_locked_periods * ONE_YEAR_IN_SECONDS, (token_economics.maximum_locked_periods * ONE_YEAR_IN_SECONDS) * 3) random_allocation = { 'address': beneficiary_address, 'amount': amount, 'duration': duration } allocation_data.append(random_allocation) deployer.deploy_beneficiary_contracts( allocations=allocation_data, allocation_registry=allocation_registry)
def make_testerchain(): # Create new blockchain testerchain = _TesterBlockchain(eth_airdrop=True, free_transactions=False) # Set the deployer address from a freshly created test account testerchain.deployer_address = testerchain.etherbase_account testerchain.transacting_power = TransactingPower(blockchain=testerchain, account=testerchain.etherbase_account) return testerchain
def test_rapid_deployment(token_economics, test_registry): compiler = SolidityCompiler() allocation_registry = InMemoryAllocationRegistry() blockchain = _TesterBlockchain(eth_airdrop=False, test_accounts=4, compiler=compiler) # TODO: #1092 - TransactingPower blockchain.transacting_power = TransactingPower(password=INSECURE_DEVELOPMENT_PASSWORD, account=blockchain.etherbase_account) blockchain.transacting_power.activate() deployer_address = blockchain.etherbase_account deployer = ContractAdministrator(deployer_address=deployer_address, registry=test_registry) secrets = dict() for deployer_class in deployer.upgradeable_deployer_classes: secrets[deployer_class.contract_name] = INSECURE_DEVELOPMENT_PASSWORD deployer.deploy_network_contracts(secrets=secrets, emitter=StdoutEmitter()) all_yall = blockchain.unassigned_accounts # Start with some hard-coded cases... allocation_data = [{'beneficiary_address': all_yall[1], 'amount': token_economics.maximum_allowed_locked, 'duration_seconds': ONE_YEAR_IN_SECONDS}, {'beneficiary_address': all_yall[2], 'amount': token_economics.minimum_allowed_locked, 'duration_seconds': ONE_YEAR_IN_SECONDS*2}, {'beneficiary_address': all_yall[3], 'amount': token_economics.minimum_allowed_locked*100, 'duration_seconds': ONE_YEAR_IN_SECONDS*3} ] # Pile on the rest for _ in range(NUMBER_OF_ALLOCATIONS_IN_TESTS - len(allocation_data)): random_password = ''.join(random.SystemRandom().choice(string.ascii_uppercase+string.digits) for _ in range(16)) acct = w3.eth.account.create(random_password) beneficiary_address = acct.address amount = random.randint(token_economics.minimum_allowed_locked, token_economics.maximum_allowed_locked) duration = random.randint(token_economics.minimum_locked_periods*ONE_YEAR_IN_SECONDS, (token_economics.maximum_rewarded_periods*ONE_YEAR_IN_SECONDS)*3) random_allocation = {'beneficiary_address': beneficiary_address, 'amount': amount, 'duration_seconds': duration} allocation_data.append(random_allocation) deployer.deploy_beneficiary_contracts(allocations=allocation_data, allocation_registry=allocation_registry, interactive=False)
def another_testerchain(solidity_compiler): testerchain = _TesterBlockchain(eth_airdrop=True, free_transactions=True) testerchain.deployer_address = testerchain.etherbase_account yield testerchain testerchain.disconnect()
def test_rapid_deployment(token_economics, test_registry, tmpdir, get_random_checksum_address): compiler = SolidityCompiler() blockchain = _TesterBlockchain(eth_airdrop=False, test_accounts=4, compiler=compiler) # TODO: #1092 - TransactingPower blockchain.transacting_power = TransactingPower( password=INSECURE_DEVELOPMENT_PASSWORD, account=blockchain.etherbase_account) blockchain.transacting_power.activate() deployer_address = blockchain.etherbase_account administrator = ContractAdministrator(deployer_address=deployer_address, registry=test_registry) administrator.deploy_network_contracts(emitter=StdoutEmitter()) all_yall = blockchain.unassigned_accounts # Start with some hard-coded cases... allocation_data = [ { 'checksum_address': all_yall[1], 'amount': token_economics.maximum_allowed_locked, 'lock_periods': token_economics.minimum_locked_periods }, { 'checksum_address': all_yall[2], 'amount': token_economics.minimum_allowed_locked, 'lock_periods': token_economics.minimum_locked_periods }, { 'checksum_address': all_yall[3], 'amount': token_economics.minimum_allowed_locked * 100, 'lock_periods': token_economics.minimum_locked_periods }, ] # Pile on the rest for _ in range(NUMBER_OF_ALLOCATIONS_IN_TESTS - len(allocation_data)): checksum_address = get_random_checksum_address() amount = random.randint(token_economics.minimum_allowed_locked, token_economics.maximum_allowed_locked) duration = random.randint(token_economics.minimum_locked_periods, token_economics.maximum_rewarded_periods) random_allocation = { 'checksum_address': checksum_address, 'amount': amount, 'lock_periods': duration } allocation_data.append(random_allocation) filepath = tmpdir / "allocations.json" with open(filepath, 'w') as f: json.dump(allocation_data, f) administrator.batch_deposits(allocation_data_filepath=str(filepath), interactive=False) minimum, default, maximum = 10, 20, 30 administrator.set_min_reward_rate_range(minimum, default, maximum)