Skip to content

Commit

Permalink
chore: added test
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielMartinezRodriguez committed Mar 14, 2024
1 parent 8426b10 commit 78eade0
Show file tree
Hide file tree
Showing 8 changed files with 2,396 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ jobs:
yarn workspace @stabilityprotocol/config build
yarn workspace @stabilityprotocol/provider build
- name: Test package
run: |
yarn workspace @stabilityprotocol/config test
yarn workspace @stabilityprotocol/provider test
- name: Publish package
run: |
yarn workspace @stabilityprotocol/config publish --non-interactive --access public
Expand Down
46 changes: 46 additions & 0 deletions packages/config/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { networks, Blockchains } from "../src/index";

describe("Blockchain Enums and Objects", () => {
it("should have the correct values for Blockchains enum", () => {
expect(Blockchains.STABILITY_TESTNET).toEqual("stabilitytestnet");
expect(Blockchains.STABILITY_GTN).toEqual("stabilitygtn");
});

it("should have correct network configurations for STABILITY_TESTNET", () => {
const testnetConfig = networks[Blockchains.STABILITY_TESTNET];
expect(testnetConfig.id).toEqual(20180427);
expect(testnetConfig.name).toEqual("Stability Testnet");
expect(testnetConfig.network).toEqual(Blockchains.STABILITY_TESTNET);
expect(testnetConfig.nativeCurrency.decimals).toEqual(18);
expect(testnetConfig.nativeCurrency.name).toEqual(
"Decentralized Native Token"
);
expect(testnetConfig.nativeCurrency.symbol).toEqual("DNT");
expect(testnetConfig.rpcUrl).toEqual(
"https://free.testnet.stabilityprotocol.com"
);
expect(testnetConfig.blockExplorer).toEqual(
"https://stability-testnet.blockscout.com/"
);
expect(testnetConfig.contracts.multicall3.address).toEqual(
"0x3ed62137c5DB927cb137c26455969116BF0c23Cb"
);
});

it("should have correct network configurations for STABILITY_GTN", () => {
const gtnConfig = networks[Blockchains.STABILITY_GTN];
expect(gtnConfig.id).toEqual(101010);
expect(gtnConfig.name).toEqual("Global Trust Network");
expect(gtnConfig.network).toEqual(Blockchains.STABILITY_GTN);
expect(gtnConfig.nativeCurrency.decimals).toEqual(18);
expect(gtnConfig.nativeCurrency.name).toEqual("Decentralized Native Token");
expect(gtnConfig.nativeCurrency.symbol).toEqual("DNT");
expect(gtnConfig.rpcUrl).toEqual("https://gtn.stabilityprotocol.com");
expect(gtnConfig.blockExplorer).toEqual(
"https://stability-testnet.blockscout.com/"
);
expect(gtnConfig.contracts.multicall3.address).toEqual(
"0xBA2923DAe45aD6b8B77bff4733c75b0C13F0ce2d"
);
});
});
13 changes: 13 additions & 0 deletions packages/config/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Config } from "@jest/types";

// Sync object
const config: Config.InitialOptions = {
verbose: true,
transform: {
"^.+\\.tsx?$": "ts-jest",
},
extensionsToTreatAsEsm: [".ts"],
testMatch: ["**/__tests__/**/*.test.ts"],
testTimeout: 30000,
};
export default config;
9 changes: 7 additions & 2 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"name": "@stabilityprotocol/config",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf dist/ && tsc"
"build": "rm -rf dist/ && tsc",
"test": "jest"
},
"devDependencies": {
"@tsconfig/node16": "^16.1.1",
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.2"
},
"publishConfig": {
Expand Down
38 changes: 38 additions & 0 deletions packages/provider/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ethers } from "ethers";
import { networks } from "@stabilityprotocol/config";
import {
StabilityGtnRpcProvider,
StabilityTestnetRpcProvider,
} from "../src/index";

describe("StabilityGtnRpcProvider", () => {
it("correctly configures the provider instance for the Global Trust Network (STABILITY_GTN) with the correct RPC URL", () => {
const apiKey = "dummyApiKey";
const provider = new StabilityGtnRpcProvider(apiKey);

expect(provider.connection.url).toBe(
`${networks.stabilitygtn.rpcUrl}/${apiKey}`
);
});

it("correctly configures the provider instance for the Stability Testnet (STABILITY_GTN) with the correct CHAIN ID", () => {
const apiKey = "dummyApiKey";
const provider = new StabilityGtnRpcProvider(apiKey);

expect(provider.network.chainId).toBe(networks.stabilitygtn.id);
});
});

describe("StabilityTestnetRpcProvider", () => {
it("correctly configures the provider instance for the Stability Testnet (STABILITY_TESTNET) with the correct RPC URL", () => {
const provider = new StabilityTestnetRpcProvider();

expect(provider.connection.url).toBe(networks.stabilitytestnet.rpcUrl);
});

it("correctly configures the provider instance for the Stability Testnet (STABILITY_TESTNET) with the correct CHAIN ID", () => {
const provider = new StabilityTestnetRpcProvider();

expect(provider.network.chainId).toBe(networks.stabilitytestnet.id);
});
});
13 changes: 13 additions & 0 deletions packages/provider/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Config } from "@jest/types";

// Sync object
const config: Config.InitialOptions = {
verbose: true,
transform: {
"^.+\\.tsx?$": "ts-jest",
},
extensionsToTreatAsEsm: [".ts"],
testMatch: ["**/__tests__/**/*.test.ts"],
testTimeout: 30000,
};
export default config;
10 changes: 7 additions & 3 deletions packages/provider/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{
"name": "@stabilityprotocol/provider",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf dist/ && tsc"
"build": "rm -rf dist/ && tsc",
"test": "jest"
},
"dependencies": {
"@stabilityprotocol/config": "1.0.1",
"@stabilityprotocol/config": "1.0.2",
"ethers": "5.7.2"
},
"devDependencies": {
"@tsconfig/node16": "^16.1.1",
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.2"
},
"publishConfig": {
Expand Down
Loading

0 comments on commit 78eade0

Please sign in to comment.