示例#1
0
def overwrite_genesis_file(testnet_config: TestnetConfiguration,
                           nodes_config_folders):
    genesis = genesis_json.build(testnet_config)

    for index, config_folder in enumerate(nodes_config_folders):
        config = config_folder / 'genesis.json'
        utils.write_json_file(str(config), genesis)
示例#2
0
def overwrite_nodes_setup(testnet_config: TestnetConfiguration,
                          nodes_config_folders):
    nodes_setup = nodes_setup_json.build(testnet_config)

    for index, config_folder in enumerate(nodes_config_folders):
        config = config_folder / 'nodesSetup.json'
        utils.write_json_file(str(config), nodes_setup)
示例#3
0
def patch_node_config(testnet_config: TestnetConfiguration):
    for node_config in testnet_config.all_nodes_config_folders():
        config_file = node_config / 'config.toml'
        data = utils.read_toml_file(config_file)
        node_config_toml.patch(data, testnet_config)
        utils.write_toml_file(config_file, data)

        config_file = node_config / 'api.toml'
        data = utils.read_toml_file(config_file)
        node_config_toml.patch_api(data, testnet_config)
        utils.write_toml_file(config_file, data)

        genesis_smart_contracts_file = node_config / 'genesisSmartContracts.json'
        data = utils.read_json_file(genesis_smart_contracts_file)
        genesis_smart_contracts_json.patch(data, testnet_config)
        utils.write_json_file(genesis_smart_contracts_file, data)
示例#4
0
    def _patch_mandos_tests(self):
        test_dir_path = path.join(self.directory, "mandos")
        if not path.isdir(test_dir_path):
            return

        test_paths = [e for e in utils.list_files(test_dir_path, suffix=".json")]
        self._replace_in_files(
            test_paths,
            [
                (f"{self.template_name}.wasm", f"{self.project_name}.wasm")
            ]
        )

        for file in test_paths:
            data = utils.read_json_file(file)
            # Patch fields
            data["name"] = data.get("name", "").replace(self.template_name, self.project_name)
            utils.write_json_file(file, data)
示例#5
0
def write_file(data: Dict[str, Any]):
    utils.write_json_file(CONFIG_PATH, data)
示例#6
0
def _write_file(use_global: bool, data: Dict[str, Any]):
    filename = _get_filename(use_global)

    utils.write_json_file(filename, data)
示例#7
0
 def ensure_config_file(self):
     config_file = self.get_config_file()
     if not config_file.exists():
         utils.write_json_file(str(config_file), self.default_config())
         logger.info("created default configuration in elrond.json")