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

test(relayer): adds initial testing base #375

Merged
merged 5 commits into from
Dec 13, 2024
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
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"es6": true,
"node": true,
"mocha": true,
"es2020": true
"es2020": true,
"jest": true
},
"extends": [
"eslint:recommended",
Expand Down
1 change: 1 addition & 0 deletions relayer-cli/.gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage
10 changes: 10 additions & 0 deletions relayer-cli/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Config } from "jest";

const config: Config = {
preset: "ts-jest",
testEnvironment: "node",
collectCoverage: true,
collectCoverageFrom: ["**/*.ts"],
};

export default config;
4 changes: 4 additions & 0 deletions relayer-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"yarn": "4.2.2"
},
"scripts": {
"test": "jest --coverage",
"start-devnet-relayer": "npx ts-node ./src/devnetRelayExample.ts",
"start-testnet-relayer": "npx ts-node ./src/testnetRelayer.ts"
},
Expand All @@ -23,6 +24,9 @@
"web3-batched-send": "^1.0.3"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2"
}
}
17 changes: 1 addition & 16 deletions relayer-cli/src/utils/relayerHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
import * as fs from "fs";

class ShutdownManager {
private isShuttingDown: boolean;

constructor(initialState: boolean = false) {
this.isShuttingDown = initialState;
}

public getIsShuttingDown(): boolean {
return this.isShuttingDown;
}

public triggerShutdown() {
this.isShuttingDown = true;
}
}
import ShutdownManager from "./shutdownManager";

async function initialize(chainId: number, network: string): Promise<number> {
const lockFileName = "./state/" + network + "_" + chainId + ".pid";
Expand Down
36 changes: 36 additions & 0 deletions relayer-cli/src/utils/shutdownManager.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import ShutdownManager from "./shutdownManager";

describe("ShutdownManager", () => {
describe("constructor", () => {
it("should create a new instance", () => {
const instance = new ShutdownManager();
expect(instance).toBeInstanceOf(ShutdownManager);
});

it("should set isShuttingDown to the provided value", () => {
const instance = new ShutdownManager(true);
expect(instance["isShuttingDown"]).toBe(true);
mani99brar marked this conversation as resolved.
Show resolved Hide resolved
});

it("should set isShuttingDown to false if no value is provided", () => {
const instance = new ShutdownManager();
expect(instance["isShuttingDown"]).toBe(false);
});
});

describe("getIsShuttingDown", () => {
it("should return true when isShuttingDown is true", () => {
const instance = new ShutdownManager(true);
expect(instance.getIsShuttingDown()).toBe(true);
});

it("should return false when isShuttingDown is false", () => {
const instance = new ShutdownManager(false);
expect(instance.getIsShuttingDown()).toBe(false);
});
});

describe("triggerShutdown", () => {
it.todo("should set isShuttingDown to true");
});
mani99brar marked this conversation as resolved.
Show resolved Hide resolved
});
15 changes: 15 additions & 0 deletions relayer-cli/src/utils/shutdownManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default class ShutdownManager {
private isShuttingDown: boolean;

constructor(initialState: boolean = false) {
this.isShuttingDown = initialState;
}

public getIsShuttingDown(): boolean {
return this.isShuttingDown;
}

public triggerShutdown() {
this.isShuttingDown = true;
}
}
Loading
Loading