From 12201ff3073c0bbdd36a2490079fe9bfe56a9914 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Wed, 19 Feb 2025 23:57:19 +0000 Subject: [PATCH] chore: 1826 --- packages/network/jest.config.js | 4 +-- packages/network/package.json | 8 ++--- .../eth_estimateGas/eth_estimateGas.ts | 4 +-- .../methods/eth_estimateGas/fixture.ts | 36 +++++++++---------- turbo.json | 3 +- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/packages/network/jest.config.js b/packages/network/jest.config.js index 27eab725f..59b01ca60 100644 --- a/packages/network/jest.config.js +++ b/packages/network/jest.config.js @@ -1,6 +1,6 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ // Coverage threshold would apply to yarn test, not yarn test:unit -const isUnitTest = process.env.UNIT; +const applyCodeCoverageLimits = process.env.APPLYCODECOVLIMITS; module.exports = { preset: 'ts-jest', @@ -10,7 +10,7 @@ module.exports = { reporters: ['default', 'jest-junit'], workerThreads: true, coverageThreshold: - isUnitTest !== 'true' + applyCodeCoverageLimits == 'true' ? { global: { branches: 98, diff --git a/packages/network/package.json b/packages/network/package.json index 37baec268..2010f7cbf 100644 --- a/packages/network/package.json +++ b/packages/network/package.json @@ -32,11 +32,11 @@ "format": "prettier --write src/**/*.ts tests/**/*.ts solo-seeding/**/*.ts", "start-thor-solo": "echo 'Starting thor solo node ...' && docker compose -f ../../docker-compose.thor.yml up -d --wait && echo '\nThor solo node started ...'", "stop-thor-solo": "echo 'Stopping thor solo node ...' && docker compose -f ../../docker-compose.thor.yml down && echo 'Thor solo node stopped ...'", - "test:unit": "rm -rf ./coverageUnit && UNIT=true jest --coverage --coverageDirectory=coverageUnit --group=unit", - "test:integration": "rm -rf ./coverageIntegration && jest --coverage --coverageDirectory=coverageIntegration --group=integration", - "test:integration:solo": "(yarn start-thor-solo && yarn test:integration && yarn stop-thor-solo) || yarn stop-thor-solo", + "test:unit": "rm -rf ./coverageUnit && APPLYCODECOVLIMITS=false jest --coverage --coverageDirectory=coverageUnit --group=unit", + "test:integration": "rm -rf ./coverageIntegration && APPLYCODECOVLIMITS=false jest --coverage --coverageDirectory=coverageIntegration --group=integration", + "test:integration:solo": "APPLYCODECOVLIMITS=false yarn start-thor-solo && yarn test:integration && yarn stop-thor-solo || yarn stop-thor-solo", "test:browser": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit --config ./jest.config.browser.js", - "test": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit", + "test": "rm -rf ./coverage && APPLYCODECOVLIMITS=true jest --coverage --coverageDirectory=coverage --group=integration --group=unit", "test:solo": "(yarn start-thor-solo && yarn test && yarn stop-thor-solo) || yarn stop-thor-solo", "test:browser:solo": "(yarn start-thor-solo && yarn test:browser && yarn stop-thor-solo) || yarn stop-thor-solo" }, diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts index b8133e80a..ef3126b03 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts @@ -52,7 +52,7 @@ const ethEstimateGas = async ( { to: inputOptions.to ?? null, value: inputOptions.value ?? '0x0', - data: inputOptions.data ?? '0x0' + data: inputOptions.data ?? '0x' } satisfies SimulateTransactionClause ], inputOptions.from, @@ -62,7 +62,7 @@ const ethEstimateGas = async ( ); // Convert intrinsic gas to hex string and return - return await Promise.resolve('0x' + estimatedGas.totalGas.toString(16)); + return '0x' + estimatedGas.totalGas.toString(16); } catch (e) { throw new JSONRPCInternalError( 'eth_estimateGas()', diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts index 6d5bb8af9..4ebbe643e 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts @@ -1,8 +1,4 @@ -import { Address, Clause, VET } from '@vechain/sdk-core'; -import { - JSONRPCInternalError, - JSONRPCInvalidParams -} from '@vechain/sdk-errors'; +import { JSONRPCInvalidParams } from '@vechain/sdk-errors'; /** * Fixtures for positive cases @@ -11,10 +7,11 @@ const positiveCasesFixtures = [ { description: 'Simple transfer.', input: [ - Clause.transferVET( - Address.of('0x7567d83b7b8d80addcb281a71d54fc7b3364ffed'), - VET.of(1000) - ), + { + from: '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed', + to: '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed', + value: '0x1000' + }, 'latest' ], expected: '0x5208' @@ -30,6 +27,17 @@ const positiveCasesFixtures = [ 'latest' ], expected: '0x45015' + }, + { + description: 'Missing from parameter', + input: [ + { + to: '0x7487d912d03ab9de786278f679592b3730bdd540', + value: '0x1000' + }, + 'latest' + ], + expected: '0x5208' } ]; @@ -42,16 +50,6 @@ const negativeCasesFixtures = [ input: [], expected: JSONRPCInvalidParams }, - { - description: 'Missing parameters', - input: [ - { - to: '0x7487d912d03ab9de786278f679592b3730bdd540' - }, - 'latest' - ], - expected: JSONRPCInternalError - }, { description: 'Missing block reference', input: [ diff --git a/turbo.json b/turbo.json index a5edb4d21..84b2dc8d9 100644 --- a/turbo.json +++ b/turbo.json @@ -2,7 +2,8 @@ "$schema": "https://turbo.build/schema.json", "tasks": { "build": { - "dependsOn": ["^build"] + "dependsOn": ["^build"], + "cache": false }, "check:circular-dependencies": {}, "test": {