genlayer 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
 
2
2
 
3
+ ## 0.2.0 (2024-11-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * adding headless option to cli ([#128](https://github.com/yeagerai/genlayer-cli/issues/128)) ([d9bfbc2](https://github.com/yeagerai/genlayer-cli/commit/d9bfbc2dc2bcb8a4673f419d868f2c41d8396bd8))
9
+
10
+ ## 0.1.4 (2024-11-12)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * changing linux command to fix display issue and fixing waiting simulator issue ([#127](https://github.com/yeagerai/genlayer-cli/issues/127)) ([721eebf](https://github.com/yeagerai/genlayer-cli/commit/721eebfea758a0897f23afd60b5767c59d593eb1))
16
+
3
17
  ## 0.1.3 (2024-11-08)
4
18
 
5
19
  ## 0.1.2 (2024-11-08)
package/dist/index.js CHANGED
@@ -39699,7 +39699,7 @@ var {
39699
39699
  } = import_index.default;
39700
39700
 
39701
39701
  // package.json
39702
- var version = "0.1.3";
39702
+ var version = "0.2.0";
39703
39703
 
39704
39704
  // src/lib/config/text.ts
39705
39705
  var CLI_DESCRIPTION = "GenLayer CLI is a development environment for the GenLayer ecosystem. It allows developers to interact with the protocol by creating accounts, sending transactions, and working with Intelligent Contracts by testing, debugging, and deploying them.";
@@ -39764,10 +39764,10 @@ var v4_default = v4;
39764
39764
  var DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
39765
39765
  var DEFAULT_REPO_GH_URL = "https://github.com/yeagerai/genlayer-simulator.git";
39766
39766
  var DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX = "genlayer-simulator-";
