def load_or_create_smoketest_config(): # get the contract and compiler (if available) versions versions = dict() for file in os.listdir(get_contract_path('')): if file.endswith('.sol'): versions[file] = contract_checksum(get_contract_path(file)) # if solc is available, record its version, too if get_solidity() is not None: solc_version_out, _ = subprocess.Popen( [get_solidity().compiler_available(), '--version'], stdout=subprocess.PIPE).communicate() versions['solc'] = solc_version_out.split()[-1] smoketest_config_path = os.path.join(get_project_root(), 'smoketest_config.json') # try to load an existing smoketest genesis config smoketest_config = dict() if os.path.exists(smoketest_config_path): with open(smoketest_config_path) as handler: smoketest_config = json.load(handler) # if the file versions still fit, return the genesis config (ignore solc if not available) if all(versions[key] == smoketest_config['versions'][key] for key in versions.keys()): return smoketest_config # something did not fit -- we will create the genesis smoketest_config['versions'] = versions raiden_config, smoketest_genesis = complete_genesis() smoketest_config['genesis'] = smoketest_genesis smoketest_config.update(raiden_config) with open(os.path.join(get_project_root(), 'smoketest_config.json'), 'w') as handler: json.dump(smoketest_config, handler) return smoketest_config
def load_or_create_smoketest_config(): # get the contract and compiler (if available) versions versions = dict() for file in os.listdir(get_contract_path('')): if file.endswith('.sol'): versions[file] = contract_checksum(get_contract_path(file)) # if solc is available, record its version, too if get_solidity() is not None: solc_version_out, _ = subprocess.Popen( [get_solidity().compiler_available(), '--version'], stdout=subprocess.PIPE ).communicate() versions['solc'] = solc_version_out.split()[-1].decode() smoketest_config_path = os.path.join( get_project_root(), 'smoketest_config.json' ) # try to load an existing smoketest genesis config smoketest_config = dict() if os.path.exists(smoketest_config_path): with open(smoketest_config_path) as handler: smoketest_config = json.load(handler) # if the file versions still fit, return the genesis config (ignore solc if not available) config_matches = [ versions[key] == smoketest_config['versions'][key] for key in versions.keys() ] if all(config_matches): return smoketest_config # something did not fit -- we will create the genesis smoketest_config['versions'] = versions raiden_config, smoketest_genesis = complete_genesis() smoketest_config['genesis'] = smoketest_genesis smoketest_config.update(raiden_config) with open(os.path.join(get_project_root(), 'smoketest_config.json'), 'w') as handler: json.dump(smoketest_config, handler) return smoketest_config