Skip to content

Commit 8b12f94

Browse files
committed
Modified config and updated test.
1 parent b023f27 commit 8b12f94

3 files changed

Lines changed: 38 additions & 52 deletions

File tree

test/computeFlow.test.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { homedir } from 'os'
77

88
import { dirname } from 'path'
99
import { fileURLToPath } from 'url'
10-
import { ProviderInstance } from "../node_modules/@oceanprotocol/lib/dist/types/index";
10+
import {
11+
ProviderInstance
12+
} from "@oceanprotocol/lib";
1113

1214
const execPromise = util.promisify(exec);
1315

@@ -65,6 +67,11 @@ describe("Ocean CLI Compute", function() {
6567
const output = await runCommand(`npm run cli publish ${metadataFile}`);
6668

6769
const jsonMatch = output.match(/did:op:[a-f0-9]{64}/);
70+
if (!jsonMatch) {
71+
console.error("Raw output:", output);
72+
throw new Error("Could not find compute environments in the output");
73+
}
74+
6875
try {
6976
computeDatasetDid = jsonMatch[0];
7077
} catch (error) {
@@ -141,6 +148,10 @@ describe("Ocean CLI Compute", function() {
141148
}
142149
const match = jsonMatch[0].match(/Exiting compute environments:\s*(.*)/s);
143150
const result = match ? match[1].trim() : null;
151+
if (!result) {
152+
console.error("Raw output:", output);
153+
throw new Error("Could not find compute environments in the output");
154+
}
144155

145156
let environments;
146157
try {
@@ -166,6 +177,8 @@ describe("Ocean CLI Compute", function() {
166177
it("should initialize compute on compute dataset and algorithm", async function() {
167178
const computeEnvs = await ProviderInstance.getComputeEnvironments('http://127.0.0.1:8001');
168179
const env = computeEnvs[0];
180+
expect(env).to.be.an('object').and.to.not.be.null.and.to.not.be.undefined;
181+
169182
console.log(`env: ${JSON.stringify(env)}`)
170183
resources = [
171184
{
@@ -191,7 +204,10 @@ describe("Ocean CLI Compute", function() {
191204
}
192205
const match = jsonMatch[0].match(/initialize compute details:\s*(.*)/s);
193206
const result = match ? match[1].trim() : null;
194-
207+
if (!result) {
208+
console.error("Raw output:", output);
209+
throw new Error("Could not find initialize compute response in the output");
210+
}
195211
try {
196212
providerInitializeResponse = eval(result);
197213
} catch (error) {
@@ -215,6 +231,10 @@ describe("Ocean CLI Compute", function() {
215231
}
216232
const match = jsonMatch[0].match(/JobID:\s*(.*)/s);
217233
const result = match ? match[1].trim() : null;
234+
if (!result) {
235+
console.error("Raw output:", output);
236+
throw new Error("Could not find compute job in the output");
237+
}
218238
computeJobId = result
219239
expect(computeJobId).to.be.a("string");
220240
});

test/consumeFlow.test.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -214,44 +214,4 @@ describe("Ocean CLI Publishing", function() {
214214
}
215215
})();
216216
});
217-
218-
it("should initialize compute on compute dataset and algorithm", async function(done) {
219-
this.timeout(10000); // Increase timeout if needed
220-
221-
(async () => {
222-
try {
223-
const { stdout } = await new Promise<{ stdout: string, error: Error | null }>((resolve, reject) => {
224-
exec(`npm run cli initializeCompute ${computeDatasetDid} ${jsAlgoDid} `, { cwd: projectRoot }, (error, stdout) => {
225-
if (error) {
226-
reject(error);
227-
} else {
228-
resolve({ stdout, error: null });
229-
}
230-
});
231-
});
232-
233-
expect(stdout).to.contain("File downloaded successfully");
234-
235-
// Path to the downloaded file
236-
const downloadedFilePath = './LICENSE';
237-
238-
// Verify the downloaded file content hash matches the original file hash
239-
const downloadedFileHash = computeFileHash(downloadedFilePath);
240-
const originalFilePath = './metadata/LICENSE';
241-
242-
await downloadFile("https://raw.githubusercontent.com/oceanprotocol/ocean-node/refs/heads/main/LICENSE", originalFilePath);
243-
const originalFileHash = computeFileHash(originalFilePath);
244-
245-
expect(downloadedFileHash).to.equal(originalFileHash);
246-
247-
// Clean up downloaded original file
248-
fs.unlinkSync(originalFilePath);
249-
250-
done()
251-
} catch (err) {
252-
done(err);
253-
}
254-
})();
255-
});
256-
257217
});

test/tsconfig.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
{
22
"compilerOptions": {
3-
"lib": ["es6", "es7", "dom"],
4-
"module": "ES2022",
5-
"target": "ES2022",
6-
"noUnusedLocals": false,
3+
"resolveJsonModule": true,
4+
"moduleResolution": "node",
75
"esModuleInterop": true,
8-
"allowSyntheticDefaultImports": true
6+
"allowSyntheticDefaultImports": true,
7+
"lib": ["ESNext", "dom"],
8+
"declaration": true,
9+
"module": "ES2020",
10+
"target": "ES2020",
11+
"removeComments": false,
12+
"experimentalDecorators": true,
13+
"preserveConstEnums": true,
14+
"outDir": "./dist",
15+
"sourceMap": true,
16+
"skipLibCheck": true,
917
},
10-
"ts-node": {
11-
"esm": true,
12-
"experimentalSpecifierResolution": "node"
13-
}
14-
}
18+
"include": ["src/**/*", "src/tests/**/*"],
19+
"exclude": ["node_modules"]
20+
}

0 commit comments

Comments
 (0)