Skip to content

Commit

Permalink
test: runner (#82)
Browse files Browse the repository at this point in the history
* chore: sonarcloud improvements

* fix: eventemitter import

* test: thread sandbox

* chore: ignore binaries from coverage

* test: hide console logs

* test: runner tests

* test: runner pool GN-3478

* chore: add changeset

* chore: increase RPC test timeout

* fix: path
  • Loading branch information
mkykadir authored Dec 4, 2023
1 parent 9af7269 commit 166e091
Show file tree
Hide file tree
Showing 24 changed files with 1,024 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/slow-hairs-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gelatonetwork/web3-functions-sdk": patch
---

fix: make sandbox testable
2 changes: 2 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module.exports = {
"src/web3-functions",
"lib/Web3Function.ts",
"lib/polyfill",
"lib/binaries",
"bin",
"hardhat",
".d.ts",
"__test__",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"format:check": "prettier --check '*/**/*.{js,json,md,ts}'",
"lint": "eslint --cache .",
"test": "ts-node src/bin/index.ts test",
"test:unit": "node --experimental-vm-modules ./node_modules/.bin/jest src --verbose --detectOpenHandles --forceExit --silent=false",
"test:unit": "node --experimental-vm-modules ./node_modules/.bin/jest src --verbose --detectOpenHandles --forceExit --silent=true",
"benchmark": "ts-node src/bin/index.ts benchmark",
"deploy": "ts-node src/bin/index.ts deploy",
"fetch": "ts-node src/bin/index.ts fetch",
Expand All @@ -93,6 +93,7 @@
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@ethersproject/abi": "^5.7.0",
"@jest/globals": "^29.7.0",
"@tsconfig/recommended": "^1.0.1",
"@types/jest": "^29.5.5",
"@types/node": "^16.11.12",
Expand Down
6 changes: 3 additions & 3 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ sonar.javascript.lcov.reportPaths=./coverage/lcov.info

sonar.qualitygate.wait=true

sonar.exclusions=**/*spec.ts,src/lib/polyfill/*,jest.config.ts
sonar.coverage.exclusions=**/*spec.ts,src/lib/polyfill/*,jest.config.ts
sonar.cpd.exclusions=**/*spec.ts,src/lib/polyfill/*,jest.config.ts
sonar.exclusions=**/*spec.ts,src/lib/polyfill/*,jest.config.ts,src/lib/binaries/*,**/__test__/**/*
sonar.coverage.exclusions=**/*spec.ts,src/lib/polyfill/*,jest.config.ts,src/lib/binaries/*,**/__test__/**/*
sonar.cpd.exclusions=**/*spec.ts,src/lib/polyfill/*,jest.config.ts,src/lib/binaries/*,**/__test__/**/*

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=web3-functions-sdk
Expand Down
2 changes: 1 addition & 1 deletion src/lib/provider/Web3FunctionMultiChainProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("Web3FunctionMultiChainProvider", () => {
} catch (error) {
expect(rateLimitInvoked).toBeTruthy();
}
});
}, 20_000);

test("should fail when RPC is not configured for the chainId", async () => {
try {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/provider/Web3FunctionProxyProvider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Web3FunctionProxyProvider } from "./Web3FunctionProxyProvider";
import { MultiChainProviderConfig } from "./types";

import axios from "axios";
import { StaticJsonRpcProvider } from "@ethersproject/providers";
import axios from "axios";

describe("Web3FunctionProxyProvider", () => {
enum TestChainIds {
Expand Down Expand Up @@ -98,7 +98,7 @@ describe("Web3FunctionProxyProvider", () => {

expect(numFulfilled).toEqual(rpcLimit);
expect(numUnfulfilled).toEqual(numRequests - rpcLimit);
});
}, 20_000);

test("should not rate limit whitelisted methods", async () => {
const numRequests = rpcLimit * 2;
Expand Down Expand Up @@ -195,5 +195,5 @@ describe("Web3FunctionProxyProvider", () => {

expect(rpcStats.total).toEqual(numRequests);
expect(rpcStats.throttled).toEqual(numRequests - rpcLimit);
});
}, 20_000);
});
Loading

0 comments on commit 166e091

Please sign in to comment.