-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DO NOT MERGE: prototype running coverage for unit tests
- measure unit test coverage - enforce minimum requirements - generate json reports - unfinished: derive from a common jest config Signed-off-by: Ryan Goulding <[email protected]>
- Loading branch information
1 parent
be21702
commit 1255210
Showing
26 changed files
with
382 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ node_modules | |
Dockerfile | ||
Makefile | ||
*.bats | ||
coverage-fina.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,7 @@ dist | |
.netrc | ||
|
||
# Cache | ||
.cache | ||
.cache | ||
|
||
# Coverage | ||
**/coverage/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../.eslintrc.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<p align="center"> | ||
<a href="https://layerzero.network"> | ||
<img alt="LayerZero" style="max-width: 500px" src="https://d3a2dpnnrypp5h.cloudfront.net/bridge-app/lz.png"/> | ||
</a> | ||
</p> | ||
|
||
<h1 align="center">@layerzerolabs/devtools-evm</h1> | ||
|
||
<!-- The badges section --> | ||
<p align="center"> | ||
<!-- Shields.io NPM published package version --> | ||
<a href="https://www.npmjs.com/package/@layerzerolabs/devtools-evm"><img alt="NPM Version" src="https://img.shields.io/npm/v/@layerzerolabs/devtools-evm"/></a> | ||
<!-- Shields.io NPM downloads --> | ||
<a href="https://www.npmjs.com/package/@layerzerolabs/devtools-evm"><img alt="Downloads" src="https://img.shields.io/npm/dm/@layerzerolabs/devtools-evm"/></a> | ||
<!-- Shields.io license badge --> | ||
<a href="https://www.npmjs.com/package/@layerzerolabs/devtools-evm"><img alt="NPM License" src="https://img.shields.io/npm/l/@layerzerolabs/devtools-evm"/></a> | ||
</p> | ||
|
||
Utilities for working with LayerZero EVM contracts. | ||
|
||
## Installation | ||
|
||
```bash | ||
yarn add @layerzerolabs/devtools-evm | ||
|
||
pnpm add @layerzerolabs/devtools-evm | ||
|
||
npm install @layerzerolabs/devtools-evm | ||
``` | ||
|
||
### Address utilities | ||
|
||
#### ignoreZero(address: Address | null | undefined) | ||
|
||
Turns EVM zero addresses to `undefined` | ||
|
||
```typescript | ||
import { ignoreZero } from "@layerzerolabs/devtools-evm"; | ||
|
||
ignoreZero("0xEe6cF2E1Bc7645F8439d241ce37820305F2BB3F8"); // Returns '0xEe6cF2E1Bc7645F8439d241ce37820305F2BB3F8' | ||
ignoreZero("0x0000000000000000000000000000000000000000"); // Returns undefined | ||
ignoreZero(undefined); // Returns undefined | ||
ignoreZero(null); // Returns undefined | ||
``` | ||
|
||
#### makeZeroAddress(address) | ||
|
||
Turns `null` and `undefined` into EVM zero address | ||
|
||
```typescript | ||
import { makeZeroAddress } from "@layerzerolabs/devtools-evm"; | ||
|
||
makeZeroAddress("0xEe6cF2E1Bc7645F8439d241ce37820305F2BB3F8"); // Returns '0xEe6cF2E1Bc7645F8439d241ce37820305F2BB3F8' | ||
makeZeroAddress("0x0000000000000000000000000000000000000000"); // Returns '0x0000000000000000000000000000000000000000' | ||
makeZeroAddress(undefined); // Returns '0x0000000000000000000000000000000000000000' | ||
makeZeroAddress(null); // Returns '0x0000000000000000000000000000000000000000' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"name": "@layerzerolabs/devtools-config-jest", | ||
"version": "0.0.1", | ||
"description": "Utilities for LayerZero EVM projects", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/LayerZero-Labs/devtools.git", | ||
"directory": "packages/devtools-evm" | ||
}, | ||
"license": "MIT", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs" | ||
}, | ||
"./*": { | ||
"types": "./dist/*.d.ts", | ||
"require": "./dist/*.js", | ||
"import": "./dist/*.mjs" | ||
} | ||
}, | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"./dist/index.*" | ||
], | ||
"scripts": { | ||
"prebuild": "$npm_execpath tsc --noEmit -p tsconfig.build.json", | ||
"build": "$npm_execpath tsup", | ||
"clean": "rm -rf dist", | ||
"dev": "$npm_execpath tsup --watch", | ||
"lint": "$npm_execpath eslint '**/*.{js,ts,json}'", | ||
"lint:fix": "eslint --fix '**/*.{js,ts,json}'", | ||
"test": "jest --ci --changedSince=origin/main" | ||
}, | ||
"dependencies": { | ||
"p-memoize": "~4.0.4" | ||
}, | ||
"devDependencies": { | ||
"@ethersproject/abi": "^5.7.0", | ||
"@ethersproject/abstract-provider": "^5.7.0", | ||
"@ethersproject/abstract-signer": "^5.7.0", | ||
"@ethersproject/address": "~5.7.0", | ||
"@ethersproject/bignumber": "^5.7.0", | ||
"@ethersproject/constants": "^5.7.0", | ||
"@ethersproject/contracts": "^5.7.0", | ||
"@ethersproject/providers": "^5.7.2", | ||
"@layerzerolabs/devtools": "~0.1.3", | ||
"@layerzerolabs/io-devtools": "~0.1.2", | ||
"@layerzerolabs/lz-definitions": "~2.1.3", | ||
"@layerzerolabs/test-devtools": "~0.1.2", | ||
"@swc/core": "^1.4.0", | ||
"@swc/jest": "^0.2.36", | ||
"@types/jest": "^29.5.12", | ||
"fast-check": "^3.15.1", | ||
"jest": "^29.7.0", | ||
"jest-extended": "^4.0.2", | ||
"ts-node": "^10.9.2", | ||
"tslib": "~2.6.2", | ||
"tsup": "~8.0.1", | ||
"typescript": "^5.3.3", | ||
"zod": "^3.22.4" | ||
}, | ||
"peerDependencies": { | ||
"@ethersproject/abi": "^5.7.0", | ||
"@ethersproject/abstract-provider": "^5.7.0", | ||
"@ethersproject/abstract-signer": "^5.7.0", | ||
"@ethersproject/address": "~5.7.0", | ||
"@ethersproject/bignumber": "^5.7.0", | ||
"@ethersproject/constants": "^5.7.0", | ||
"@ethersproject/contracts": "^5.7.0", | ||
"@ethersproject/providers": "^5.7.0", | ||
"@layerzerolabs/devtools": "~0.1.3", | ||
"@layerzerolabs/io-devtools": "~0.1.2", | ||
"@layerzerolabs/lz-definitions": "~2.1.3", | ||
"zod": "^3.22.4" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './jest.config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Config } from 'jest' | ||
|
||
const config: Config = { | ||
coverageThreshold: { | ||
global: { | ||
branches: 80, | ||
functions: 80, | ||
lines: 80, | ||
statements: -10, | ||
}, | ||
}, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"exclude": ["node_modules", "dist", "test"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"exclude": ["dist", "node_modules"], | ||
"include": ["src", "test", "*.config.ts"], | ||
"compilerOptions": { | ||
"types": ["node", "jest"], | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from 'tsup' | ||
|
||
export default defineConfig([ | ||
{ | ||
entry: ['src/index.ts'], | ||
outDir: './dist', | ||
clean: true, | ||
dts: true, | ||
sourcemap: true, | ||
splitting: false, | ||
treeshake: true, | ||
format: ['esm', 'cjs'], | ||
}, | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.