Skip to content

Commit

Permalink
chore: coverage threshold (#1356)
Browse files Browse the repository at this point in the history
* chore: added coverage threshold

* chore: added coverage threshold

* chore: added coverage threshold

* chore: added coverage threshold

* chore: added coverage threshold

* chore: added coverage threshold

* chore: commented testnet tests

* chore: commented testnet tests

* chore: commented testnet tests

* chore: commented testnet tests

* chore: functions coverage for network is 99
  • Loading branch information
freemanzMrojo authored Sep 28, 2024
1 parent 5267fd4 commit a09df9b
Show file tree
Hide file tree
Showing 18 changed files with 357 additions and 269 deletions.
10 changes: 9 additions & 1 deletion apps/sdk-nextjs-integration/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ const nextJest = require("next/jest")
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
}
})

// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
testEnvironment: './jest-environment-jsdom.js',
testEnvironment: './jest-environment-jsdom.js'
}

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
Expand Down
50 changes: 26 additions & 24 deletions docs/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,32 @@ In this example the `thorClient` connects to the *testnet* to trace the contract
the `input` parameter.

```typescript { name=debug-trace-contract-call, category=example }
// 1 - Create thor client for testnet
const thorClient = ThorClient.fromUrl(TESTNET_URL);

// 2 - Trace the contract call.
const result = await thorClient.debug.traceContractCall(
{
contractInput: {
to: '0x0000000000000000000000000000456E65726779',
data: '0xa9059cbb0000000000000000000000000000000000000000000000000000456e65726779000000000000000000000000000000000000000000000004563918244f400000',
value: '0x0'
},
transactionOptions: {
caller: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
gasPayer: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
expiration: 18,
blockRef: '0x0101d05409d55cce'
},
config: {}
},
null
);

// 3 - Print the result.
console.log(result);
// // 1 - Create thor client for testnet
// const thorClient = ThorClient.fromUrl(TESTNET_URL);

// // 2 - Trace the contract call.
// const result = await thorClient.debug.traceContractCall(
// {
// contractInput: {
// to: '0x0000000000000000000000000000456E65726779',
// data: '0xa9059cbb0000000000000000000000000000000000000000000000000000456e65726779000000000000000000000000000000000000000000000004563918244f400000',
// value: '0x0'
// },
// transactionOptions: {
// caller: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
// gasPayer: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
// expiration: 18,
// blockRef: '0x0101d05409d55cce'
// },
// config: {}
// },
// null
// );

// // 3 - Print the result.
// console.log(result);

//
```

<details>
Expand Down
51 changes: 26 additions & 25 deletions docs/examples/debug/debug-trace-contract-call.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import { TESTNET_URL, ThorClient } from '@vechain/sdk-network';
// The commented out lines should be used as part of the test on solo {@link https://github.com/vechain/vechain-sdk-js/issues/1357}
// import { TESTNET_URL, ThorClient } from '@vechain/sdk-network';

// START_SNIPPET: DebugTraceContractCallSnippet
// // START_SNIPPET: DebugTraceContractCallSnippet

// 1 - Create thor client for testnet
const thorClient = ThorClient.fromUrl(TESTNET_URL);
// // 1 - Create thor client for testnet
// const thorClient = ThorClient.fromUrl(TESTNET_URL);

// 2 - Trace the contract call.
const result = await thorClient.debug.traceContractCall(
{
contractInput: {
to: '0x0000000000000000000000000000456E65726779',
data: '0xa9059cbb0000000000000000000000000000000000000000000000000000456e65726779000000000000000000000000000000000000000000000004563918244f400000',
value: '0x0'
},
transactionOptions: {
caller: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
gasPayer: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
expiration: 18,
blockRef: '0x0101d05409d55cce'
},
config: {}
},
null
);
// // 2 - Trace the contract call.
// const result = await thorClient.debug.traceContractCall(
// {
// contractInput: {
// to: '0x0000000000000000000000000000456E65726779',
// data: '0xa9059cbb0000000000000000000000000000000000000000000000000000456e65726779000000000000000000000000000000000000000000000004563918244f400000',
// value: '0x0'
// },
// transactionOptions: {
// caller: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
// gasPayer: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
// expiration: 18,
// blockRef: '0x0101d05409d55cce'
// },
// config: {}
// },
// null
// );

// 3 - Print the result.
console.log(result);
// // 3 - Print the result.
// console.log(result);

// END_SNIPPET: DebugTraceContractCallSnippet
// // END_SNIPPET: DebugTraceContractCallSnippet
10 changes: 9 additions & 1 deletion packages/core/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@ module.exports = {
coverageReporters: ['html', 'lcov', 'json'],
runner: 'groups',
reporters: ['default', 'jest-junit'],
workerThreads: true
workerThreads: true,
coverageThreshold: {
global: {
branches: 91,
functions: 92,
lines: 94,
statements: 94
}
}
};
10 changes: 9 additions & 1 deletion packages/errors/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@ module.exports = {
testEnvironment: 'node',
coverageReporters: ['html', 'lcov', 'json'],
runner: 'groups',
reporters: ['default', 'jest-junit']
reporters: ['default', 'jest-junit'],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
}
};
10 changes: 9 additions & 1 deletion packages/ethers-adapter/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@ module.exports = {
coverageReporters: ['html', 'lcov', 'json'],
runner: 'groups',
reporters: ['default', 'jest-junit'],
workerThreads: false
workerThreads: false,
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
}
};
16 changes: 15 additions & 1 deletion packages/hardhat-plugin/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
// Coverage threshold would apply to yarn test, not yarn test:unit
const isUnitTest = process.env.UNIT;

