Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PD-4296: stack upgrade #109

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
25 changes: 0 additions & 25 deletions .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc.js

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/push_to_ecr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
- name: Run tests
run: |
npm install
npx playwright install-deps webkit
npx playwright install
npm run build
npm run test:ci

Expand Down
6 changes: 0 additions & 6 deletions .mocharc.json

This file was deleted.

3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import toruslabsTypescript from "@toruslabs/eslint-config-typescript";

export default [...toruslabsTypescript];
9,303 changes: 5,638 additions & 3,665 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@
},
"devDependencies": {
"@babel/register": "^7.25.9",
"@toruslabs/config": "^2.2.0",
"@toruslabs/eslint-config-typescript": "^3.3.4",
"@toruslabs/torus-scripts": "^6.1.5",
"@types/mocha": "^10.0.9",
"@toruslabs/config": "^3.0.0",
"@toruslabs/eslint-config-typescript": "^4.0.2",
"@toruslabs/torus-scripts": "^7.0.2",
"cross-env": "^7.0.3",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"husky": "^9.1.6",
"dotenv": "^16.4.7",
"eslint": "^9.17.0",
"husky": "^9.1.7",
"lerna": "^8.1.9",
"lint-staged": "^15.2.10",
"mocha": "^10.8.2",
"prettier": "^3.3.3",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"lint-staged": "^15.3.0",
"prettier": "^3.4.2",
"tsconfig-paths-webpack-plugin": "^4.2.0",
"tsx": "^4.19.2",
"typescript": "^5.6.3",
"typescript": "^5.7.3",
"wait-port": "^1.1.0"
},
"version": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/fetch-node-details/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fetchNodeDetails.getNodeDetails({ verifier: "google", verifierId: "[email protected]"
## Requirements

- This package requires a peer dependency of `@babel/runtime`
- Node 18+
- Node 20+

## Local Development

Expand Down
17 changes: 14 additions & 3 deletions packages/fetch-node-details/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"build": "torus-scripts build",
"release": "torus-scripts release",
"prepack": "npm run build",
"test": "mocha",
"test": "npm run test:node && npm run test:browsers",
"test:node": "vitest run --config test/configs/node.config.mts --coverage",
"test:chrome": "vitest run --config test/configs/chrome.config.mts",
"test:firefox": "vitest run --config test/configs/firefox.config.mts --coverage",
"test:safari": "vitest run --config test/configs/safari.config.mts --coverage",
"test:browsers": "npm run test:chrome && npm run test:firefox && npm run test:safari",
"lint": "eslint --fix 'src/**/*.ts'"
},
"peerDependencies": {
Expand All @@ -25,7 +30,7 @@
"dependencies": {
"@toruslabs/constants": "^14.2.0",
"@toruslabs/fnd-base": "^14.2.0",
"@toruslabs/http-helpers": "^7.0.0",
"@toruslabs/http-helpers": "^7.0.1",
"loglevel": "^1.9.2"
},
"lint-staged": {
Expand Down Expand Up @@ -56,10 +61,16 @@
},
"homepage": "https://github.com/torusresearch/fetch-node-details-sapphire#readme",
"engines": {
"node": ">=18.x",
"node": ">=20.x",
"npm": ">=9.x"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@vitest/browser": "^2.1.8",
"@vitest/coverage-istanbul": "^2.1.8",
"playwright": "^1.49.1",
"vitest": "^2.1.8"
}
}
19 changes: 19 additions & 0 deletions packages/fetch-node-details/test/configs/chrome.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
reporters: "verbose",
browser: {
screenshotFailures: false,
headless: true,
provider: "playwright",
name: "chromium",
enabled: true,
},
coverage: {
reporter: ["text"],
provider: "istanbul",
include: ["src/**/*.ts"],
},
},
});
19 changes: 19 additions & 0 deletions packages/fetch-node-details/test/configs/firefox.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
reporters: "verbose",
browser: {
screenshotFailures: false,
headless: true,
provider: "playwright",
name: "firefox",
enabled: true,
},
coverage: {
reporter: ["text"],
provider: "istanbul",
include: ["src/**/*.ts"],
},
},
});
14 changes: 14 additions & 0 deletions packages/fetch-node-details/test/configs/node.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// eslint-disable-next-line import/no-unresolved
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
reporters: "verbose",
coverage: {
reporter: ["text"],
provider: "istanbul",
include: ["src/**/*.ts"],
},
environment: "node",
},
});
19 changes: 19 additions & 0 deletions packages/fetch-node-details/test/configs/safari.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
reporters: "verbose",
browser: {
screenshotFailures: false,
headless: true,
provider: "playwright",
name: "webkit",
enabled: true,
},
coverage: {
reporter: ["text"],
provider: "istanbul",
include: ["src/**/*.ts"],
},
},
});
72 changes: 34 additions & 38 deletions packages/fetch-node-details/test/nodeDetail.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { METADATA_MAP, TORUS_LEGACY_NETWORK, TORUS_NETWORK_TYPE, TORUS_SAPPHIRE_NETWORK } from "@toruslabs/constants";
import { getSapphireNodeDetails } from "@toruslabs/fnd-base";
import { deepStrictEqual, strictEqual, throws } from "assert";
import { describe, expect, it } from "vitest";

