Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
25 changes: 14 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
76 changes: 32 additions & 44 deletions test/http.test.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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");
Expand Down
Loading