def test_genesis(): for profile in ['frontier']: # fixme olympics config = dict(eth=dict()) # Set config values based on profile selection merge_dict(config, PROFILES[profile]) # Load genesis config update_config_from_genesis_json(config, config['eth']['genesis']) konfig.update_config_with_defaults( config, {'eth': { 'block': blocks.default_config }}) print config['eth'].keys() bc = config['eth']['block'] print bc.keys() env = Env(DB(), bc) genesis = blocks.genesis(env) print 'genesis.hash', genesis.hash.encode('hex') print 'expected', config['eth']['genesis_hash'] assert genesis.hash == config['eth']['genesis_hash'].decode('hex')
def app(ctx, profile, alt_config, config_values, data_dir, log_config, bootstrap_node, log_json, mining_pct, unlock, password): # configure logging slogging.configure(log_config, log_json=log_json) # data dir default or from cli option data_dir = data_dir or konfig.default_data_dir konfig.setup_data_dir(data_dir) # if not available, sets up data_dir and required config log.info('using data in', path=data_dir) # prepare configuration # config files only contain required config (privkeys) and config different from the default if alt_config: # specified config file config = konfig.load_config(alt_config) else: # load config from default or set data_dir config = konfig.load_config(data_dir) config['data_dir'] = data_dir # add default config konfig.update_config_with_defaults(config, konfig.get_default_config([EthApp] + services)) log.DEV("Move to EthApp.default_config") konfig.update_config_with_defaults(config, {'eth': {'block': blocks.default_config}}) # Set config values based on profile selection merge_dict(config, PROFILES[profile]) # override values with values from cmd line for config_value in config_values: try: konfig.set_config_param(config, config_value) # check if this is part of the default config if config_value.startswith("eth.genesis"): del config['eth']['genesis_hash'] except ValueError: raise BadParameter('Config parameter must be of the form "a.b.c=d" where "a.b.c" ' 'specifies the parameter to set and d is a valid yaml value ' '(example: "-c jsonrpc.port=5000")') # Load genesis config update_config_from_genesis_json(config, config['eth']['genesis']) if bootstrap_node: config['discovery']['bootstrap_nodes'] = [bytes(bootstrap_node)] if mining_pct > 0: config['pow']['activated'] = True config['pow']['cpu_pct'] = int(min(100, mining_pct)) if not config['pow']['activated']: config['deactivated_services'].append(PoWService.name) ctx.obj = {'config': config, 'unlock': unlock, 'password': password.read().rstrip() if password else None} assert (password and ctx.obj['password'] is not None and len( ctx.obj['password'])) or not password, "empty password file"
def test_genesis(): for profile in ['frontier']: # fixme olympics config = dict(eth=dict()) # Set config values based on profile selection merge_dict(config, PROFILES[profile]) # Load genesis config update_config_from_genesis_json(config, config['eth']['genesis']) konfig.update_config_with_defaults(config, {'eth': {'block': blocks.default_config}}) print config['eth'].keys() bc = config['eth']['block'] print bc.keys() env = Env(DB(), bc) genesis = blocks.genesis(env) print 'genesis.hash', genesis.hash.encode('hex') print 'expected', config['eth']['genesis_hash'] assert genesis.hash == config['eth']['genesis_hash'].decode('hex')
def app(ctx, profile, alt_config, config_values, data_dir, log_config, bootstrap_node, log_json, mining_pct, unlock, password): # configure logging slogging.configure(log_config, log_json=log_json) # data dir default or from cli option data_dir = data_dir or konfig.default_data_dir konfig.setup_data_dir( data_dir) # if not available, sets up data_dir and required config log.info('using data in', path=data_dir) # prepare configuration # config files only contain required config (privkeys) and config different from the default if alt_config: # specified config file config = konfig.load_config(alt_config) else: # load config from default or set data_dir config = konfig.load_config(data_dir) config['data_dir'] = data_dir # add default config konfig.update_config_with_defaults( config, konfig.get_default_config([EthApp] + services)) log.DEV("Move to EthApp.default_config") konfig.update_config_with_defaults( config, {'eth': { 'block': blocks.default_config }}) # Set config values based on profile selection merge_dict(config, PROFILES[profile]) # override values with values from cmd line for config_value in config_values: try: konfig.set_config_param(config, config_value) # check if this is part of the default config if config_value.startswith("eth.genesis"): del config['eth']['genesis_hash'] except ValueError: raise BadParameter( 'Config parameter must be of the form "a.b.c=d" where "a.b.c" ' 'specifies the parameter to set and d is a valid yaml value ' '(example: "-c jsonrpc.port=5000")') # Load genesis config update_config_from_genesis_json(config, config['eth']['genesis']) if bootstrap_node: config['discovery']['bootstrap_nodes'] = [bytes(bootstrap_node)] if mining_pct > 0: config['pow']['activated'] = True config['pow']['cpu_pct'] = int(min(100, mining_pct)) if not config['pow']['activated']: config['deactivated_services'].append(PoWService.name) ctx.obj = { 'config': config, 'unlock': unlock, 'password': password.read().rstrip() if password else None } assert (password and ctx.obj['password'] is not None and len( ctx.obj['password'])) or not password, "empty password file"