39767
- var DEFAULT_RUN_SIMULATOR_COMMAND = (simulatorLocation) => ({
39768
- darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker compose build && docker compose up"'`,
39769
- win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker compose build && docker compose up && pause"`,
39770
- linux: `x-terminal-emulator -e bash -c 'cd ${simulatorLocation} && docker compose build && docker compose up; echo "Press enter to exit"; read'`
39767
+ var DEFAULT_RUN_SIMULATOR_COMMAND = (simulatorLocation, options) => ({
39768
+ darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker compose build && docker compose up ${options}"'`,
39769
+ win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker compose build && docker compose up && pause ${options}"`,
39770
+ linux: `nohup bash -c 'cd ${simulatorLocation} && docker compose build && docker compose up -d ${options}'`
39771
39771
  });
39772
39772
  var DEFAULT_PULL_OLLAMA_COMMAND = (simulatorLocation) => ({
39773
39773
  darwin: `cd ${simulatorLocation} && docker exec ollama ollama pull llama3`,
@@ -40418,8 +40418,10 @@ function sleep(millliseconds) {
40418
40418
  }
40419
40419
  var SimulatorService = class {
40420
40420
  constructor() {
40421
+ __publicField(this, "composeOptions");
40421
40422
  __publicField(this, "simulatorLocation");
40422
40423
  this.simulatorLocation = "";
40424
+ this.composeOptions = "";
40423
40425
  }
40424
40426
  setSimulatorLocation(location) {
40425
40427
  this.simulatorLocation = location;
@@ -40427,6 +40429,12 @@ var SimulatorService = class {
40427
40429
  getSimulatorLocation() {
40428
40430
  return this.simulatorLocation;
40429
40431
  }
40432
+ setComposeOptions(headless) {
40433
+ this.composeOptions = headless ? "--scale frontend=0" : "";
40434
+ }
40435
+ getComposeOptions() {
40436
+ return this.composeOptions;
40437
+ }
40430
40438
  readEnvConfigValue(key) {
40431
40439
  const envFilePath = path2.join(this.simulatorLocation, ".env");
40432
40440
  const envConfig = dotenv.parse(fs5.readFileSync(envFilePath, "utf8"));
@@ -40563,7 +40571,7 @@ var SimulatorService = class {
40563
40571
  });
40564
40572
  }
40565
40573
  runSimulator() {
40566
- const commandsByPlatform = DEFAULT_RUN_SIMULATOR_COMMAND(this.simulatorLocation);
40574
+ const commandsByPlatform = DEFAULT_RUN_SIMULATOR_COMMAND(this.simulatorLocation, this.getComposeOptions());
40567
40575
  return executeCommand(commandsByPlatform);
40568
40576
  }
40569
40577
  waitForSimulatorToBeReady() {
@@ -40572,7 +40580,7 @@ var SimulatorService = class {
40572
40580
  console.log("Waiting for the simulator to start up...");
40573
40581
  try {
40574
40582
  const response = yield rpcClient.request({ method: "ping", params: [] });
40575
- if (((_a = response == null ? void 0 : response.result) == null ? void 0 : _a.status) === "OK" || ((_c = (_b = response == null ? void 0 : response.result) == null ? void 0 : _b.data) == null ? void 0 : _c.status) === "OK") {
40583
+ if ((response == null ? void 0 : response.result) === "OK" || ((_a = response == null ? void 0 : response.result) == null ? void 0 : _a.status) === "OK" || ((_c = (_b = response == null ? void 0 : response.result) == null ? void 0 : _b.data) == null ? void 0 : _c.status) === "OK") {
40576
40584
  return { initialized: true };
40577
40585
  }
40578
40586
  if (retries > 0) {
@@ -43260,6 +43268,7 @@ function getVersionErrorMessage({ docker, node }) {
43260
43268
  function initAction(options, simulatorService) {
43261
43269
  return __async(this, null, function* () {
43262
43270
  simulatorService.setSimulatorLocation(options.location);
43271
+ simulatorService.setComposeOptions(options.headless);
43263
43272
  try {
43264
43273
  const requirementsInstalled = yield simulatorService.checkInstallRequirements();
43265
43274
  const requirementErrorMessage = getRequirementsErrorMessage(requirementsInstalled);
@@ -43413,7 +43422,9 @@ function initAction(options, simulatorService) {
43413
43422
  `GenLayer simulator initialized successfully! Go to ${simulatorService.getFrontendUrl()} in your browser to access it.`
43414
43423
  );
43415
43424
  try {
43416
- simulatorService.openFrontend();
43425
+ if (!options.headless) {
43426
+ yield simulatorService.openFrontend();
43427
+ }
43417
43428
  } catch (error) {
43418
43429
  console.error(error);
43419
43430
  }
@@ -43423,7 +43434,8 @@ function initAction(options, simulatorService) {
43423
43434
  // src/commands/general/start.ts
43424
43435
  function startAction(options, simulatorService) {
43425
43436
  return __async(this, null, function* () {
43426
- const { resetValidators, numValidators, branch, location } = options;
43437
+ const { resetValidators, numValidators, branch, location, headless } = options;
43438
+ simulatorService.setComposeOptions(headless);
43427
43439
  simulatorService.setSimulatorLocation(location);
43428
43440
  const restartValidatorsHintText = resetValidators ? `creating new ${numValidators} random validators` : "keeping the existing validators";
43429
43441
  console.log(`Starting GenLayer simulator ${restartValidatorsHintText}`);
@@ -43493,7 +43505,9 @@ function startAction(options, simulatorService) {
43493
43505
  `GenLayer simulator initialized successfully! Go to ${simulatorService.getFrontendUrl()} in your browser to access it.`
43494
43506
  );
43495
43507
  try {
43496
- yield simulatorService.openFrontend();
43508
+ if (!headless) {
43509
+ yield simulatorService.openFrontend();
43510
+ }
43497
43511
  } catch (error) {
43498
43512
  console.error(error);
43499
43513
  }
@@ -43502,8 +43516,8 @@ function startAction(options, simulatorService) {
43502
43516
 
43503
43517
  // src/commands/general/index.ts
43504
43518
  function initializeGeneralCommands(program2) {
43505
- program2.command("init").description("Initialize the GenLayer Environment").option("--numValidators <numValidators>", "Number of validators", "5").option("--branch <branch>", "Branch", "main").option("--location <folder>", "Location where it will be installed", process.cwd()).action((options) => initAction(options, simulator_default));
43506
- program2.command("up").description("Starts GenLayer's simulator").option("--reset-validators", "Remove all current validators and create new random ones", false).option("--numValidators <numValidators>", "Number of validators", "5").option("--branch <branch>", "Branch", "main").option("--location <folder>", "Location where it will be installed", process.cwd()).action((options) => startAction(options, simulator_default));
43519
+ program2.command("init").description("Initialize the GenLayer Environment").option("--numValidators <numValidators>", "Number of validators", "5").option("--branch <branch>", "Branch", "main").option("--location <folder>", "Location where it will be installed", process.cwd()).option("--headless", "Headless mode", false).action((options) => initAction(options, simulator_default));
43520
+ program2.command("up").description("Starts GenLayer's simulator").option("--reset-validators", "Remove all current validators and create new random ones", false).option("--numValidators <numValidators>", "Number of validators", "5").option("--branch <branch>", "Branch", "main").option("--location <folder>", "Location where it will be installed", process.cwd()).option("--headless", "Headless mode", false).action((options) => startAction(options, simulator_default));
43507
43521
  return program2;
43508
43522
  }
43509
43523
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genlayer",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "GenLayer Command Line Tool",
5
5
  "main": "src/index.ts",
6
6
  "bin": {
@@ -12,6 +12,7 @@ export function initializeGeneralCommands(program: Command) {
12
12
  .option("--numValidators <numValidators>", "Number of validators", "5")
13
13
  .option("--branch <branch>", "Branch", "main")
14
14
  .option("--location <folder>", "Location where it will be installed", process.cwd())
15
+ .option("--headless", "Headless mode", false)
15
16
  .action((options: InitActionOptions) => initAction(options, simulatorService));
16
17
 
17
18
  program
@@ -21,6 +22,7 @@ export function initializeGeneralCommands(program: Command) {
21
22
  .option("--numValidators <numValidators>", "Number of validators", "5")
22
23
  .option("--branch <branch>", "Branch", "main")
23
24
  .option("--location <folder>", "Location where it will be installed", process.cwd())
25
+ .option("--headless", "Headless mode", false)
24
26
  .action((options: StartActionOptions) => startAction(options, simulatorService));
25
27
 
26
28
  return program;
@@ -6,7 +6,7 @@ export interface InitActionOptions {
6
6
  numValidators: number;
7
7
  branch: string;
8
8
  location: string;
9
-
9
+ headless: boolean;
10
10
  }
11
11
 
12
12
  function getRequirementsErrorMessage({git, docker}: Record<string, boolean>): string {
@@ -38,9 +38,8 @@ function getVersionErrorMessage({docker, node}: Record<string, string>): string
38
38
  }
39
39
 
40
40
  export async function initAction(options: InitActionOptions, simulatorService: ISimulatorService) {
41
- // Update simulator location with user input
42
41
  simulatorService.setSimulatorLocation(options.location);
43
-
42
+ simulatorService.setComposeOptions(options.headless);
44
43
 
45
44
  // Check if requirements are installed
46
45
  try {
@@ -231,8 +230,9 @@ export async function initAction(options: InitActionOptions, simulatorService: I
231
230
  `GenLayer simulator initialized successfully! Go to ${simulatorService.getFrontendUrl()} in your browser to access it.`,
232
231
  );
233
232
  try {
234
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
235
- simulatorService.openFrontend();
233
+ if(!options.headless){
234
+ await simulatorService.openFrontend();
235
+ }
236
236
  } catch (error) {
237
237
  console.error(error);
238
238
  }
@@ -7,11 +7,13 @@ export interface StartActionOptions {
7
7
  numValidators: number;
8
8
  branch: string;
9
9
  location: string;
10
+ headless: boolean;
10
11
  }
11
12
 
12
13
  export async function startAction(options: StartActionOptions, simulatorService: ISimulatorService) {
13
- const {resetValidators, numValidators, branch, location} = options;
14
+ const {resetValidators, numValidators, branch, location, headless} = options;
14
15
  // Update simulator location with user input
16
+ simulatorService.setComposeOptions(headless);
15
17
  simulatorService.setSimulatorLocation(location);
16
18
 
17
19
 
@@ -100,7 +102,9 @@ export async function startAction(options: StartActionOptions, simulatorService:
100
102
  `GenLayer simulator initialized successfully! Go to ${simulatorService.getFrontendUrl()} in your browser to access it.`,
101
103
  );
102
104
  try {
103
- await simulatorService.openFrontend();
105
+ if(!headless) {
106
+ await simulatorService.openFrontend();
107
+ }
104
108
 
105
109
  } catch (error) {
106
110
  console.error(error);
@@ -1,10 +1,10 @@
1
1
  export const DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
2
2
  export const DEFAULT_REPO_GH_URL = "https://github.com/yeagerai/genlayer-simulator.git";
3
3
  export const DOCKER_IMAGES_AND_CONTAINERS_NAME_PREFIX = "genlayer-simulator-";
4
- export const DEFAULT_RUN_SIMULATOR_COMMAND = (simulatorLocation: string) => ({
5
- darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker compose build && docker compose up"'`,
6
- win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker compose build && docker compose up && pause"`,
7
- linux: `x-terminal-emulator -e bash -c 'cd ${simulatorLocation} && docker compose build && docker compose up; echo "Press enter to exit"; read'`,
4
+ export const DEFAULT_RUN_SIMULATOR_COMMAND = (simulatorLocation: string, options: string) => ({
5
+ darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker compose build && docker compose up ${options}"'`,
6
+ win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker compose build && docker compose up && pause ${options}"`,
7
+ linux: `nohup bash -c 'cd ${simulatorLocation} && docker compose build && docker compose up -d ${options}'`,
8
8
  });
9
9
  export const DEFAULT_PULL_OLLAMA_COMMAND = (simulatorLocation: string) => ({
10
10
  darwin: `cd ${simulatorLocation} && docker exec ollama ollama pull llama3`,
@@ -3,6 +3,8 @@ import {AiProviders} from "../config/simulator";
3
3
  export interface ISimulatorService {
4
4
  setSimulatorLocation(location: string): void;
5
5
  getSimulatorLocation(): string;
6
+ setComposeOptions(headless: boolean): void;
7
+ getComposeOptions(): string;
6
8
  checkInstallRequirements(): Promise<Record<string, boolean>>;
7
9
  checkVersionRequirements(): Promise<Record<string, string>>;
8
10
  downloadSimulator(branch?: string): Promise<DownloadSimulatorResultType>;
@@ -41,10 +41,12 @@ function sleep(millliseconds: number): Promise<void> {
41
41
  }
42
42
 
43
43
  export class SimulatorService implements ISimulatorService {
44
+ private composeOptions: string
44
45
  public simulatorLocation: string;
45
46
 
46
47
  constructor() {
47
48
  this.simulatorLocation = "";
49
+ this.composeOptions = "";
48
50
  }
49
51
 
50
52
  public setSimulatorLocation(location: string): void {
@@ -55,6 +57,14 @@ export class SimulatorService implements ISimulatorService {
55
57
  return this.simulatorLocation;
56
58
  }
57
59
 
60
+ public setComposeOptions(headless: boolean): void {
61
+ this.composeOptions = headless ? '--scale frontend=0' : '';
62
+ }
63
+
64
+ public getComposeOptions(): string {
65
+ return this.composeOptions;
66
+ }
67
+
58
68
  private readEnvConfigValue(key: string): string {
59
69
  const envFilePath = path.join(this.simulatorLocation, ".env");
60
70
  // Transform the config string to object
@@ -209,7 +219,7 @@ export class SimulatorService implements ISimulatorService {
209
219
  }
210
220
 
211
221
  public runSimulator(): Promise<{stdout: string; stderr: string}> {
212
- const commandsByPlatform = DEFAULT_RUN_SIMULATOR_COMMAND(this.simulatorLocation);
222
+ const commandsByPlatform = DEFAULT_RUN_SIMULATOR_COMMAND(this.simulatorLocation, this.getComposeOptions());
213
223
  return executeCommand(commandsByPlatform);
214
224
  }
215
225
 
@@ -221,7 +231,7 @@ export class SimulatorService implements ISimulatorService {
221
231
  const response = await rpcClient.request({method: "ping", params: []});
222
232
 
223
233
  //Compatibility with current simulator version
224
- if (response?.result?.status === "OK" || response?.result?.data?.status === "OK") {
234
+ if (response?.result === "OK" || response?.result?.status === "OK" || response?.result?.data?.status === "OK") {
225
235
  return { initialized: true };
226
236
  }
227
237
  if (retries > 0) {
@@ -7,7 +7,7 @@ import {mkdtempSync} from "fs";
7
7
  import {join} from "path";
8
8
 
9
9
  const tempDir = mkdtempSync(join(tmpdir(), "test-initAction-"));
10
- const defaultActionOptions = { numValidators: 5, branch: "main", location: tempDir };
10
+ const defaultActionOptions = { numValidators: 5, branch: "main", location: tempDir, headless: false };
11
11
 
12
12
  describe("init action", () => {
13
13
  let error: ReturnType<any>;
@@ -422,4 +422,4 @@ describe("init action", () => {
422
422
 
423
423
  expect(error).toHaveBeenCalledWith(errorMsg);
424
424
  });
425
- });
425
+ });
@@ -13,7 +13,8 @@ describe("startAction - Additional Tests", () => {
13
13
  resetValidators: false,
14
14
  numValidators: 5,
15
15
  branch: "main",
16
- location: ''
16
+ location: '',
17
+ headless: false,
17
18
  };
18
19
 
19
20
  beforeEach(() => {
@@ -29,6 +30,7 @@ describe("startAction - Additional Tests", () => {
29
30
  createRandomValidators: vi.fn().mockResolvedValue(undefined),
30
31
  openFrontend: vi.fn().mockResolvedValue(undefined),
31
32
  setSimulatorLocation: vi.fn().mockResolvedValue(undefined),
33
+ setComposeOptions: vi.fn(),
32
34
  getAiProvidersOptions: vi.fn(() => [
33
35
  { name: "Provider A", value: "providerA" },
34
36
  { name: "Provider B", value: "providerB" },
@@ -2,6 +2,9 @@ import { Command } from "commander";
2
2
  import { vi, describe, beforeEach, afterEach, test, expect } from "vitest";
3
3
  import { initializeGeneralCommands } from "../../src/commands/general";
4
4
  import { getCommand, getCommandOption } from "../utils";
5
+ import simulatorService from '../../src/lib/services/simulator'
6
+
7
+ const openFrontendSpy = vi.spyOn(simulatorService, "openFrontend");
5
8
 
6
9
  vi.mock("inquirer", () => ({
7
10
  prompt: vi.fn(() => {}),
@@ -71,6 +74,13 @@ describe("init command", () => {
71
74
  test("action is called", async () => {
72
75
  program.parse(["node", "test", "init"]);
73
76
  expect(action).toHaveBeenCalledTimes(1);
74
- expect(action).toHaveBeenCalledWith({ numValidators: "5", branch: "main", location: process.cwd() });
77
+ expect(action).toHaveBeenCalledWith({ numValidators: "5", branch: "main", location: process.cwd(), headless: false });
78
+ });
79
+
80
+ test("option --headless is accepted", async () => {
81
+ program.parse(["node", "test", "init", "--headless"]);
82
+ expect(action).toHaveBeenCalledTimes(1);
83
+ expect(action).toHaveBeenCalledWith({ numValidators: "5", branch: "main", location: process.cwd(), headless: true });
84
+ expect(openFrontendSpy).not.toHaveBeenCalled();
75
85
  });
76
86
  });
@@ -2,6 +2,9 @@ import { Command } from "commander";
2
2
  import { vi, describe, beforeEach, afterEach, test, expect } from "vitest";
3
3
  import { initializeGeneralCommands } from "../../src/commands/general";
4
4
  import { getCommand, getCommandOption } from "../utils";
5
+ import simulatorService from '../../src/lib/services/simulator'
6
+
7
+ const openFrontendSpy = vi.spyOn(simulatorService, "openFrontend");
5
8
 
6
9
  const action = vi.fn();
7
10
 
@@ -69,7 +72,7 @@ describe("up command", () => {
69
72
  test("action is called with default options", async () => {
70
73
  program.parse(["node", "test", "up"]);
71
74
  expect(action).toHaveBeenCalledTimes(1);
72
- expect(action).toHaveBeenCalledWith({ resetValidators: false, numValidators: "5", branch: "main", location: process.cwd() });
75
+ expect(action).toHaveBeenCalledWith({ resetValidators: false, numValidators: "5", branch: "main", location: process.cwd(), headless: false });
73
76
  });
74
77
 
75
78
  test("action is called with custom options", async () => {
@@ -82,6 +85,8 @@ describe("up command", () => {
82
85
  "10",
83
86
  "--branch",
84
87
  "development",
88
+ "--headless",
89
+ "true"
85
90
  ]);
86
91
  expect(action).toHaveBeenCalledTimes(1);
87
92
  expect(action).toHaveBeenCalledWith({
@@ -89,6 +94,8 @@ describe("up command", () => {
89
94
  numValidators: "10",
90
95
  branch: "development",
91
96
  location: process.cwd(),
97
+ headless: true,
92
98
  });
99
+ expect(openFrontendSpy).not.toHaveBeenCalled();
93
100
  });
94
101
  });
@@ -23,6 +23,7 @@ import {
23
23
  } from "../../src/lib/config/simulator";
24
24
  import { rpcClient } from "../../src/lib/clients/jsonRpcClient";
25
25
  import * as semver from "semver";
26
+ import {getCommandOption} from "@@/tests/utils";
26
27
 
27
28
 
28
29
  vi.mock("fs");
@@ -104,20 +105,27 @@ describe("SimulatorService - Basic Tests", () => {
104
105
  expect(fs.existsSync).toHaveBeenCalled();
105
106
  });
106
107
 
107
- test("should return initialized true when simulator responds with OK", async () => {
108
+ test("should return initialized true when simulator responds with OK (result.status = OK)", async () => {
108
109
  vi.mocked(rpcClient.request).mockResolvedValueOnce({ result: {status: 'OK'} });
109
110
  const result = await simulatorService.waitForSimulatorToBeReady(STARTING_TIMEOUT_ATTEMPTS);
110
111
  expect(result).toEqual({ initialized: true });
111
112
  expect(rpcClient.request).toHaveBeenCalledWith({ method: "ping", params: [] });
112
113
  });
113
114
 
114
- test("should return initialized true when simulator responds with OK (different json structure)", async () => {
115
+ test("should return initialized true when simulator responds with OK (result.data.status = OK)", async () => {
115
116
  vi.mocked(rpcClient.request).mockResolvedValueOnce({ result: {data: {status: 'OK'}} });
116
117
  const result = await simulatorService.waitForSimulatorToBeReady(STARTING_TIMEOUT_ATTEMPTS);
117
118
  expect(result).toEqual({ initialized: true });
118
119
  expect(rpcClient.request).toHaveBeenCalledWith({ method: "ping", params: [] });
119
120
  });
120
121
 
122
+ test("should return initialized true when simulator responds with OK (result = OK)", async () => {
123
+ vi.mocked(rpcClient.request).mockResolvedValueOnce({ result: 'OK' });
124
+ const result = await simulatorService.waitForSimulatorToBeReady(STARTING_TIMEOUT_ATTEMPTS);
125
+ expect(result).toEqual({ initialized: true });
126
+ expect(rpcClient.request).toHaveBeenCalledWith({ method: "ping", params: [] });
127
+ });
128
+
121
129
  test("should return initialized false with errorCode TIMEOUT after retries", async () => {
122
130
  vi.mocked(rpcClient.request).mockResolvedValue(undefined);
123
131
  const result = await simulatorService.waitForSimulatorToBeReady(1);
@@ -148,7 +156,20 @@ describe("SimulatorService - Basic Tests", () => {
148
156
  stderr: "",
149
157
  });
150
158
  const result = await simulatorService.runSimulator();
151
- const expectedCommand = DEFAULT_RUN_SIMULATOR_COMMAND("/mock/home/genlayer-simulator");
159
+ const expectedCommand = DEFAULT_RUN_SIMULATOR_COMMAND("/mock/home/genlayer-simulator", '');
160
+ expect(executeCommand).toHaveBeenCalledWith(expectedCommand);
161
+ expect(result).toEqual({ stdout: "Simulator started", stderr: "" });
162
+ });
163
+
164
+ test("should execute the correct run simulator command based on headless option", async () => {
165
+ (executeCommand as Mock).mockResolvedValue({
166
+ stdout: "Simulator started",
167
+ stderr: "",
168
+ });
169
+ simulatorService.setComposeOptions(true)
170
+ const commandOption = simulatorService.getComposeOptions();
171
+ const result = await simulatorService.runSimulator();
172
+ const expectedCommand = DEFAULT_RUN_SIMULATOR_COMMAND("/mock/home/genlayer-simulator", commandOption);
152
173
  expect(executeCommand).toHaveBeenCalledWith(expectedCommand);
153
174
  expect(result).toEqual({ stdout: "Simulator started", stderr: "" });
154
175
  });