@marinade.finance/web3js-1x-testing 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # web3js-1x-testing
2
+
3
+ [`@marinade.finance/web3js-1x-testing`](https://www.npmjs.com/package/@marinade.finance/web3js-1x-testing)
4
+
5
+ Testing utilities to work with
6
+ [Solana web3.js](https://github.com/solana-labs/solana-web3.js/) library
7
+ in **version 1.x**
8
+
9
+ ### Dependencies
10
+
11
+ Library defines set of `peerDependencies` that are required to be directly installed by dependent program.
12
+
13
+
14
+ ```sh
15
+ pnpm add -D @solana/web3.js@1
16
+ pnpm add -D bn.js@5.2.2
17
+ ```
18
+
19
+ ### Installation
20
+
21
+ ```sh
22
+ # see Pre-requisites and Dependencies
23
+ pnpm add @marinade.finance/web3js-1x-testing@latest
24
+ ```
25
+
26
+ ## Jest test equality testers
27
+
28
+ When used with testing framework jest to use `equalityTesters`, also install
29
+
30
+ ```sh
31
+ pnpm add -D @jest/globals@^30.1.2
32
+ ```
33
+
34
+ add to `jest.config.js` something like this
35
+
36
+ ```js
37
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
38
+ module.exports = {
39
+ preset: 'ts-jest',
40
+ testEnvironment: 'node',
41
+ testTimeout: 90000,
42
+ detectOpenHandles: true,
43
+ modulePathIgnorePatterns: ['<rootDir>/build/'],
44
+ testPathIgnorePatterns: ['__tests__/.*.skip.ts', '__tests__/setup/*'],
45
+ globalSetup:
46
+ '<rootDir>/packages/marinade-ts-cli/__tests__/setup/globalSetup.ts',
47
+ setupFilesAfterEnv: ['<rootDir>/<path-to-package>/node_modules/@marinade.finance/web3js-1x-testing/dist/src/equalityTesters'],
48
+ }
49
+ ```
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@marinade.finance/web3js-1x-testing",
3
+ "version": "4.1.3",
4
+ "description": "solana/web3.js 1.x testing helper library",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git@github.com:marinade-finance/typescript-common.git"
8
+ },
9
+ "main": "dist/src/index.js",
10
+ "types": "dist/src/index.d.ts",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "keywords": [
15
+ "solana",
16
+ "marinade.finance",
17
+ "staking",
18
+ "blockchain",
19
+ "lib"
20
+ ],
21
+ "files": [
22
+ "dist/",
23
+ "README.md"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsc --build",
27
+ "test": "pnpm jest --config ../../jest.config.js --testPathPattern=\"$(pwd)\""
28
+ },
29
+ "devDependencies": {
30
+ "@types/bn.js": "^5.2.0",
31
+ "bn.js": "5.2.2",
32
+ "@solana/web3.js": "1.98.4",
33
+ "@jest/globals": "^30.1.2"
34
+ },
35
+ "dependencies": {
36
+ "yaml": "2.8.1"
37
+ },
38
+ "peerDependencies": {
39
+ "@solana/web3.js": "^1.98.4",
40
+ "bn.js": "^5.2.2",
41
+ "@types/bn.js": "^5.2.0",
42
+ "@jest/globals": "^29 || ^30"
43
+ },
44
+ "engines": {
45
+ "node": ">=20"
46
+ }
47
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=equalityTesters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equalityTesters.d.ts","sourceRoot":"","sources":["../../src/equalityTesters.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const globals_1 = require("@jest/globals");
7
+ const web3_js_1 = require("@solana/web3.js");
8
+ const bn_js_1 = __importDefault(require("bn.js"));
9
+ globals_1.expect.addEqualityTesters([
10
+ (a, b) => {
11
+ const bnA = convertNumberToBN(a);
12
+ const bnB = convertNumberToBN(b);
13
+ if (bnA instanceof bn_js_1.default) {
14
+ return bnA.eq(bnB);
15
+ }
16
+ return undefined;
17
+ },
18
+ (a, b) => {
19
+ if (a instanceof web3_js_1.PublicKey) {
20
+ return a.equals(b);
21
+ }
22
+ return undefined;
23
+ },
24
+ ]);
25
+ function convertNumberToBN(value) {
26
+ if (typeof value === 'bigint') {
27
+ return new bn_js_1.default(value.toString());
28
+ }
29
+ if (typeof value === 'number') {
30
+ return new bn_js_1.default(value);
31
+ }
32
+ return value;
33
+ }
34
+ //# sourceMappingURL=equalityTesters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equalityTesters.js","sourceRoot":"","sources":["../../src/equalityTesters.ts"],"names":[],"mappings":";;;;;AAAA,2CAAsC;AACtC,6CAA2C;AAC3C,kDAAsB;AAatB,gBAAM,CAAC,kBAAkB,CAAC;IAExB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACP,MAAM,GAAG,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;QAChC,MAAM,GAAG,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;QAChC,IAAI,GAAG,YAAY,eAAE,EAAE,CAAC;YACtB,OAAO,GAAG,CAAC,EAAE,CAAC,GAAS,CAAC,CAAA;QAC1B,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACP,IAAI,CAAC,YAAY,mBAAS,EAAE,CAAC;YAC3B,OAAO,CAAC,CAAC,MAAM,CAAC,CAAc,CAAC,CAAA;QACjC,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF,CAAC,CAAA;AAEF,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,eAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IACjC,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,eAAE,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@marinade.finance/web3js-1x-testing",
3
+ "version": "4.1.3",
4
+ "description": "solana/web3.js 1.x testing helper library",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git@github.com:marinade-finance/typescript-common.git"
8
+ },
9
+ "main": "dist/src/index.js",
10
+ "types": "dist/src/index.d.ts",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "keywords": [
15
+ "solana",
16
+ "marinade.finance",
17
+ "staking",
18
+ "blockchain",
19
+ "lib"
20
+ ],
21
+ "files": [
22
+ "dist/",
23
+ "README.md"
24
+ ],
25
+ "devDependencies": {
26
+ "@types/bn.js": "^5.2.0",
27
+ "bn.js": "5.2.2",
28
+ "@solana/web3.js": "1.98.4",
29
+ "@jest/globals": "^30.1.2"
30
+ },
31
+ "dependencies": {
32
+ "yaml": "2.8.1"
33
+ },
34
+ "peerDependencies": {
35
+ "@solana/web3.js": "^1.98.4",
36
+ "bn.js": "^5.2.2",
37
+ "@types/bn.js": "^5.2.0",
38
+ "@jest/globals": "^29 || ^30"
39
+ },
40
+ "engines": {
41
+ "node": ">=20"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc --build",
45
+ "test": "pnpm jest --config ../../jest.config.js --testPathPattern=\"$(pwd)\""
46
+ }
47
+ }