diff --git a/package.json b/package.json index 82f42b61b..6b1c081a7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "zombie-net", + "name": "zombienet", "version": "0.0.1", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/configManager.ts b/src/configManager.ts index 10b27316c..785439549 100644 --- a/src/configManager.ts +++ b/src/configManager.ts @@ -14,7 +14,7 @@ export const RPC_HTTP_PORT = 9944; // The port substrate listens for p2p connections on export const P2P_PORT = 30333; -export const DEFAULT_GLOBAL_TIMEOUT = 300; // seconds +export const DEFAULT_GLOBAL_TIMEOUT = 1200; // 20 mins export const DEFAULT_INDIVIDUAL_TEST_TIMEOUT = 10; // seconds export const DEFAULT_COMMAND = "polkadot"; export const DEFAULT_IMAGE = "parity/substrate:latest"; @@ -233,6 +233,7 @@ export function generateNetworkSpec(config: LaunchConfig): ComputedNetwork { } networkSpec.types = config.types ? config.types : {}; + networkSpec.configBasePath = config.configBasePath; return networkSpec; } diff --git a/src/orchestrator.ts b/src/orchestrator.ts index 75095a24d..5a617fd57 100644 --- a/src/orchestrator.ts +++ b/src/orchestrator.ts @@ -35,7 +35,7 @@ import { } from "./utils"; import tmp from "tmp-promise"; import fs from "fs"; -import { resolve } from "path"; +import path, { resolve } from "path"; import { generateParachainFiles } from "./paras"; import { setupChainSpec } from "./providers/k8s"; import { getChainSpecRaw } from "./providers/k8s/chain-spec"; @@ -104,10 +104,8 @@ export async function start( fs.openSync(localMagicFilepath, "w"); const zombieWrapperLocalPath = `${tmpDir.path}/${ZOMBIE_WRAPPER}`; - await fs.promises.copyFile(zombieWrapperPath,zombieWrapperLocalPath); - - // const zombieWrapperContent = await fs.promises.readFile(zombieWrapperPath); - // await fs.promises.writeFile(zombieWrapperLocalPath, zombieWrapperContent); + const zombieWrapperContent = await fs.promises.readFile(zombieWrapperPath); + await fs.promises.writeFile(zombieWrapperLocalPath, zombieWrapperContent, {mode: 0o755 }); // Define chain name and file name to use. const chainSpecFileName = `${networkSpec.relaychain.chain}.json`; @@ -211,8 +209,20 @@ export async function start( let finalFilesToCopyToNode = filesToCopyToNodes; for (const override of node.overrides) { + // let check if local_path is full or relative + let local_real_path = ""; + if( fs.existsSync(override.local_path) ){ + local_real_path = override.local_path; + } else { + // check relative to config + local_real_path = path.join(networkSpec.configBasePath, override.local_path); + console.log(local_real_path); + if(! fs.existsSync(local_real_path)) throw new Error("Invalid override config, only fullpaths or relative paths (from the config) are allowed"); + } + + console.log('es: ' +local_real_path); finalFilesToCopyToNode.push({ - localFilePath: override.local_path, + localFilePath: local_real_path, remoteFilePath: `/cfg/${override.remote_name}` }); } diff --git a/src/types.d.ts b/src/types.d.ts index 8d4bc52c8..78fd393ba 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -11,6 +11,7 @@ export interface ComputedNetwork { }; parachains: Parachain[]; types: any; + configBasePath: string; } export interface Node { @@ -118,6 +119,7 @@ export interface LaunchConfig { relaychain: RelayChainConfig; parachains: ParachainConfig[]; types: any; + configBasePath: string; } export interface Settings { diff --git a/src/utils.ts b/src/utils.ts index ce70dbce1..e0f86f67b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -4,6 +4,7 @@ import { format } from "util"; import { LaunchConfig, Node } from "./types"; import toml from "toml"; import { getUniqueName, WAIT_UNTIL_SCRIPT_SUFIX } from "./configManager"; +import path from "path"; export async function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); @@ -68,6 +69,7 @@ export function filterConsole(excludePatterns: string[], options?: any) { } export function readNetworkConfig(filepath: string): LaunchConfig { + const configBasePath = path.dirname(filepath); let content = fs.readFileSync(filepath).toString(); let replacements = getReplacementInText(content); @@ -88,6 +90,8 @@ export function readNetworkConfig(filepath: string): LaunchConfig { ? JSON.parse(content) //require(filepath) : toml.parse(content); + + config.configBasePath = configBasePath; return config; }