import NodeDetailManager from "../src/nodeDetailManager";

const fndServerEndpoint = "http://localhost:8060/node-details";

describe("Fetch Node Details", function () {
it("#should return correct values - mainnet", async function () {
describe("Fetch Node Details", () => {
it("should return correct values - mainnet", async () => {
const nodeDetailManager = new NodeDetailManager({
network: TORUS_LEGACY_NETWORK.MAINNET,
fndServerEndpoint,
Expand All @@ -16,11 +16,11 @@ describe("Fetch Node Details", function () {
const details = await nodeDetailManager.getNodeDetails({ verifier: "google", verifierId: "[email protected]" });
delete details.updated;
const metadataUrl = await nodeDetailManager.getMetadataUrl();
deepStrictEqual(details, getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET, TORUS_LEGACY_NETWORK.MAINNET));
strictEqual(metadataUrl, METADATA_MAP[TORUS_LEGACY_NETWORK.MAINNET]);
expect(details).toEqual(getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET, TORUS_LEGACY_NETWORK.MAINNET));
expect(metadataUrl).toBe(METADATA_MAP[TORUS_LEGACY_NETWORK.MAINNET]);
});

it("#should return correct values - sapphire devnet", async function () {
it("should return correct values - sapphire devnet", async () => {
const nodeDetailManager = new NodeDetailManager({
network: TORUS_SAPPHIRE_NETWORK.SAPPHIRE_DEVNET,
fndServerEndpoint,
Expand All @@ -30,11 +30,11 @@ describe("Fetch Node Details", function () {
delete details.updated;
const metadataUrl = await nodeDetailManager.getMetadataUrl();
const compareNodeDetails = getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_DEVNET);
deepStrictEqual(details, compareNodeDetails);
strictEqual(metadataUrl, compareNodeDetails.torusNodeEndpoints[0].replace("/sss/jrpc", "/metadata"));
expect(details).toEqual(compareNodeDetails);
expect(metadataUrl).toBe(compareNodeDetails.torusNodeEndpoints[0].replace("/sss/jrpc", "/metadata"));
});

it("#should return correct values - sapphire mainnet", async function () {
it("should return correct values - sapphire mainnet", async () => {
const nodeDetailManager = new NodeDetailManager({
network: TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET,
fndServerEndpoint,
Expand All @@ -44,11 +44,11 @@ describe("Fetch Node Details", function () {
delete details.updated;
const metadataUrl = await nodeDetailManager.getMetadataUrl();
const compareNodeDetails = getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET);
deepStrictEqual(details, compareNodeDetails);
strictEqual(metadataUrl, compareNodeDetails.torusNodeEndpoints[0].replace("/sss/jrpc", "/metadata"));
expect(details).toEqual(compareNodeDetails);
expect(metadataUrl).toBe(compareNodeDetails.torusNodeEndpoints[0].replace("/sss/jrpc", "/metadata"));
});

it("#should return correct values - cyan", async function () {
it("should return correct values - cyan", async () => {
const nodeDetailManager = new NodeDetailManager({
network: TORUS_LEGACY_NETWORK.CYAN,
fndServerEndpoint,
Expand All @@ -57,11 +57,11 @@ describe("Fetch Node Details", function () {
const details = await nodeDetailManager.getNodeDetails({ verifier: "google-cyan", verifierId: "[email protected]" });
delete details.updated;
const metadataUrl = await nodeDetailManager.getMetadataUrl();
deepStrictEqual(details, getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET, TORUS_LEGACY_NETWORK.CYAN));
strictEqual(metadataUrl, METADATA_MAP[TORUS_LEGACY_NETWORK.CYAN]);
expect(details).toEqual(getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET, TORUS_LEGACY_NETWORK.CYAN));
expect(metadataUrl).toBe(METADATA_MAP[TORUS_LEGACY_NETWORK.CYAN]);
});

it("#should return correct values - aqua", async function () {
it("should return correct values - aqua", async () => {
const nodeDetailManager = new NodeDetailManager({
network: TORUS_LEGACY_NETWORK.AQUA,
fndServerEndpoint,
Expand All @@ -70,11 +70,11 @@ describe("Fetch Node Details", function () {
const details = await nodeDetailManager.getNodeDetails({ verifier: "google-aqua", verifierId: "[email protected]" });
delete details.updated;
const metadataUrl = await nodeDetailManager.getMetadataUrl();
deepStrictEqual(details, getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET, TORUS_LEGACY_NETWORK.AQUA));
strictEqual(metadataUrl, METADATA_MAP[TORUS_LEGACY_NETWORK.AQUA]);
expect(details).toEqual(getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET, TORUS_LEGACY_NETWORK.AQUA));
expect(metadataUrl).toBe(METADATA_MAP[TORUS_LEGACY_NETWORK.AQUA]);
});

it("#should return correct values - celeste", async function () {
it("should return correct values - celeste", async () => {
const nodeDetailManager = new NodeDetailManager({
network: TORUS_LEGACY_NETWORK.CELESTE,
fndServerEndpoint,
Expand All @@ -83,11 +83,11 @@ describe("Fetch Node Details", function () {
const details = await nodeDetailManager.getNodeDetails({ verifier: "google-celeste", verifierId: "[email protected]" });
delete details.updated;
const metadataUrl = await nodeDetailManager.getMetadataUrl();
deepStrictEqual(details, getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET, TORUS_LEGACY_NETWORK.CELESTE));
strictEqual(metadataUrl, METADATA_MAP[TORUS_LEGACY_NETWORK.CELESTE]);
expect(details).toEqual(getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET, TORUS_LEGACY_NETWORK.CELESTE));
expect(metadataUrl).toBe(METADATA_MAP[TORUS_LEGACY_NETWORK.CELESTE]);
});

it("#should return correct values - testnet", async function () {
it("should return correct values - testnet", async () => {
const nodeDetailManager = new NodeDetailManager({
network: TORUS_LEGACY_NETWORK.TESTNET,
fndServerEndpoint,
Expand All @@ -96,32 +96,28 @@ describe("Fetch Node Details", function () {
const details = await nodeDetailManager.getNodeDetails({ verifier: "google-lrc", verifierId: "[email protected]" });
delete details.updated;
const metadataUrl = await nodeDetailManager.getMetadataUrl();
deepStrictEqual(details, getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_DEVNET, TORUS_LEGACY_NETWORK.TESTNET));
strictEqual(metadataUrl, METADATA_MAP[TORUS_LEGACY_NETWORK.TESTNET]);
expect(details).toEqual(getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_DEVNET, TORUS_LEGACY_NETWORK.TESTNET));
expect(metadataUrl).toBe(METADATA_MAP[TORUS_LEGACY_NETWORK.TESTNET]);
});

it("#should throw error for invalid network", async function () {
throws(
() => {
const nodeDetailManager = new NodeDetailManager({
network: "INVALID_NETWORK" as TORUS_NETWORK_TYPE,
fndServerEndpoint,
enableLogging: true,
});
return nodeDetailManager.getNodeDetails({ verifier: "google", verifierId: "[email protected]" });
},
Error,
"Invalid network"
);
it("should throw error for invalid network", () => {
expect(() => {
const nodeDetailManager = new NodeDetailManager({
network: "INVALID_NETWORK" as TORUS_NETWORK_TYPE,
fndServerEndpoint,
enableLogging: true,
});
return nodeDetailManager.getNodeDetails({ verifier: "google", verifierId: "[email protected]" });
}).toThrow("Invalid network");
});

it("#should use default network if not provided", async function () {
it("should use default network if not provided", async () => {
const nodeDetailManager = new NodeDetailManager({
fndServerEndpoint,
enableLogging: true,
});
const details = await nodeDetailManager.getNodeDetails({ verifier: "google", verifierId: "[email protected]" });
delete details.updated;
deepStrictEqual(details, getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET));
expect(details).toEqual(getSapphireNodeDetails(TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET));
});
});
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-require-imports */
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");

function generateWebpackConfig({ alias }) {
Expand Down
Loading