diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba60ce39f22..ee95deaf804 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -118,6 +118,7 @@ jobs: steps: - uses: actions/setup-node@v4 with: + architecture: x64 node-version: ${{ matrix.node }} - uses: actions/cache/restore@v3 with: diff --git a/packages/web3-core/test/config/jest.config.js b/packages/web3-core/test/config/jest.config.js index 4a60f95b353..74597df99d0 100644 --- a/packages/web3-core/test/config/jest.config.js +++ b/packages/web3-core/test/config/jest.config.js @@ -1,18 +1,18 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', - }, + }, verbose: false, collectCoverage: false, coverageReporters: ['json'], diff --git a/packages/web3-eth-abi/test/config/jest.config.js b/packages/web3-eth-abi/test/config/jest.config.js index c8c21e06e6a..74597df99d0 100644 --- a/packages/web3-eth-abi/test/config/jest.config.js +++ b/packages/web3-eth-abi/test/config/jest.config.js @@ -1,14 +1,14 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', diff --git a/packages/web3-eth-accounts/test/unit/account.test.ts b/packages/web3-eth-accounts/test/unit/account.test.ts index 713ac9e4829..10dae39fbc7 100644 --- a/packages/web3-eth-accounts/test/unit/account.test.ts +++ b/packages/web3-eth-accounts/test/unit/account.test.ts @@ -49,6 +49,8 @@ import { import { TransactionFactory } from '../../src/tx/transactionFactory'; import { TxData } from '../../src/tx/types'; +jest.setTimeout(25000); + describe('accounts', () => { describe('create', () => { describe('valid cases', () => { diff --git a/packages/web3-eth-contract/test/config/jest.config.js b/packages/web3-eth-contract/test/config/jest.config.js index c8c21e06e6a..74597df99d0 100644 --- a/packages/web3-eth-contract/test/config/jest.config.js +++ b/packages/web3-eth-contract/test/config/jest.config.js @@ -1,14 +1,14 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', diff --git a/packages/web3-eth-ens/test/integration/resolver.test.ts b/packages/web3-eth-ens/test/integration/resolver.test.ts index d0d4d5095b1..587ce2e7b29 100644 --- a/packages/web3-eth-ens/test/integration/resolver.test.ts +++ b/packages/web3-eth-ens/test/integration/resolver.test.ts @@ -44,6 +44,7 @@ import { ENSRegistryBytecode } from '../fixtures/ens/bytecode/ENSRegistryBytecod import { NameWrapperBytecode } from '../fixtures/ens/bytecode/NameWrapperBytecode'; import { PublicResolverBytecode } from '../fixtures/ens/bytecode/PublicResolverBytecode'; +jest.setTimeout(25000); describe('ens', () => { let registry: Contract; let resolver: Contract; diff --git a/packages/web3-eth-personal/test/config/jest.config.js b/packages/web3-eth-personal/test/config/jest.config.js index c8c21e06e6a..74597df99d0 100644 --- a/packages/web3-eth-personal/test/config/jest.config.js +++ b/packages/web3-eth-personal/test/config/jest.config.js @@ -1,14 +1,14 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', diff --git a/packages/web3-eth/test/unit/format_transaction.test.ts b/packages/web3-eth/test/unit/format_transaction.test.ts index 028ac043b20..9ce83aaa941 100644 --- a/packages/web3-eth/test/unit/format_transaction.test.ts +++ b/packages/web3-eth/test/unit/format_transaction.test.ts @@ -26,6 +26,7 @@ import { numbersAsNumberTransaction, bytesAsUint8ArrayTransaction, } from '../fixtures/format_transaction'; +import { objectBigintToString } from '../fixtures/system_test_utils'; const transactionsDataForNumberTypes: Record> = { [FMT_NUMBER.BIGINT]: numbersAsBigIntTransaction, @@ -59,14 +60,16 @@ describe('formatTransaction', () => { delete expectedFormattedTransaction.data; expect( - formatTransaction( - transactionsDataForNumberTypes[sourceType as FMT_NUMBER], - { - ...DEFAULT_RETURN_FORMAT, - number: destinationType as FMT_NUMBER, - }, + objectBigintToString( + formatTransaction( + transactionsDataForNumberTypes[sourceType as FMT_NUMBER], + { + ...DEFAULT_RETURN_FORMAT, + number: destinationType as FMT_NUMBER, + }, + ), ), - ).toStrictEqual(expectedFormattedTransaction); + ).toStrictEqual(objectBigintToString(expectedFormattedTransaction)); }); } } @@ -85,11 +88,16 @@ describe('formatTransaction', () => { delete expectedFormattedTransaction.data; expect( - formatTransaction(transactionsDataForByteTypes[sourceType as FMT_BYTES], { - ...DEFAULT_RETURN_FORMAT, - bytes: destinationType as FMT_BYTES, - }), - ).toStrictEqual(expectedFormattedTransaction); + objectBigintToString( + formatTransaction( + transactionsDataForByteTypes[sourceType as FMT_BYTES], + { + ...DEFAULT_RETURN_FORMAT, + bytes: destinationType as FMT_BYTES, + }, + ), + ), + ).toStrictEqual(objectBigintToString(expectedFormattedTransaction)); }); } } diff --git a/packages/web3-net/test/config/jest.config.js b/packages/web3-net/test/config/jest.config.js index c8c21e06e6a..74597df99d0 100644 --- a/packages/web3-net/test/config/jest.config.js +++ b/packages/web3-net/test/config/jest.config.js @@ -1,14 +1,14 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', diff --git a/packages/web3-providers-ipc/test/config/jest.config.js b/packages/web3-providers-ipc/test/config/jest.config.js index 6c71b126961..068de35aa8e 100644 --- a/packages/web3-providers-ipc/test/config/jest.config.js +++ b/packages/web3-providers-ipc/test/config/jest.config.js @@ -1,14 +1,14 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', diff --git a/packages/web3-types/test/config/jest.config.js b/packages/web3-types/test/config/jest.config.js index eaa5e9049da..7d959c45719 100644 --- a/packages/web3-types/test/config/jest.config.js +++ b/packages/web3-types/test/config/jest.config.js @@ -1,14 +1,14 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, verbose: false, collectCoverage: false, diff --git a/packages/web3-utils/src/objects.ts b/packages/web3-utils/src/objects.ts index 6417465e57b..feda5510e4f 100644 --- a/packages/web3-utils/src/objects.ts +++ b/packages/web3-utils/src/objects.ts @@ -36,18 +36,19 @@ export const mergeDeep = ( destination: Record, ...sources: Record[] ): Record => { - const result = { ...destination }; // clone deep here - if (!isIterable(result)) { - return result; + if (!isIterable(destination)) { + return destination; } + const result = { ...destination }; // clone deep here for (const src of sources) { + // const src = { ..._src }; // eslint-disable-next-line no-restricted-syntax for (const key in src) { if (isIterable(src[key])) { if (!result[key]) { result[key] = {}; } - mergeDeep( + result[key] = mergeDeep( result[key] as Record, src[key] as Record, ); diff --git a/packages/web3-utils/test/config/jest.config.js b/packages/web3-utils/test/config/jest.config.js index 4a60f95b353..74597df99d0 100644 --- a/packages/web3-utils/test/config/jest.config.js +++ b/packages/web3-utils/test/config/jest.config.js @@ -1,18 +1,18 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', - }, + }, verbose: false, collectCoverage: false, coverageReporters: ['json'], diff --git a/packages/web3-utils/test/unit/objects.test.ts b/packages/web3-utils/test/unit/objects.test.ts index 07c4f225022..1201b3b7345 100644 --- a/packages/web3-utils/test/unit/objects.test.ts +++ b/packages/web3-utils/test/unit/objects.test.ts @@ -21,9 +21,7 @@ import { mergeDeepData } from '../fixtures/objects'; describe('objects', () => { describe('mergeDeep', () => { it.each(mergeDeepData)('$message', ({ destination, sources, output }) => { - mergeDeep(destination, ...sources); - - expect(destination).toEqual(output); + expect(mergeDeep(destination, ...sources)).toEqual(output); }); it('should not mutate the sources', () => { diff --git a/packages/web3-validator/test/config/jest.config.js b/packages/web3-validator/test/config/jest.config.js index c8c21e06e6a..74597df99d0 100644 --- a/packages/web3-validator/test/config/jest.config.js +++ b/packages/web3-validator/test/config/jest.config.js @@ -1,14 +1,14 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', diff --git a/packages/web3-validator/test/integration/void.test.ts b/packages/web3-validator/test/integration/void.test.ts new file mode 100644 index 00000000000..9fe194cc5fc --- /dev/null +++ b/packages/web3-validator/test/integration/void.test.ts @@ -0,0 +1,22 @@ +/* +This file is part of web3.js. + +web3.js is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +web3.js is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with web3.js. If not, see . +*/ + +describe('Web3 validator test', () => { + it('void', () => { + expect(1).toBe(1); + }); +}); diff --git a/packages/web3/test/cjs_black_box/jest.config.js b/packages/web3/test/cjs_black_box/jest.config.js index 06b150fe5c8..ce489d3d015 100644 --- a/packages/web3/test/cjs_black_box/jest.config.js +++ b/packages/web3/test/cjs_black_box/jest.config.js @@ -6,6 +6,11 @@ module.exports = { }, }, transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, }; diff --git a/packages/web3/test/config/jest.config.js b/packages/web3/test/config/jest.config.js index c8c21e06e6a..74597df99d0 100644 --- a/packages/web3/test/config/jest.config.js +++ b/packages/web3/test/config/jest.config.js @@ -1,14 +1,14 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', diff --git a/packages/web3/test/esm_black_box/jest.config.js b/packages/web3/test/esm_black_box/jest.config.js index d01db385b4b..678e0222c26 100644 --- a/packages/web3/test/esm_black_box/jest.config.js +++ b/packages/web3/test/esm_black_box/jest.config.js @@ -6,6 +6,11 @@ export default { }, }, transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, }; diff --git a/scripts/geth.sh b/scripts/geth.sh index 8469b4e65ab..62c7213ccfb 100755 --- a/scripts/geth.sh +++ b/scripts/geth.sh @@ -12,12 +12,12 @@ start() { if [ -z "${ORIGARGS[1]}" ] then echo "Starting geth..." - echo "docker run -p $WEB3_SYSTEM_TEST_PORT:$WEB3_SYSTEM_TEST_PORT ethereum/client-go:latest --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev" - docker run -p $WEB3_SYSTEM_TEST_PORT:$WEB3_SYSTEM_TEST_PORT ethereum/client-go:latest --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev + echo "docker run -p $WEB3_SYSTEM_TEST_PORT:$WEB3_SYSTEM_TEST_PORT ethereum/client-go:v1.13.14-amd64 --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev" + docker run -p $WEB3_SYSTEM_TEST_PORT:$WEB3_SYSTEM_TEST_PORT ethereum/client-go:v1.13.14-amd64 --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev else echo "Starting geth..." - echo "docker run -d -p $WEB3_SYSTEM_TEST_PORT:$WEB3_SYSTEM_TEST_PORT ethereum/client-go:latest --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev" - docker run -d -p $WEB3_SYSTEM_TEST_PORT:$WEB3_SYSTEM_TEST_PORT ethereum/client-go:latest --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev + echo "docker run -d -p $WEB3_SYSTEM_TEST_PORT:$WEB3_SYSTEM_TEST_PORT ethereum/client-go:v1.13.14-amd64 --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev" + docker run -d -p $WEB3_SYSTEM_TEST_PORT:$WEB3_SYSTEM_TEST_PORT ethereum/client-go:v1.13.14-amd64 --nodiscover --nousb --ws --ws.addr 0.0.0.0 --ws.port $WEB3_SYSTEM_TEST_PORT --http --http.addr 0.0.0.0 --http.port $WEB3_SYSTEM_TEST_PORT --allow-insecure-unlock --http.api personal,web3,eth,admin,debug,txpool,net --ws.api personal,web3,eth,admin,debug,miner,txpool,net --dev echo "Waiting for geth..." npx wait-port -t 10000 "$WEB3_SYSTEM_TEST_PORT" echo "Geth started" diff --git a/scripts/geth_binary.sh b/scripts/geth_binary.sh index 927783acbe2..96212d04a77 100755 --- a/scripts/geth_binary.sh +++ b/scripts/geth_binary.sh @@ -21,11 +21,11 @@ getOS(){ getDownloadLink(){ case "$OS" in SOLARIS*) LINK="-" ;; - OSX*) LINK="https://gethstore.blob.core.windows.net/builds/geth-darwin-amd64-1.13.8-b20b4a71.tar.gz" ;; - LINUX*) LINK="https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.13.8-b20b4a71.tar.gz" ;; - BSD*) LINK="https://gethstore.blob.core.windows.net/builds/geth-darwin-amd64-1.13.8-b20b4a71.tar.gz" ;; - WINDOWS*) LINK="https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.13.8-b20b4a71.exe" ;; - "ALSO WINDOWS"*) LINK="https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.13.8-b20b4a71.exe" ;; + OSX*) LINK="https://gethstore.blob.core.windows.net/builds/geth-darwin-arm64-1.13.14-2bd6bd01.tar.gz" ;; + LINUX*) LINK="https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.13.14-2bd6bd01.tar.gz" ;; + BSD*) LINK="https://gethstore.blob.core.windows.net/builds/geth-darwin-arm64-1.13.14-2bd6bd01.tar.gz" ;; + WINDOWS*) LINK="https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.13.14-2bd6bd01.exe" ;; + "ALSO WINDOWS"*) LINK="https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.13.14-2bd6bd01.exe" ;; *) LINK="-" ;; esac } diff --git a/scripts/system_tests_utils.ts b/scripts/system_tests_utils.ts index ea84d21f03e..a502c44825e 100644 --- a/scripts/system_tests_utils.ts +++ b/scripts/system_tests_utils.ts @@ -26,7 +26,7 @@ import { } from 'web3-eth-accounts'; // eslint-disable-next-line import/no-extraneous-dependencies -import HardhatPlugin from 'web3-hardhat-plugin'; +import HardhatPlugin from 'web3-hardhat-plugin'; // eslint-disable-next-line import/no-extraneous-dependencies import { prepareTransactionForSigning, Web3Eth } from 'web3-eth'; // eslint-disable-next-line import/no-extraneous-dependencies @@ -257,33 +257,34 @@ export const createNewAccount = async (config?: { const clientUrl = DEFAULT_SYSTEM_PROVIDER; if (config?.unlock) { - - if (getSystemTestBackend() === BACKEND.HARDHAT){ + if (getSystemTestBackend() === BACKEND.HARDHAT) { const url = getSystemTestProviderUrl(); const web3 = new Web3(url); - web3.registerPlugin(new HardhatPlugin()) + web3.registerPlugin(new HardhatPlugin()); await web3.hardhat.impersonateAccount(acc.address); // await impersonateAccount(acc.address); await web3.hardhat.setBalance(acc.address, web3.utils.toHex('100000000')); } else { - const web3Personal = new Personal(clientUrl); - if (!config?.doNotImport) { - await web3Personal.importRawKey( - getSystemTestBackend() === BACKEND.GETH ? acc.privateKey.slice(2) : acc.privateKey, - config.password ?? '123456', - ); - } + const web3Personal = new Personal(clientUrl); + if (!config?.doNotImport) { + await web3Personal.importRawKey( + getSystemTestBackend() === BACKEND.GETH + ? acc.privateKey.slice(2) + : acc.privateKey, + config.password ?? '123456', + ); + } - await web3Personal.unlockAccount(acc.address, config.password ?? '123456', 100000000); + await web3Personal.unlockAccount(acc.address, config.password ?? '123456', 100000000); } } if (config?.refill) { - if (getSystemTestBackend() === BACKEND.HARDHAT){ + if (getSystemTestBackend() === BACKEND.HARDHAT) { const url = getSystemTestProviderUrl(); const web3 = new Web3(url); - web3.registerPlugin(new HardhatPlugin()) - await web3.hardhat.setBalance(acc.address, web3.utils.toHex('100000000')) + web3.registerPlugin(new HardhatPlugin()); + await web3.hardhat.setBalance(acc.address, web3.utils.toHex('100000000')); } else { const web3Personal = new Personal(clientUrl); if (!mainAcc) { @@ -337,7 +338,7 @@ export const createTempAccount = async ( currentIndex += 1; return acc; - } +}; export const getSystemTestAccountsWithKeys = async (): Promise< { @@ -496,3 +497,10 @@ export const sendFewSampleTxs = async (cnt = 1) => { await closeOpenConnection(web3); return res; }; + +export const objectBigintToString = (obj: object): object => + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + JSON.parse( + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + JSON.stringify(obj, (_, value) => (typeof value === 'bigint' ? value.toString() : value)), + ); diff --git a/templates/jest.config.js.tmpl b/templates/jest.config.js.tmpl index d7789fbbbd0..e4d70e55a94 100644 --- a/templates/jest.config.js.tmpl +++ b/templates/jest.config.js.tmpl @@ -15,23 +15,20 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1', - }, + }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, - moduleNameMapper: { - '^(\\.{1,2}/.*)\\.js$': '$1', - }, verbose: false, collectCoverage: false, coverageReporters: ['json'], diff --git a/tools/web3-plugin-example/test/config/jest.config.js b/tools/web3-plugin-example/test/config/jest.config.js index eaa5e9049da..7d959c45719 100644 --- a/tools/web3-plugin-example/test/config/jest.config.js +++ b/tools/web3-plugin-example/test/config/jest.config.js @@ -1,14 +1,14 @@ module.exports = { - globals: { - 'ts-jest': { - tsconfig: './test/tsconfig.json', - }, - }, rootDir: '../..', testMatch: ['/test/**/?(*.)+(spec|test).+(ts|tsx|js)'], setupFilesAfterEnv: ['/test/config/setup.js'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx)$': [ + 'ts-jest', + { + tsconfig: './test/tsconfig.json', + }, + ], }, verbose: false, collectCoverage: false,