Skip to content
Merged
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
49 changes: 45 additions & 4 deletions src/schemas/manifest.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,56 @@
}
},
"chain": {
"type": "string",
"oneOf": [
{
"type": "string",
"enum": [
"ethereum",
"ethereum-beacon-chain",
"ethereum2-beacon-chain-prysm",
"bitcoin",
"monero"
]
},
{
"type": "object",
"properties": {
"driver": {
"type": "string",
"enum": [
"bitcoin",
"ethereum",
"ethereum-beacon-chain",
"ethereum2-beacon-chain-prysm",
"monero"
],
"description": "The blockchain driver used by this DAppNode Package",
"examples": ["ethereum", "bitcoin"]
},
"serviceName": {
"type": "string",
"description": "The name of the blockchain service used by this DAppNode Package"
},
"portNumber": {
"type": "integer",
"description": "The port number of the blockchain service used by this DAppNode Package"
}
},
"required": ["driver"]
}
],
"description": "Indicate that this DAppNode Package is a blockchain node so the admin UI shows its syncing status",
"examples": [
"ethereum",
"ethereum2-beacon-chain-prysm",
"bitcoin",
"monero"
"monero",
{
"driver": "ethereum-beacon-chain",
"serviceName": "beacon-chain",
"portNumber": 3500
}
],
"enum": ["ethereum", "ethereum2-beacon-chain-prysm", "bitcoin", "monero"],
"enumDescriptions": {
"ethereum": "Must have an Ethereum JSON RPC exposed internally at port 8545",
"bitcoin": "Must have a standard Bitcoin JSON API exposed at the default port (8332). Uses the NPM package `bitcoin-core`",
Expand Down Expand Up @@ -310,7 +351,7 @@
"description": "Port this exposable service listens to",
"examples": [80, 5001, 8545]
},
"exposeByDefault" : {
"exposeByDefault": {
"type": "boolean",
"description": "Whether this HTTPS port should be exposed by default on installation",
"examples": [true, false]
Expand Down
51 changes: 51 additions & 0 deletions test/validate.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { expect } from "chai";
import { validateManifestSchema } from "../src/utils/validateManifestSchema";

describe("utils / format", () => {
it("validateManifest chainDriver as string", () => {
const manifest = {
name: "",
version: "1.0.0",
description: "",
type: "dncore",
license: "1",
chain: {
driver: "ethereum"
}
};

const validManifest = validateManifestSchema(manifest);
expect(validManifest.valid).to.be.true;
expect(validManifest.errors).to.be.empty;
});

it("validateManifest chainDriver as object", () => {
const manifest = {
name: "",
version: "1.0.0",
description: "",
type: "dncore",
license: "1",
chain: "ethereum"
};

const validManifest = validateManifestSchema(manifest);
expect(validManifest.valid).to.be.true;
expect(validManifest.errors).to.be.empty;
});

it("throw error validating", () => {
const manifest = {
name: "",
version: "1.0.0",
description: "",
type: "dncore",
license: "1",
chain: "notAllowed"
};

const validManifest = validateManifestSchema(manifest);
expect(validManifest.valid).to.be.false;
expect(validManifest.errors).to.not.be.empty;
});
});