genlayer 0.39.0 → 0.39.2

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.
@@ -56,4 +56,22 @@ describe("JsonRpcClient - Successful and Unsuccessful Requests", () => {
56
56
  body: expect.stringContaining('"method":"testMethod"'),
57
57
  });
58
58
  });
59
+
60
+ test("should reject JSON-RPC error responses even when HTTP status is ok", async () => {
61
+ (fetch as Mock).mockResolvedValueOnce({
62
+ ok: true,
63
+ json: async () => ({
64
+ jsonrpc: "2.0",
65
+ error: { code: -32603, message: "RPC failed" },
66
+ id: "1",
67
+ }),
68
+ });
69
+
70
+ const params: JsonRPCParams = {
71
+ method: "testMethod",
72
+ params: ["param1"],
73
+ };
74
+
75
+ await expect(rpcClient.request(params)).rejects.toThrowError("RPC failed");
76
+ });
59
77
  });
@@ -70,13 +70,15 @@ describe("System Functions - Error Paths", () => {
70
70
  await expect(getVersion(toolName)).rejects.toThrow(`Error getting ${toolName} version.`);
71
71
  });
72
72
 
73
- test("getVersion returns '' if stdout is empty", async () => {
73
+ test("getVersion throws when stdout does not match version pattern", async () => {
74
74
  vi.mocked(util.promisify).mockReturnValueOnce(() => Promise.resolve({
75
75
  stdout: "",
76
76
  stderr: ""
77
77
  }));
78
- const result = await getVersion('git');
79
- expect(result).toBe("");
78
+ const toolName = "git";
79
+ await expect(getVersion(toolName)).rejects.toThrow(
80
+ `Could not parse ${toolName} version from output`
81
+ );
80
82
  });
81
83
 
82
84
  test("getVersion throw error if stdout undefined", async () => {
@@ -87,6 +89,17 @@ describe("System Functions - Error Paths", () => {
87
89
  await expect(getVersion(toolName)).rejects.toThrow(`Error getting ${toolName} version.`);
88
90
  });
89
91
 
92
+ test("getVersion throws when stdout has non-matching version format (e.g. major-only)", async () => {
93
+ vi.mocked(util.promisify).mockReturnValueOnce(() => Promise.resolve({
94
+ stdout: "Docker version 25",
95
+ stderr: ""
96
+ }));
97
+ const toolName = "docker";
98
+ await expect(getVersion(toolName)).rejects.toThrow(
99
+ `Could not parse ${toolName} version from output`
100
+ );
101
+ });
102
+
90
103
  test("checkCommand returns false if the command does not exist", async () => {
91
104
  vi.mocked(util.promisify).mockReturnValueOnce(() => Promise.reject({
92
105
  stdout: "",
@@ -96,6 +109,26 @@ describe("System Functions - Error Paths", () => {
96
109
  await expect(checkCommand(`${toolName} --version`, toolName)).rejects.toThrow(new MissingRequirementError(toolName));
97
110
  });
98
111
 
112
+ test("checkCommand throws MissingRequirementError when binary is not installed (ENOENT)", async () => {
113
+ vi.mocked(util.promisify).mockReturnValueOnce(() => Promise.reject({
114
+ code: 'ENOENT',
115
+ stderr: '',
116
+ message: 'spawn ENOENT'
117
+ }));
118
+ const toolName = 'docker';
119
+ await expect(checkCommand(`${toolName} --version`, toolName)).rejects.toThrow(new MissingRequirementError(toolName));
120
+ });
121
+
122
+ test("checkCommand throws MissingRequirementError when command exits without stderr", async () => {
123
+ vi.mocked(util.promisify).mockReturnValueOnce(() => Promise.reject({
124
+ code: 127,
125
+ stderr: '',
126
+ message: 'command failed'
127
+ }));
128
+ const toolName = 'docker';
129
+ await expect(checkCommand(`${toolName} --version`, toolName)).rejects.toThrow(new MissingRequirementError(toolName));
130
+ });
131
+
99
132
  test("executeCommand throws an error if the command fails", async () => {
100
133
  vi.mocked(util.promisify).mockReturnValueOnce(() => Promise.reject(new Error("Execution failed")));
101
134
  await expect(executeCommand({
package/tsconfig.json CHANGED
@@ -39,9 +39,8 @@
39
39
  ] /* Allow multiple folders to be treated as one when resolving modules. */,
40
40
  // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
41
41
  "types": [
42
- "jest",
43
- "node",
44
- "@types/jest"
42
+ "vitest/globals",
43
+ "node"
45
44
  ] /* Specify type package names to be included without being referenced in a source file. */,
46
45
  // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
47
46
  // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */