mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Fix unit test
This commit is contained in:
parent
4c64dcf201
commit
e765ccf303
2 changed files with 17 additions and 11 deletions
7
package-lock.json
generated
7
package-lock.json
generated
|
|
@ -294,8 +294,7 @@
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
"win32"
|
"win32"
|
||||||
],
|
]
|
||||||
"peer": true
|
|
||||||
},
|
},
|
||||||
"node_modules/@oxlint/darwin-arm64": {
|
"node_modules/@oxlint/darwin-arm64": {
|
||||||
"version": "1.22.0",
|
"version": "1.22.0",
|
||||||
|
|
@ -2096,10 +2095,10 @@
|
||||||
"aikido-npx": "bin/aikido-npx.js",
|
"aikido-npx": "bin/aikido-npx.js",
|
||||||
"aikido-pip": "bin/aikido-pip.js",
|
"aikido-pip": "bin/aikido-pip.js",
|
||||||
"aikido-pip3": "bin/aikido-pip3.js",
|
"aikido-pip3": "bin/aikido-pip3.js",
|
||||||
"aikido-python": "bin/aikido-python.js",
|
|
||||||
"aikido-python3": "bin/aikido-python3.js",
|
|
||||||
"aikido-pnpm": "bin/aikido-pnpm.js",
|
"aikido-pnpm": "bin/aikido-pnpm.js",
|
||||||
"aikido-pnpx": "bin/aikido-pnpx.js",
|
"aikido-pnpx": "bin/aikido-pnpx.js",
|
||||||
|
"aikido-python": "bin/aikido-python.js",
|
||||||
|
"aikido-python3": "bin/aikido-python3.js",
|
||||||
"aikido-yarn": "bin/aikido-yarn.js",
|
"aikido-yarn": "bin/aikido-yarn.js",
|
||||||
"safe-chain": "bin/safe-chain.js"
|
"safe-chain": "bin/safe-chain.js"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,24 @@ import { describe, it, before, after } from "node:test";
|
||||||
import assert from "node:assert";
|
import assert from "node:assert";
|
||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
||||||
import { join } from "node:path";
|
import { join, dirname } from "node:path";
|
||||||
import { homedir } from "node:os";
|
import { homedir } from "node:os";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
import { parseShellOutput } from "./parseShellOutput.js";
|
import { parseShellOutput } from "./parseShellOutput.js";
|
||||||
|
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const REPO_ROOT = join(__dirname, "../..");
|
||||||
|
|
||||||
const SAFE_CHAIN_BIN = join(
|
const SAFE_CHAIN_BIN = join(
|
||||||
process.cwd(),
|
REPO_ROOT,
|
||||||
"packages/safe-chain/bin/safe-chain.js"
|
"packages/safe-chain/bin/safe-chain.js"
|
||||||
);
|
);
|
||||||
const AIKIDO_NPM_BIN = join(
|
const AIKIDO_NPM_BIN = join(
|
||||||
process.cwd(),
|
REPO_ROOT,
|
||||||
"packages/safe-chain/bin/aikido-npm.js"
|
"packages/safe-chain/bin/aikido-npm.js"
|
||||||
);
|
);
|
||||||
const AIKIDO_PIP_BIN = join(
|
const AIKIDO_PIP_BIN = join(
|
||||||
process.cwd(),
|
REPO_ROOT,
|
||||||
"packages/safe-chain/bin/aikido-pip3.js"
|
"packages/safe-chain/bin/aikido-pip3.js"
|
||||||
);
|
);
|
||||||
const PROXY_STATE_FILE = join(homedir(), ".safe-chain/proxy-state.json");
|
const PROXY_STATE_FILE = join(homedir(), ".safe-chain/proxy-state.json");
|
||||||
|
|
@ -38,12 +42,15 @@ async function startAgentMode(args = []) {
|
||||||
const onData = (data) => {
|
const onData = (data) => {
|
||||||
output += data.toString();
|
output += data.toString();
|
||||||
|
|
||||||
|
// Strip ANSI color codes for parsing
|
||||||
|
const strippedOutput = output.replace(/\x1b\[[0-9;]*m/g, '');
|
||||||
|
|
||||||
// Look for port and pid - they might arrive in separate chunks
|
// Look for port and pid - they might arrive in separate chunks
|
||||||
const portMatch = output.match(/Port:\s+(\d+)/);
|
const portMatch = strippedOutput.match(/Port:\s+(\d+)/);
|
||||||
const pidMatch = output.match(/PID:\s+(\d+)/);
|
const pidMatch = strippedOutput.match(/PID:\s+(\d+)/);
|
||||||
|
|
||||||
// Also check for the success checkmark as confirmation
|
// Also check for the success checkmark as confirmation
|
||||||
const hasSuccess = output.includes("Safe Chain proxy started successfully");
|
const hasSuccess = strippedOutput.includes("Safe Chain proxy started successfully");
|
||||||
|
|
||||||
if (portMatch && pidMatch && hasSuccess && !hasResolved) {
|
if (portMatch && pidMatch && hasSuccess && !hasResolved) {
|
||||||
hasResolved = true;
|
hasResolved = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue