genlayer 0.12.1 → 0.12.2-beta.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/.github/workflows/publish-beta.yml +2 -2
- package/.github/workflows/publish.yml +2 -2
- package/.github/workflows/validate-code.yml +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/index.js +24736 -108331
- package/docker-compose.yml +1 -1
- package/esbuild.config.dev.js +18 -0
- package/esbuild.config.js +10 -5
- package/esbuild.config.prod.js +16 -0
- package/eslint.config.js +59 -0
- package/package.json +12 -9
- package/scripts/postinstall.js +10 -6
- package/src/commands/config/getSetReset.ts +25 -18
- package/src/commands/contracts/deploy.ts +105 -25
- package/src/commands/contracts/index.ts +5 -1
- package/src/commands/general/index.ts +10 -4
- package/src/commands/general/init.ts +136 -189
- package/src/commands/general/start.ts +76 -77
- package/src/commands/general/stop.ts +6 -5
- package/src/commands/keygen/create.ts +9 -11
- package/src/commands/update/index.ts +3 -8
- package/src/commands/update/ollama.ts +56 -56
- package/src/commands/validators/validators.ts +48 -55
- package/src/lib/actions/BaseAction.ts +75 -4
- package/src/lib/config/simulator.ts +1 -1
- package/src/lib/services/simulator.ts +3 -2
- package/tests/actions/create.test.ts +18 -30
- package/tests/actions/deploy.test.ts +200 -30
- package/tests/actions/getSetReset.test.ts +29 -42
- package/tests/actions/init.test.ts +240 -475
- package/tests/actions/ollama.test.ts +40 -55
- package/tests/actions/start.test.ts +107 -108
- package/tests/actions/stop.test.ts +23 -4
- package/tests/actions/validators.test.ts +273 -142
- package/tests/commands/call.test.ts +4 -1
- package/tests/commands/deploy.test.ts +11 -0
- package/tests/commands/init.test.ts +11 -12
- package/tests/commands/up.test.ts +31 -23
- package/tests/commands/update.test.ts +2 -5
- package/tests/libs/baseAction.test.ts +175 -0
- package/tests/services/simulator.test.ts +15 -0
- package/.eslintrc.js +0 -58
- package/esbuild.config.dev +0 -16
- package/esbuild.config.prod +0 -16
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import { CallAction } from "../../src/commands/contracts/call";
|
|
2
3
|
import { vi, describe, beforeEach, afterEach, test, expect } from "vitest";
|
|
3
4
|
import { initializeContractsCommands } from "../../src/commands/contracts";
|
|
4
|
-
import { CallAction } from "../../src/commands/contracts/call";
|
|
5
5
|
|
|
6
6
|
vi.mock("../../src/commands/contracts/call");
|
|
7
|
+
vi.mock("esbuild", () => ({
|
|
8
|
+
buildSync: vi.fn(),
|
|
9
|
+
}));
|
|
7
10
|
|
|
8
11
|
describe("call command", () => {
|
|
9
12
|
let program: Command;
|
|
@@ -4,6 +4,9 @@ import { initializeContractsCommands } from "../../src/commands/contracts";
|
|
|
4
4
|
import { DeployAction } from "../../src/commands/contracts/deploy";
|
|
5
5
|
|
|
6
6
|
vi.mock("../../src/commands/contracts/deploy");
|
|
7
|
+
vi.mock("esbuild", () => ({
|
|
8
|
+
buildSync: vi.fn(),
|
|
9
|
+
}));
|
|
7
10
|
|
|
8
11
|
describe("deploy command", () => {
|
|
9
12
|
let program: Command;
|
|
@@ -66,4 +69,12 @@ describe("deploy command", () => {
|
|
|
66
69
|
program.parse(["node", "test", "deploy", "--contract", "./path/to/contract"])
|
|
67
70
|
).not.toThrow();
|
|
68
71
|
});
|
|
72
|
+
|
|
73
|
+
test("DeployAction.deployScripts is called without throwing errors", async () => {
|
|
74
|
+
program.parse(["node", "test", "deploy"]);
|
|
75
|
+
vi.mocked(DeployAction.prototype.deployScripts).mockResolvedValueOnce(undefined);
|
|
76
|
+
expect(() =>
|
|
77
|
+
program.parse(["node", "test", "deploy"])
|
|
78
|
+
).not.toThrow();
|
|
79
|
+
});
|
|
69
80
|
});
|
|
@@ -4,6 +4,11 @@ import { initializeGeneralCommands } from "../../src/commands/general";
|
|
|
4
4
|
import { getCommand, getCommandOption } from "../utils";
|
|
5
5
|
import simulatorService from '../../src/lib/services/simulator'
|
|
6
6
|
import {localnetCompatibleVersion} from "../../src/lib/config/simulator";
|
|
7
|
+
import { InitAction } from "../../src/commands/general/init";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
vi.mock("../../src/commands/general/init");
|
|
11
|
+
|
|
7
12
|
|
|
8
13
|
const openFrontendSpy = vi.spyOn(simulatorService, "openFrontend");
|
|
9
14
|
const defaultOptions = {
|
|
@@ -17,8 +22,6 @@ vi.mock("inquirer", () => ({
|
|
|
17
22
|
prompt: vi.fn(() => {}),
|
|
18
23
|
}));
|
|
19
24
|
|
|
20
|
-
const action = vi.fn();
|
|
21
|
-
|
|
22
25
|
describe("init command", () => {
|
|
23
26
|
let initCommand: Command;
|
|
24
27
|
let program: Command;
|
|
@@ -28,10 +31,6 @@ describe("init command", () => {
|
|
|
28
31
|
initializeGeneralCommands(program);
|
|
29
32
|
|
|
30
33
|
initCommand = getCommand(program, "init");
|
|
31
|
-
initCommand?.action(async (args) => {
|
|
32
|
-
action(args);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
34
|
vi.clearAllMocks();
|
|
36
35
|
});
|
|
37
36
|
|
|
@@ -65,21 +64,21 @@ describe("init command", () => {
|
|
|
65
64
|
|
|
66
65
|
test("action is called", async () => {
|
|
67
66
|
program.parse(["node", "test", "init"]);
|
|
68
|
-
expect(
|
|
69
|
-
expect(
|
|
67
|
+
expect(InitAction).toHaveBeenCalledTimes(1);
|
|
68
|
+
expect(InitAction.prototype.execute).toHaveBeenCalledWith(defaultOptions);
|
|
70
69
|
});
|
|
71
70
|
|
|
72
71
|
test("option --headless is accepted", async () => {
|
|
73
72
|
program.parse(["node", "test", "init", "--headless"]);
|
|
74
|
-
expect(
|
|
75
|
-
expect(
|
|
73
|
+
expect(InitAction).toHaveBeenCalledTimes(1);
|
|
74
|
+
expect(InitAction.prototype.execute).toHaveBeenCalledWith({...defaultOptions, headless: true});
|
|
76
75
|
expect(openFrontendSpy).not.toHaveBeenCalled();
|
|
77
76
|
});
|
|
78
77
|
|
|
79
78
|
test("option --localnet-version is accepted", async () => {
|
|
80
79
|
program.parse(["node", "test", "init", "--localnet-version", "v1.0.0"]);
|
|
81
|
-
expect(
|
|
82
|
-
expect(
|
|
80
|
+
expect(InitAction).toHaveBeenCalledTimes(1);
|
|
81
|
+
expect(InitAction.prototype.execute).toHaveBeenCalledWith({...defaultOptions, localnetVersion: "v1.0.0"});
|
|
83
82
|
expect(openFrontendSpy).not.toHaveBeenCalled();
|
|
84
83
|
});
|
|
85
84
|
});
|
|
@@ -2,17 +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
|
|
5
|
+
import { StartAction } from "../../src/commands/general/start";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const action = vi.fn();
|
|
10
|
-
const defaultOptions = {
|
|
11
|
-
resetValidators: false,
|
|
12
|
-
numValidators: "5",
|
|
13
|
-
headless: false ,
|
|
14
|
-
resetDb: false
|
|
15
|
-
}
|
|
7
|
+
vi.mock("../../src/commands/general/start");
|
|
16
8
|
|
|
17
9
|
describe("up command", () => {
|
|
18
10
|
let upCommand: Command;
|
|
@@ -23,10 +15,6 @@ describe("up command", () => {
|
|
|
23
15
|
initializeGeneralCommands(program);
|
|
24
16
|
|
|
25
17
|
upCommand = getCommand(program, "up");
|
|
26
|
-
upCommand?.action(async (args) => {
|
|
27
|
-
action(args);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
18
|
vi.clearAllMocks();
|
|
31
19
|
});
|
|
32
20
|
|
|
@@ -36,6 +24,15 @@ describe("up command", () => {
|
|
|
36
24
|
|
|
37
25
|
test("doesn't require arguments or options", async () => {
|
|
38
26
|
expect(() => program.parse(["node", "test", "up"])).not.toThrow();
|
|
27
|
+
expect(StartAction).toHaveBeenCalledTimes(1);
|
|
28
|
+
expect(StartAction.prototype.execute).toHaveBeenCalledWith(
|
|
29
|
+
expect.objectContaining({
|
|
30
|
+
resetValidators: false,
|
|
31
|
+
numValidators: "5",
|
|
32
|
+
headless: false,
|
|
33
|
+
resetDb: false,
|
|
34
|
+
})
|
|
35
|
+
);
|
|
39
36
|
});
|
|
40
37
|
|
|
41
38
|
test("option --reset-validators is accepted", async () => {
|
|
@@ -56,7 +53,6 @@ describe("up command", () => {
|
|
|
56
53
|
expect(numValidatorsOption?.defaultValue).toBe("5");
|
|
57
54
|
});
|
|
58
55
|
|
|
59
|
-
|
|
60
56
|
test("unrecognized option is not accepted", async () => {
|
|
61
57
|
upCommand?.exitOverride();
|
|
62
58
|
expect(() => program.parse(["node", "test", "up", "-unknown"])).toThrowError(
|
|
@@ -69,8 +65,15 @@ describe("up command", () => {
|
|
|
69
65
|
|
|
70
66
|
test("action is called with default options", async () => {
|
|
71
67
|
program.parse(["node", "test", "up"]);
|
|
72
|
-
expect(
|
|
73
|
-
expect(
|
|
68
|
+
expect(StartAction).toHaveBeenCalledTimes(1);
|
|
69
|
+
expect(StartAction.prototype.execute).toHaveBeenCalledWith(
|
|
70
|
+
expect.objectContaining({
|
|
71
|
+
resetValidators: false,
|
|
72
|
+
numValidators: "5",
|
|
73
|
+
headless: false,
|
|
74
|
+
resetDb: false,
|
|
75
|
+
})
|
|
76
|
+
);
|
|
74
77
|
});
|
|
75
78
|
|
|
76
79
|
test("action is called with custom options", async () => {
|
|
@@ -82,12 +85,17 @@ describe("up command", () => {
|
|
|
82
85
|
"--numValidators",
|
|
83
86
|
"10",
|
|
84
87
|
"--headless",
|
|
85
|
-
"
|
|
86
|
-
"--reset-db",
|
|
87
|
-
"true"
|
|
88
|
+
"--reset-db"
|
|
88
89
|
]);
|
|
89
|
-
|
|
90
|
-
expect(
|
|
91
|
-
expect(
|
|
90
|
+
|
|
91
|
+
expect(StartAction).toHaveBeenCalledTimes(1);
|
|
92
|
+
expect(StartAction.prototype.execute).toHaveBeenCalledWith(
|
|
93
|
+
expect.objectContaining({
|
|
94
|
+
resetValidators: true,
|
|
95
|
+
numValidators: "10",
|
|
96
|
+
headless: true,
|
|
97
|
+
resetDb: true,
|
|
98
|
+
})
|
|
99
|
+
);
|
|
92
100
|
});
|
|
93
101
|
});
|
|
@@ -2,10 +2,8 @@ import { Command } from "commander";
|
|
|
2
2
|
import { vi, describe, beforeEach, afterEach, test, expect } from "vitest";
|
|
3
3
|
import { initializeUpdateCommands } from "../../src/commands/update";
|
|
4
4
|
import { OllamaAction } from "../../src/commands/update/ollama";
|
|
5
|
-
import { ConfigFileManager } from "../../src/lib/config/ConfigFileManager";
|
|
6
5
|
|
|
7
6
|
vi.mock("../../src/commands/update/ollama");
|
|
8
|
-
vi.mock("../../src/lib/config/ConfigFileManager");
|
|
9
7
|
|
|
10
8
|
describe("ollama command", () => {
|
|
11
9
|
let program: Command;
|
|
@@ -15,7 +13,6 @@ describe("ollama command", () => {
|
|
|
15
13
|
initializeUpdateCommands(program);
|
|
16
14
|
|
|
17
15
|
const mockConfig = { defaultOllamaModel: "default-model" };
|
|
18
|
-
vi.mocked(ConfigFileManager.prototype.getConfig).mockReturnValue(mockConfig);
|
|
19
16
|
});
|
|
20
17
|
|
|
21
18
|
afterEach(() => {
|
|
@@ -31,7 +28,7 @@ describe("ollama command", () => {
|
|
|
31
28
|
test("OllamaAction.updateModel is called with default model", async () => {
|
|
32
29
|
program.parse(["node", "test", "update", "ollama"]);
|
|
33
30
|
expect(OllamaAction).toHaveBeenCalledTimes(1);
|
|
34
|
-
expect(OllamaAction.prototype.updateModel).toHaveBeenCalledWith("
|
|
31
|
+
expect(OllamaAction.prototype.updateModel).toHaveBeenCalledWith("");
|
|
35
32
|
});
|
|
36
33
|
|
|
37
34
|
test("OllamaAction.removeModel is called with model option", async () => {
|
|
@@ -43,6 +40,6 @@ describe("ollama command", () => {
|
|
|
43
40
|
test("OllamaAction.removeModel is called with default model", async () => {
|
|
44
41
|
program.parse(["node", "test", "update", "ollama", "--remove"]);
|
|
45
42
|
expect(OllamaAction).toHaveBeenCalledTimes(1);
|
|
46
|
-
expect(OllamaAction.prototype.removeModel).toHaveBeenCalledWith("
|
|
43
|
+
expect(OllamaAction.prototype.removeModel).toHaveBeenCalledWith("");
|
|
47
44
|
});
|
|
48
45
|
});
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {describe, test, vi, beforeEach, afterEach, expect, Mock} from "vitest";
|
|
2
|
+
import { BaseAction } from "../../src/lib/actions/BaseAction";
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
import ora, { Ora } from "ora";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
|
|
7
|
+
vi.mock("inquirer");
|
|
8
|
+
vi.mock("ora");
|
|
9
|
+
|
|
10
|
+
describe("BaseAction", () => {
|
|
11
|
+
let baseAction: BaseAction;
|
|
12
|
+
let mockSpinner: Ora;
|
|
13
|
+
let consoleSpy: any;
|
|
14
|
+
let consoleErrorSpy: any;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
vi.clearAllMocks();
|
|
18
|
+
consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {});
|
|
19
|
+
consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
20
|
+
mockSpinner = {
|
|
21
|
+
start: vi.fn(),
|
|
22
|
+
stop: vi.fn(),
|
|
23
|
+
succeed: vi.fn(),
|
|
24
|
+
fail: vi.fn(),
|
|
25
|
+
text: "",
|
|
26
|
+
} as unknown as Ora;
|
|
27
|
+
|
|
28
|
+
(ora as unknown as Mock).mockReturnValue(mockSpinner);
|
|
29
|
+
|
|
30
|
+
baseAction = new BaseAction();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
vi.restoreAllMocks();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("should start the spinner with a message", () => {
|
|
38
|
+
baseAction["startSpinner"]("Loading...");
|
|
39
|
+
expect(mockSpinner.start).toHaveBeenCalled();
|
|
40
|
+
expect(mockSpinner.text).toBe(chalk.blue("Loading..."));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("should succeed the spinner with a message", () => {
|
|
44
|
+
baseAction["succeedSpinner"]("Success");
|
|
45
|
+
expect(mockSpinner.succeed).toHaveBeenCalledWith(expect.stringContaining("Success"));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("should fail the spinner with an error message", () => {
|
|
49
|
+
baseAction["failSpinner"]("Failure", new Error("Something went wrong"));
|
|
50
|
+
expect(mockSpinner.fail).toHaveBeenCalledWith(expect.stringContaining("Failure"));
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("should stop the spinner", () => {
|
|
54
|
+
baseAction["stopSpinner"]();
|
|
55
|
+
expect(mockSpinner.stop).toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("should set spinner text", () => {
|
|
59
|
+
baseAction["setSpinnerText"]("Updated text");
|
|
60
|
+
expect(mockSpinner.text).toBe(chalk.blue("Updated text"));
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("should confirm prompt and proceed when confirmed", async () => {
|
|
64
|
+
vi.mocked(inquirer.prompt).mockResolvedValue({ confirmAction: true });
|
|
65
|
+
|
|
66
|
+
await expect(baseAction["confirmPrompt"]("Are you sure?")).resolves.not.toThrow();
|
|
67
|
+
expect(inquirer.prompt).toHaveBeenCalled();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("should confirm prompt and exit when declined", async () => {
|
|
71
|
+
vi.mocked(inquirer.prompt).mockResolvedValue({ confirmAction: false });
|
|
72
|
+
const processExitSpy = vi.spyOn(process, "exit").mockImplementation(() => {
|
|
73
|
+
throw new Error("process exited");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
await expect(baseAction["confirmPrompt"]("Are you sure?")).rejects.toThrow("process exited");
|
|
77
|
+
expect(inquirer.prompt).toHaveBeenCalled();
|
|
78
|
+
expect(processExitSpy).toHaveBeenCalledWith(0);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("should log a success message", () => {
|
|
82
|
+
baseAction["logSuccess"]("Success message");
|
|
83
|
+
|
|
84
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("✔ Success message"));
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("should log an error message", () => {
|
|
88
|
+
baseAction["logError"]("Error message");
|
|
89
|
+
|
|
90
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining("✖ Error message"));
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("should log a info message", () => {
|
|
94
|
+
baseAction["logInfo"]("Info message");
|
|
95
|
+
|
|
96
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("ℹ Info message"));
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("should log a warning message", () => {
|
|
100
|
+
baseAction["logWarning"]("Warning message");
|
|
101
|
+
|
|
102
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("⚠ Warning message"));
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("should log a success message with data", () => {
|
|
106
|
+
const data = { key: "value" };
|
|
107
|
+
|
|
108
|
+
baseAction["logSuccess"]("Success message", data);
|
|
109
|
+
|
|
110
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("✔ Success message"));
|
|
111
|
+
expect(consoleSpy).toHaveBeenCalledWith(chalk.green(JSON.stringify(data, null, 2)));
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("should log an error message with error details", () => {
|
|
115
|
+
const error = new Error("Something went wrong");
|
|
116
|
+
|
|
117
|
+
baseAction["logError"]("Error message", error);
|
|
118
|
+
|
|
119
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining("✖ Error message"));
|
|
120
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(chalk.red(JSON.stringify({
|
|
121
|
+
name: error.name,
|
|
122
|
+
message: error.message,
|
|
123
|
+
}, null, 2)));
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("should log an info message with data", () => {
|
|
127
|
+
const data = { info: "This is some info" };
|
|
128
|
+
|
|
129
|
+
baseAction["logInfo"]("Info message", data);
|
|
130
|
+
|
|
131
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("ℹ Info message"));
|
|
132
|
+
expect(consoleSpy).toHaveBeenCalledWith(chalk.blue(JSON.stringify(data, null, 2)));
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("should log a warning message with data", () => {
|
|
136
|
+
const data = { warning: "This is a warning" };
|
|
137
|
+
|
|
138
|
+
baseAction["logWarning"]("Warning message", data);
|
|
139
|
+
|
|
140
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("⚠ Warning message"));
|
|
141
|
+
expect(consoleSpy).toHaveBeenCalledWith(chalk.yellow(JSON.stringify(data, null, 2)));
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("should succeed the spinner with a message and log result if data is provided", () => {
|
|
145
|
+
const mockData = { key: "value" };
|
|
146
|
+
|
|
147
|
+
baseAction["succeedSpinner"]("Success", mockData);
|
|
148
|
+
|
|
149
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("Result:"));
|
|
150
|
+
expect(consoleSpy).toHaveBeenCalledWith(JSON.stringify(mockData, null, 2));
|
|
151
|
+
expect(mockSpinner.succeed).toHaveBeenCalledWith(expect.stringContaining("Success"));
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("should format an Error instance with name, message, and additional properties", () => {
|
|
155
|
+
const error = new Error("Something went wrong");
|
|
156
|
+
(error as any).code = 500;
|
|
157
|
+
|
|
158
|
+
const result = (baseAction as any).formatOutput(error);
|
|
159
|
+
expect(result).toBe(JSON.stringify({ name: "Error", message: "Something went wrong", code: 500 }, null, 2));
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("should format an object as JSON string", () => {
|
|
163
|
+
const data = { key: "value", num: 42 };
|
|
164
|
+
const result = (baseAction as any).formatOutput(data);
|
|
165
|
+
|
|
166
|
+
expect(result).toBe(JSON.stringify(data, null, 2));
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("should return a string representation of a primitive", () => {
|
|
170
|
+
expect((baseAction as any).formatOutput("Hello")).toBe("Hello");
|
|
171
|
+
expect((baseAction as any).formatOutput(42)).toBe("42");
|
|
172
|
+
expect((baseAction as any).formatOutput(true)).toBe("true");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
});
|
|
@@ -282,6 +282,21 @@ describe("SimulatorService - Basic Tests", () => {
|
|
|
282
282
|
expect(rpcClient.request).toHaveBeenCalledWith({ method: "sim_clearDbTables", params: [['current_state', 'transactions']] });
|
|
283
283
|
});
|
|
284
284
|
|
|
285
|
+
test("should create random validators", async () => {
|
|
286
|
+
const numValidators = 5;
|
|
287
|
+
const llmProviders = ["openai", "ollama"];
|
|
288
|
+
const mockResponse = { success: true };
|
|
289
|
+
vi.mocked(rpcClient.request).mockResolvedValue(mockResponse);
|
|
290
|
+
|
|
291
|
+
const result = await simulatorService.createRandomValidators(numValidators, llmProviders);
|
|
292
|
+
|
|
293
|
+
expect(rpcClient.request).toHaveBeenCalledWith({
|
|
294
|
+
method: "sim_createRandomValidators",
|
|
295
|
+
params: [numValidators, 1, 10, llmProviders],
|
|
296
|
+
});
|
|
297
|
+
expect(result).toEqual(mockResponse);
|
|
298
|
+
});
|
|
299
|
+
|
|
285
300
|
});
|
|
286
301
|
describe("SimulatorService - Docker Tests", () => {
|
|
287
302
|
let mockGetContainer: Mock;
|
package/.eslintrc.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: {
|
|
4
|
-
es6: true,
|
|
5
|
-
node: true,
|
|
6
|
-
jest: true,
|
|
7
|
-
},
|
|
8
|
-
extends: ["eslint:recommended", "prettier", "plugin:import/typescript"],
|
|
9
|
-
parser: "@typescript-eslint/parser",
|
|
10
|
-
plugins: ["@typescript-eslint", "import"],
|
|
11
|
-
overrides: [
|
|
12
|
-
{
|
|
13
|
-
files: "**/*.ts",
|
|
14
|
-
parserOptions: {
|
|
15
|
-
project: ["./tsconfig.json"],
|
|
16
|
-
sourceType: "module",
|
|
17
|
-
},
|
|
18
|
-
extends: [
|
|
19
|
-
"plugin:import/errors",
|
|
20
|
-
"plugin:import/warnings",
|
|
21
|
-
"plugin:import/typescript",
|
|
22
|
-
"plugin:@typescript-eslint/recommended",
|
|
23
|
-
],
|
|
24
|
-
rules: {
|
|
25
|
-
"import/namespace": "off",
|
|
26
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
27
|
-
"@typescript-eslint/no-empty-interface": "off",
|
|
28
|
-
"no-constant-condition": "off",
|
|
29
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
30
|
-
"prefer-const": "off",
|
|
31
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
32
|
-
"@typescript-eslint/ban-ts-ignore": "off",
|
|
33
|
-
"@typescript-eslint/no-loss-of-precision": "off",
|
|
34
|
-
"@typescript-eslint/ban-types": "off",
|
|
35
|
-
"@typescript-eslint/ban-ts-comment": "off",
|
|
36
|
-
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
|
|
37
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
38
|
-
"import/export": "off",
|
|
39
|
-
"no-fallthrough": "off",
|
|
40
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
41
|
-
"@typescript-eslint/no-floating-promises": ["error"],
|
|
42
|
-
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
ignorePatterns: [
|
|
47
|
-
"**/dist/**/*", // Ignore built files.
|
|
48
|
-
"esbuild.config.js",
|
|
49
|
-
"jest.config.js",
|
|
50
|
-
"Config.js",
|
|
51
|
-
"commitLint.config.ts",
|
|
52
|
-
],
|
|
53
|
-
settings: {
|
|
54
|
-
"import/resolver": {
|
|
55
|
-
typescript: {},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
};
|
package/esbuild.config.dev
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
context: {
|
|
3
|
-
tsconfig: "./tsconfig.json",
|
|
4
|
-
entryPoints: ["src/index.ts"],
|
|
5
|
-
bundle: true, // Bundle all dependencies
|
|
6
|
-
outfile: "dist/index.js", // Output file
|
|
7
|
-
platform: "node",
|
|
8
|
-
target: "es2020",
|
|
9
|
-
define: { 'import.meta.url': '_importMetaUrl' },
|
|
10
|
-
banner: {
|
|
11
|
-
js: "const _importMetaUrl=require('url').pathToFileURL(__filename)",
|
|
12
|
-
},
|
|
13
|
-
external: ['ssh2'],
|
|
14
|
-
},
|
|
15
|
-
watch: true,
|
|
16
|
-
};
|
package/esbuild.config.prod
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
context: {
|
|
3
|
-
tsconfig: "./tsconfig.json",
|
|
4
|
-
entryPoints: ["src/index.ts"],
|
|
5
|
-
bundle: true, // Bundle all dependencies
|
|
6
|
-
outfile: "dist/index.js", // Output file
|
|
7
|
-
platform: "node",
|
|
8
|
-
target: "es2020",
|
|
9
|
-
define: { 'import.meta.url': '_importMetaUrl' },
|
|
10
|
-
banner: {
|
|
11
|
-
js: "const _importMetaUrl=require('url').pathToFileURL(__filename)",
|
|
12
|
-
},
|
|
13
|
-
external: ['ssh2'],
|
|
14
|
-
},
|
|
15
|
-
watch: false,
|
|
16
|
-
};
|