diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d19198..9cc6d8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -183,6 +183,8 @@ jobs: working-directory: ${{ github.workspace }}/barge run: | bash -x start_ocean.sh --with-typesense 2>&1 > start_ocean.log & + env: + NODE_VERSION: pr-1622 - name: Install dependencies run: npm ci - run: npm run build @@ -219,7 +221,7 @@ jobs: attempt=1 echo "Waiting for node HTTP API to be ready..." while [ $attempt -le $max_attempts ]; do - PEER_ID=$(curl -s http://127.0.0.1:8001 | jq -r '.nodeId // empty' 2>/dev/null) + PEER_ID=$(curl -s http://127.0.0.1:8001 | jq -r '.id // .nodeId // empty' 2>/dev/null) if [ -n "$PEER_ID" ]; then echo "Got peer ID: $PEER_ID" echo "NODE_URL=${PEER_ID}" >> $GITHUB_ENV diff --git a/package-lock.json b/package-lock.json index 42effab..4e8f07d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@oasisprotocol/sapphire-ethers-v6": "^6.0.1", "@oceanprotocol/contracts": "^3.2.0-rc.1", "@oceanprotocol/ddo-js": "^1.0.0", - "@oceanprotocol/lib": "^10.1.0", + "@oceanprotocol/lib": "github:oceanprotocol/ocean.js#feature/unify_status_endpoints", "chalk": "^6.0.1", "commander": "^15.0.0", "enquirer": "^2.4.1", @@ -1933,22 +1933,24 @@ "license": "Apache-2.0" }, "node_modules/@oceanprotocol/ddo-js": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@oceanprotocol/ddo-js/-/ddo-js-1.0.0.tgz", - "integrity": "sha512-FSw3rDimhf/aHARzQVN7Ve4xGkgK4cRRr8AJtc3XRH0Knc7WK8ga+TJkx9LvS1KjH7hVePSD9Q7400oJQe0Iqg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@oceanprotocol/ddo-js/-/ddo-js-1.1.0.tgz", + "integrity": "sha512-9/CYpaD0qzA/smmK63nMDnnd3XYNGGreb8y7uUwiC6ODqEKyvhEdMnSj2Rya4oNpyiJQ9cJhOsNGSEmYDhynKw==", "license": "Apache-2.0", "dependencies": { "ethers": "^6.17.0", "jsonld": "^9.0.0", - "n3": "^2.2.0", + "n3": "^2.13.12", "rdf-literal": "^2.0.0", "rdf-validate-shacl": "^0.6.5" + }, + "engines": { + "node": ">=22" } }, "node_modules/@oceanprotocol/lib": { "version": "10.1.0", - "resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-10.1.0.tgz", - "integrity": "sha512-cZue8rqPFgPeC1yuht1A1j5nL9M9C/GQVtHYMk4GhoYpkOzAfPMBqHw2gscmf9r8sdtBZEpSXq2TviZdXwamag==", + "resolved": "git+ssh://git@github.com/oceanprotocol/ocean.js.git#6a12611adb8ca8a433db596447ba79717a5e31d2", "license": "Apache-2.0", "dependencies": { "@chainsafe/libp2p-noise": "^17.0.0", @@ -1965,7 +1967,7 @@ "@libp2p/websockets": "^10.1.21", "@multiformats/multiaddr": "^13.0.3", "@oasisprotocol/sapphire-ethers-v6": "^6.0.1", - "@oceanprotocol/ddo-js": "^1.0.0", + "@oceanprotocol/ddo-js": "^1.1.0", "bignumber.js": "^11.1.5", "cross-fetch": "^4.1.0", "crypto-js": "^4.2.0", @@ -3100,6 +3102,7 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", + "deprecated": "Active development of CryptoJS has been discontinued. This library is no longer maintained.", "license": "MIT" }, "node_modules/datastore-core": { @@ -4938,9 +4941,9 @@ } }, "node_modules/n3": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/n3/-/n3-2.2.5.tgz", - "integrity": "sha512-lR/0N7zVayC6N0uWqrMkPpJn8Up4+qBsjWiBnoOWWEi/ldTcygs2Dw1iAgozzDXLW/fcxXFfbMzpGHlc/1MBLQ==", + "version": "2.13.12", + "resolved": "https://registry.npmjs.org/n3/-/n3-2.13.12.tgz", + "integrity": "sha512-z944NsyJi58WXcYevtNkUL2JhVr0KP6nvED9AgymQq5V35TDaNn1N8kO+OWJk/kj4PR0L/ilWB3d7/bWceg1CQ==", "license": "MIT", "dependencies": { "buffer": "^6.0.3", diff --git a/package.json b/package.json index 13f2b8a..7489cd3 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "@oasisprotocol/sapphire-ethers-v6": "^6.0.1", "@oceanprotocol/contracts": "^3.2.0-rc.1", "@oceanprotocol/ddo-js": "^1.0.0", - "@oceanprotocol/lib": "^10.1.0", + "@oceanprotocol/lib": "github:oceanprotocol/ocean.js#feature/unify_status_endpoints", "chalk": "^6.0.1", "commander": "^15.0.0", "enquirer": "^2.4.1", diff --git a/test/http.test.ts b/test/http.test.ts index 20c59d8..e92adb7 100644 --- a/test/http.test.ts +++ b/test/http.test.ts @@ -1,21 +1,41 @@ import { expect } from "chai"; +import { ProviderInstance } from "@oceanprotocol/lib"; -describe("Ocean Node Root Endpoint", () => { - it("should return 200 OK", async () => { - const response = await fetch("http://localhost:8001/"); - const responseBody = await response.json(); +// Node status is fetched through ocean.js `getNodeStatus` (which uses the STATUS +// command over `POST /directCommand`), not a raw `fetch` to the root endpoint, so +// this is immune to the ocean-node #1622 root-endpoint rename (`nodeId`/ +// `providerAddress`/`nodePublicKey`/`software` are gone; the status object exposes +// `id`/`address`/`publicKey`). It runs over the node's HTTP API, which is up in +// both CI transport legs; the P2P transport itself is exercised by the full +// system-test suite (which runs the CLI with NODE_URL set to the node's peer id). +const NODE_HTTP = "http://127.0.0.1:8001"; - expect(response.status).to.equal(200); - expect(responseBody).to.have.property("chainIds"); - expect(responseBody).to.have.property("providerAddress"); - expect(responseBody).to.have.property("software"); - expect(responseBody).to.have.property("version"); +describe("Ocean Node status (via getNodeStatus)", function () { + this.timeout(30_000); + + it("should return the full node status object", async () => { + const status = await ProviderInstance.getNodeStatus( + NODE_HTTP, + AbortSignal.timeout(15_000), + ); - // You can also check the values of the properties - expect(responseBody.software).to.equal("Ocean-Node"); + expect(status, `node ${NODE_HTTP} should be reachable`).to.not.be.null; + expect(status).to.have.property("id"); + expect(status).to.have.property("publicKey"); + expect(status).to.have.property("address"); + expect(status).to.have.property("version"); + expect(status).to.have.property("http"); + expect(status).to.have.property("p2p"); + expect(status).to.have.property("provider"); + expect(status).to.have.property("indexer"); + expect(status).to.have.property("supportedStorage"); + expect(status).to.have.property("uptime"); + expect(status).to.have.property("platform"); + expect(status).to.have.property("codeHash"); + expect(status).to.have.property("allowedAdmins"); // Check if version is "0.0.1" or greater - const [major, minor, patch] = responseBody.version.split(".").map(Number); + const [major, minor, patch] = status.version.split(".").map(Number); expect(major).to.be.at.least(0); if (major === 0) { expect(minor).to.be.at.least(0); @@ -26,38 +46,6 @@ describe("Ocean Node Root Endpoint", () => { }); }); -describe("Direct Command Endpoint", () => { - it("should return correct status", async () => { - const response = await fetch("http://localhost:8001/directCommand", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ command: "status" }), - }); - const responseBody = await response.json(); - - expect(response.status).to.equal(200); - expect(responseBody).to.have.property("id"); - expect(responseBody).to.have.property("publicKey"); - expect(responseBody).to.have.property("address"); - expect(responseBody).to.have.property("version"); - expect(responseBody).to.have.property("http"); - expect(responseBody).to.have.property("p2p"); - expect(responseBody).to.have.property("provider"); - expect(responseBody).to.have.property("indexer"); - expect(responseBody).to.have.property("supportedStorage"); - expect(responseBody).to.have.property("uptime"); - expect(responseBody).to.have.property("platform"); - expect(responseBody).to.have.property("codeHash"); - expect(responseBody).to.have.property("allowedAdmins"); - - // Check the values of some of the properties - expect(responseBody.http).to.be.true; - expect(responseBody.p2p).to.be.true; - }); -}); - describe("getP2PPeers Endpoint", () => { it("should return correct status", async () => { const response = await fetch("http://localhost:8001/getP2PPeers");