Skip to content

Commit 2ade7cc

Browse files
authored
Fix parsing compute envs for ocean-node system tests. (#121)
* Fix parsing envs for ocean-node system tests. * Add check for tty. * Fix dataset on new structure of lists. * Update ddo.js version. * Update ocean.js * Remove node version from ci.
1 parent b41aadf commit 2ade7cc

6 files changed

Lines changed: 57 additions & 62 deletions

File tree

metadata/simpleComputeDataset.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"compute": {
4343
"allowRawAlgorithm": false,
4444
"allowNetworkAccess": true,
45-
"publisherTrustedAlgorithmPublishers": [],
46-
"publisherTrustedAlgorithms": []
45+
"publisherTrustedAlgorithmPublishers": ["*"],
46+
"publisherTrustedAlgorithms": ["*"]
4747
}
4848
}
4949
],

package-lock.json

Lines changed: 36 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"dependencies": {
4747
"@oasisprotocol/sapphire-paratime": "^1.3.2",
4848
"@oceanprotocol/contracts": "^2.3.1",
49-
"@oceanprotocol/ddo-js": "^0.0.8",
50-
"@oceanprotocol/lib": "^4.1.3",
49+
"@oceanprotocol/ddo-js": "^0.1.0",
50+
"@oceanprotocol/lib": "^4.1.4",
5151
"commander": "^13.1.0",
5252
"cross-fetch": "^3.1.5",
5353
"crypto-js": "^4.1.1",

src/cli.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ export async function createCLI() {
225225

226226
const proceed = options.accept;
227227
if (!proceed) {
228+
if (!process.stdin.isTTY) {
229+
console.error(chalk.red('Cannot prompt for confirmation (non-TTY). Use "--accept true" to skip.'));
230+
process.exit(1);
231+
}
228232
const rl = createInterface({ input, output });
229233
const confirmation = await rl.question(`\nProceed with payment for starting compute job at price ${amount} in tokens from address ${initResp.payment.token}? (y/n): `);
230234
rl.close();

test/consumeFlow.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("Ocean CLI Publishing", function() {
5757
const jsonMatch = output.match(/did:op:[a-f0-9]{64}/);
5858
if (!jsonMatch) {
5959
console.error("Raw output:", output);
60-
throw new Error("Could not find compute environments in the output");
60+
throw new Error("Could not find did in the output");
6161
}
6262

6363
try {
@@ -81,7 +81,7 @@ describe("Ocean CLI Publishing", function() {
8181
const jsonMatch = output.match(/did:op:[a-f0-9]{64}/);
8282
if (!jsonMatch) {
8383
console.error("Raw output:", output);
84-
throw new Error("Could not find compute environments in the output");
84+
throw new Error("Could not find did in the output");
8585
}
8686

8787
try {
@@ -104,7 +104,7 @@ describe("Ocean CLI Publishing", function() {
104104
const jsonMatch = output.match(/did:op:[a-f0-9]{64}/);
105105
if (!jsonMatch) {
106106
console.error("Raw output:", output);
107-
throw new Error("Could not find compute environments in the output");
107+
throw new Error("Could not find did in the output");
108108
}
109109

110110
try {
@@ -127,7 +127,7 @@ describe("Ocean CLI Publishing", function() {
127127
const jsonMatch = output.match(/did:op:[a-f0-9]{64}/);
128128
if (!jsonMatch) {
129129
console.error("Raw output:", output);
130-
throw new Error("Could not find compute environments in the output");
130+
throw new Error("Could not find did in the output");
131131
}
132132

133133
try {
@@ -145,7 +145,7 @@ describe("Ocean CLI Publishing", function() {
145145
const jsonMatch = output.match(/s*([\s\S]*)/);
146146
if (!jsonMatch) {
147147
console.error("Raw output:", output);
148-
throw new Error("Could not find compute environments in the output");
148+
throw new Error("Could not find ddo in the output");
149149
}
150150

151151
try {
@@ -162,7 +162,7 @@ describe("Ocean CLI Publishing", function() {
162162
const jsonMatch = output.match(/s*([\s\S]*)/);
163163
if (!jsonMatch) {
164164
console.error("Raw output:", output);
165-
throw new Error("Could not find compute environments in the output");
165+
throw new Error("Could not find ddo in the output");
166166
}
167167

168168
try {
@@ -179,7 +179,7 @@ describe("Ocean CLI Publishing", function() {
179179
const jsonMatch = output.match(/s*([\s\S]*)/);
180180
if (!jsonMatch) {
181181
console.error("Raw output:", output);
182-
throw new Error("Could not find compute environments in the output");
182+
throw new Error("Could not find ddo in the output");
183183
}
184184

185185
try {
@@ -196,7 +196,7 @@ describe("Ocean CLI Publishing", function() {
196196
const jsonMatch = output.match(/s*([\s\S]*)/);
197197
if (!jsonMatch) {
198198
console.error("Raw output:", output);
199-
throw new Error("Could not find compute environments in the output");
199+
throw new Error("Could not find ddo in the output");
200200
}
201201

202202
try {

test/paidComputeFlow.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe("Ocean CLI Paid Compute", function() {
8989
const jsonMatch = output.match(/s*([\s\S]*)/);
9090
if (!jsonMatch) {
9191
console.error("Raw output:", output);
92-
throw new Error("Could not find compute environments in the output");
92+
throw new Error("Could not find ddo in the output");
9393
}
9494

9595
try {
@@ -106,7 +106,7 @@ describe("Ocean CLI Paid Compute", function() {
106106
const jsonMatch = output.match(/s*([\s\S]*)/);
107107
if (!jsonMatch) {
108108
console.error("Raw output:", output);
109-
throw new Error("Could not find compute environments in the output");
109+
throw new Error("Could not find ddo in the output");
110110
}
111111

112112
try {
@@ -125,18 +125,12 @@ describe("Ocean CLI Paid Compute", function() {
125125
console.error("Raw output:", output);
126126
throw new Error("Could not find compute environments in the output");
127127
}
128-
const match = jsonMatch[0].match(/Exiting compute environments:\s*(.*)/s);
129-
const result = match ? match[1].trim() : null;
130-
if (!result) {
131-
console.error("Raw output:", output);
132-
throw new Error("Could not find compute environments in the output");
133-
}
134-
128+
135129
let environments;
136130
try {
137-
environments = eval(result);
131+
environments = eval(jsonMatch[1]);
138132
} catch (error) {
139-
console.error(`Extracted output: ${jsonMatch[0]} and final result: ${result}`);
133+
console.error(`Extracted output: ${jsonMatch[0]} and final result: ${jsonMatch[1]}`);
140134
throw new Error("Failed to parse the extracted output:\n" + error);
141135
}
142136

0 commit comments

Comments
 (0)