def test_rapid_deployment(): compiler = SolidityCompiler() registry = InMemoryEthereumContractRegistry() allocation_registry = InMemoryAllocationRegistry() interface = BlockchainDeployerInterface(compiler=compiler, registry=registry, provider_uri='tester://pyevm') blockchain = TesterBlockchain(interface=interface, airdrop=False, test_accounts=4) blockchain.ether_airdrop(amount=1000000000) origin, *everyone = blockchain.interface.w3.eth.accounts deployer = Deployer(blockchain=blockchain, deployer_address=origin) deployer_address, *all_yall = deployer.blockchain.interface.w3.eth.accounts # The Big Three (+ Dispatchers) deployer.deploy_network_contracts(miner_secret=os.urandom(32), policy_secret=os.urandom(32)) # User Escrow Proxy deployer.deploy_escrow_proxy(secret=os.urandom(32)) # Deploy User Escrow total_allocations = 100 # Start with some hard-coded cases... allocation_data = [{ 'address': all_yall[1], 'amount': MAX_ALLOWED_LOCKED, 'duration': ONE_YEAR_IN_SECONDS }, { 'address': all_yall[2], 'amount': MIN_ALLOWED_LOCKED, 'duration': ONE_YEAR_IN_SECONDS * 2 }, { 'address': all_yall[3], 'amount': MIN_ALLOWED_LOCKED * 100, 'duration': ONE_YEAR_IN_SECONDS * 3 }] # Pile on the rest for _ in range(total_allocations - 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(MIN_ALLOWED_LOCKED, MAX_ALLOWED_LOCKED) duration = random.randint(MIN_LOCKED_PERIODS, MAX_MINTING_PERIODS * 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 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 test_rapid_deployment(token_economics): compiler = SolidityCompiler() registry = InMemoryEthereumContractRegistry() allocation_registry = InMemoryAllocationRegistry() interface = BlockchainDeployerInterface(compiler=compiler, registry=registry, provider_uri='tester://pyevm') blockchain = TesterBlockchain(interface=interface, airdrop=False, test_accounts=4) deployer_address = blockchain.etherbase_account deployer = Deployer(blockchain=blockchain, deployer_address=deployer_address) # The Big Three (+ Dispatchers) deployer.deploy_network_contracts(miner_secret=MINERS_ESCROW_DEPLOYMENT_SECRET, policy_secret=POLICY_MANAGER_DEPLOYMENT_SECRET, adjudicator_secret=MINING_ADJUDICATOR_DEPLOYMENT_SECRET) # Deploy User Escrow, too (+ Linker) deployer.deploy_escrow_proxy(secret=USER_ESCROW_PROXY_DEPLOYMENT_SECRET) total_allocations = NUMBER_OF_ALLOCATIONS_IN_TESTS 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(total_allocations - 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 deployed_blockchain(): # # Interface # compiler = SolidityCompiler() registry = InMemoryEthereumContractRegistry() allocation_registry = InMemoryAllocationRegistry() interface = BlockchainDeployerInterface(compiler=compiler, registry=registry, provider_uri=TEST_PROVIDER_URI) # # Blockchain # blockchain = TesterBlockchain(interface=interface, airdrop=False, test_accounts=5, poa=True) blockchain.ether_airdrop(amount=TESTING_ETH_AIRDROP_AMOUNT) origin, *everyone = blockchain.interface.w3.eth.accounts # # Delpoyer # deployer = Deployer(blockchain=blockchain, deployer_address=origin) deployer_address, *all_yall = deployer.blockchain.interface.w3.eth.accounts # The Big Three (+ Dispatchers) deployer.deploy_network_contracts(miner_secret=os.urandom(32), policy_secret=os.urandom(32)) # User Escrow Proxy deployer.deploy_escrow_proxy(secret=os.urandom(32)) # Start with some hard-coded cases... allocation_data = [{ 'address': all_yall[1], 'amount': MAX_ALLOWED_LOCKED, 'duration': ONE_YEAR_IN_SECONDS }] deployer.deploy_beneficiary_contracts( allocations=allocation_data, allocation_registry=allocation_registry) yield blockchain, deployer_address, registry
def deployed_blockchain(token_economics): # Interface compiler = SolidityCompiler() registry = InMemoryEthereumContractRegistry() allocation_registry = InMemoryAllocationRegistry() interface = BlockchainDeployerInterface(compiler=compiler, registry=registry, provider_uri=TEST_PROVIDER_URI) # Blockchain blockchain = TesterBlockchain(interface=interface, airdrop=True, test_accounts=5, poa=True) deployer_address = blockchain.etherbase_account # Deployer deployer = Deployer(blockchain=blockchain, deployer_address=deployer_address) # The Big Three (+ Dispatchers) deployer.deploy_network_contracts(miner_secret=os.urandom(32), policy_secret=os.urandom(32), adjudicator_secret=os.urandom(32)) # User Escrow Proxy deployer.deploy_escrow_proxy(secret=os.urandom(32)) # Start with some hard-coded cases... all_yall = blockchain.unassigned_accounts allocation_data = [{ 'address': all_yall[1], 'amount': token_economics.maximum_allowed_locked, 'duration': ONE_YEAR_IN_SECONDS }] deployer.deploy_beneficiary_contracts( allocations=allocation_data, allocation_registry=allocation_registry) yield blockchain, deployer_address, registry