def tester_chain(deploy_key, private_keys, tester_blockgas_limit): return create_tester_chain(deploy_key, private_keys, tester_blockgas_limit)
def deploy_and_open_channel_alloc(deployment_key): """ Compiles, deploys and dumps a minimal raiden smart contract environment for use in a genesis block. This will: - deploy the raiden Registry contract stack - deploy a token contract - open a channel for the TEST_ACCOUNT address - deploy the EndpointRegistry/discovery contract - register a known value for the TEST_ACCOUNT address - dump the complete state in a genesis['alloc'] compatible format - return the state dump and the contract addresses """ deployment_key_bin = unhexlify(deployment_key) state = create_tester_chain(deployment_key_bin, [deployment_key_bin], 6 * 10**6) registry_address = tester_deploy_contract( state, deployment_key_bin, 'Registry', get_contract_path('Registry.sol'), ) discovery_address = tester_deploy_contract( state, deployment_key_bin, 'EndpointRegistry', get_contract_path('EndpointRegistry.sol'), ) client = BlockChainServiceTesterMock( deployment_key_bin, state, ) registry = client.registry(registry_address) token_address = client.deploy_and_register_token( registry, 'HumanStandardToken', get_contract_path('HumanStandardToken.sol'), constructor_parameters=(100, 'smoketesttoken', 2, 'RST')) manager = registry.manager_by_token(token_address) assert manager.private_key == deployment_key_bin channel_address = manager.new_netting_channel( unhexlify(TEST_PARTNER_ADDRESS), 50) client.token(token_address).approve(channel_address, TEST_DEPOSIT_AMOUNT) channel = NettingChannelTesterMock(state, deployment_key_bin, channel_address) channel.deposit(TEST_DEPOSIT_AMOUNT) discovery = client.discovery(discovery_address) discovery.proxy.registerEndpoint(TEST_ENDPOINT) contracts = dict( registry_address=address_encoder(registry_address), token_address=address_encoder(token_address), discovery_address=address_encoder(discovery_address), channel_address=address_encoder(channel_address), ) alloc = dict() # preserve all accounts and contracts for address in state.head_state.to_dict().keys(): alloc[address] = state.head_state.account_to_dict(address) for account, content in alloc.items(): alloc[account]['storage'] = fix_tester_storage(content['storage']) return dict( alloc=alloc, contracts=contracts, )
def deploy_and_open_channel_alloc(deployment_key): """ Compiles, deploys and dumps a minimal raiden smart contract environment for use in a genesis block. This will: - deploy the raiden Registry contract stack - deploy a token contract - open a channel for the TEST_ACCOUNT address - deploy the EndpointRegistry/discovery contract - register a known value for the TEST_ACCOUNT address - dump the complete state in a genesis['alloc'] compatible format - return the state dump and the contract addresses """ deployment_key_bin = unhexlify(deployment_key) state = create_tester_chain( deployment_key_bin, [deployment_key_bin], 6 * 10 ** 6 ) registry_address = tester_deploy_contract( state, deployment_key_bin, 'Registry', get_contract_path('Registry.sol'), ) discovery_address = tester_deploy_contract( state, deployment_key_bin, 'EndpointRegistry', get_contract_path('EndpointRegistry.sol'), ) client = BlockChainServiceTesterMock( deployment_key_bin, state, ) registry = client.registry(registry_address) token_address = client.deploy_and_register_token( registry, 'HumanStandardToken', get_contract_path('HumanStandardToken.sol'), constructor_parameters=(100, 'smoketesttoken', 2, 'RST') ) manager = registry.manager_by_token(token_address) assert manager.private_key == deployment_key_bin channel_address = manager.new_netting_channel( unhexlify(TEST_PARTNER_ADDRESS), 50 ) client.token(token_address).approve(channel_address, TEST_DEPOSIT_AMOUNT) channel = NettingChannelTesterMock( state, deployment_key_bin, channel_address ) channel.deposit(TEST_DEPOSIT_AMOUNT) discovery = client.discovery(discovery_address) discovery.proxy.registerEndpoint(TEST_ENDPOINT) contracts = dict( registry_address=address_encoder(registry_address), token_address=address_encoder(token_address), discovery_address=address_encoder(discovery_address), channel_address=address_encoder(channel_address), ) alloc = dict() # preserve all accounts and contracts for address in state.head_state.to_dict().keys(): alloc[address] = state.head_state.account_to_dict(address) for account, content in alloc.items(): alloc[account]['storage'] = fix_tester_storage(content['storage']) return dict( alloc=alloc, contracts=contracts, )