module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
coverageReporters: ['html', 'lcov', 'json'],
runner: 'groups',
reporters: ['default', 'jest-junit'],
workerThreads: false
workerThreads: false,
coverageThreshold:
isUnitTest !== 'true'
? {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
}
: undefined
};
2 changes: 1 addition & 1 deletion packages/hardhat-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"build": "rm -rf ./dist && tsup-node src/index.ts --format cjs,esm --dts",
"lint": "eslint --ext .ts src --ext .ts tests",
"format": "prettier --write src/**/*.ts tests/**/*.ts",
"test:unit": "rm -rf ./coverageUnit && jest --coverage --coverageDirectory=coverageUnit --group=unit",
"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": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit",
"test:solo": "(yarn start-thor-solo && yarn test && yarn stop-thor-solo) || yarn stop-thor-solo"
Expand Down
10 changes: 9 additions & 1 deletion packages/logging/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@ module.exports = {
coverageReporters: ['html', 'lcov', 'json'],
runner: 'groups',
reporters: ['default', 'jest-junit'],
workerThreads: true
workerThreads: true,
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
}
};
16 changes: 15 additions & 1 deletion packages/network/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
// Coverage threshold would apply to yarn test, not yarn test:unit
const isUnitTest = process.env.UNIT;

module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
coverageReporters: ['html', 'lcov', 'json'],
runner: 'groups',
reporters: ['default', 'jest-junit'],
workerThreads: true
workerThreads: true,
coverageThreshold:
isUnitTest !== 'true'
? {
global: {
branches: 99,
functions: 99,
lines: 99,
statements: 99
}
}
: undefined
};
2 changes: 1 addition & 1 deletion packages/network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"build": "rm -rf ./dist && tsup-node src/index.ts --format cjs,esm --dts",
"lint": "eslint --ext .ts src --ext .ts tests",
"format": "prettier --write src/**/*.ts tests/**/*.ts solo-seeding/**/*.ts",
"test:unit": "rm -rf ./coverageUnit && jest --coverage --coverageDirectory=coverageUnit --group=unit",
"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:browser": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit --config ./jest.config.browser.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,55 +41,56 @@ const debugTraceBlockByHashFixture = [
}
}
]
},
// Prestate tracer
{
input: {
params: [
'0x010e80e4c2b06efb61a86f33155d7a1e3f3bd2ae7b676e7d62270079bd1fe329',
{
tracer: 'presStateTracer',
tracerConfig: { onlyTopCall: true }
}
]
},
expected: [
{
txHash: '0x7e7d7ec1510425fd6f68e3dd2369e57af44114fb95b5a26fade14621821c74f3',
result: {
'0x6e1ffe60656421eb12de92433c5a319ba606bb81': {
balance: '0x0',
nonce: 0
},
'0x7487d912d03ab9de786278f679592b3730bdd540': {
balance: '0x422ca8b0a00a425000000',
nonce: 0
},
'0xb4094c25f86d628fdd571afc4077f0d0196afb48': {
balance: '0x14b3cf4cc2f3044b700000',
nonce: 0
}
}
},
{
txHash: '0x5f1eb314b18a906e26f68a6b8a79fcea47edc65d1c30bccccdb5ff3f92f4acee',
result: {
'0x6e1ffe60656421eb12de92433c5a319ba606bb81': {
balance: '0x0',
nonce: 0
},
'0x7487d912d03ab9de786278f679592b3730bdd540': {
balance: '0x422ca8b0a00a425000000',
nonce: 0
},
'0xb4094c25f86d628fdd571afc4077f0d0196afb48': {
balance: '0x14b3cf4cc2f3044b700000',
nonce: 0
}
}
}
]
}
// The commented out lines should be used as part of the test on solo {@link https://github.com/vechain/vechain-sdk-js/issues/1357}
// Prestate tracer
// {
// input: {
// params: [
// '0x010e80e4c2b06efb61a86f33155d7a1e3f3bd2ae7b676e7d62270079bd1fe329',
// {
// tracer: 'presStateTracer',
// tracerConfig: { onlyTopCall: true }
// }
// ]
// },
// expected: [
// {
// txHash: '0x7e7d7ec1510425fd6f68e3dd2369e57af44114fb95b5a26fade14621821c74f3',
// result: {
// '0x6e1ffe60656421eb12de92433c5a319ba606bb81': {
// balance: '0x0',
// nonce: 0
// },
// '0x7487d912d03ab9de786278f679592b3730bdd540': {
// balance: '0x422ca8b0a00a425000000',
// nonce: 0
// },
// '0xb4094c25f86d628fdd571afc4077f0d0196afb48': {
// balance: '0x14b3cf4cc2f3044b700000',
// nonce: 0
// }
// }
// },
// {
// txHash: '0x5f1eb314b18a906e26f68a6b8a79fcea47edc65d1c30bccccdb5ff3f92f4acee',
// result: {
// '0x6e1ffe60656421eb12de92433c5a319ba606bb81': {
// balance: '0x0',
// nonce: 0
// },
// '0x7487d912d03ab9de786278f679592b3730bdd540': {
// balance: '0x422ca8b0a00a425000000',
// nonce: 0
// },
// '0xb4094c25f86d628fdd571afc4077f0d0196afb48': {
// balance: '0x14b3cf4cc2f3044b700000',
// nonce: 0
// }
// }
// }
// ]
// }
];

export { debugTraceBlockByHashFixture };
Loading

1 comment on commit a09df9b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 97%
97.74% (4198/4295) 95.72% (1365/1426) 96.94% (857/884)
Title Tests Skipped Failures Errors Time
core 764 0 💤 0 ❌ 0 🔥 1m 50s ⏱️
network 675 0 💤 0 ❌ 0 🔥 4m 32s ⏱️
errors 42 0 💤 0 ❌ 0 🔥 17.769s ⏱️

Please sign in to comment.