Skip to content

Commit

Permalink
4x tests updates (#7162)
Browse files Browse the repository at this point in the history
* updated config and closeOpenConnection in eth

* no default to http and close open con

* unit test using local provider instead of default in utils

* lint fix

* bug fix of maxListenersWarningThreshold

* fixes in defaults and sys test utils

* lint fix

* tests update

* timeout chenged for contract tests

* DEFAULT_SYSTEM_PROVIDER revert

* cypress timout change

* reusing waitForCondition

* revert tests fix

* watch subscription transaction fix

* waitForCondition

* TransactionBlockTimeoutError tests updates

* updates

* update

* unit test fix

* changelog update
  • Loading branch information
jdevcs authored Aug 2, 2024
1 parent 2706805 commit 5080e80
Show file tree
Hide file tree
Showing 12 changed files with 277 additions and 190 deletions.
6 changes: 5 additions & 1 deletion packages/web3-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,8 @@ Documentation:

- Now when existing packages are added in web3, will be avalible for plugins via context. (#7088)

## [Unreleased]
## [Unreleased]

### Fixed

- `setConfig()` fix for `setMaxListenerWarningThreshold` fix (#5079)
8 changes: 8 additions & 0 deletions packages/web3-core/src/web3_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ export abstract class Web3Config
const keys = Object.keys(options) as (keyof Web3ConfigOptions)[];
for (const key of keys) {
this._triggerConfigChange(key, options[key]);

if(!isNullish(options[key]) &&
typeof options[key] === 'number' &&
key === 'maxListenersWarningThreshold' )
{
// additionally set in event emitter
this.setMaxListenerWarningThreshold(Number(options[key]));
}
}
Object.assign(this.config, options);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-contract/test/integration/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('../config/setup');

const jestTimeout = String(process.env.WEB3_SYSTEM_TEST_PROVIDER).includes('ipc') ? 35000 : 15000;
const jestTimeout = String(process.env.WEB3_SYSTEM_TEST_PROVIDER).includes('ipc') ? 35000 : 25000;

jest.setTimeout(jestTimeout);
12 changes: 6 additions & 6 deletions packages/web3-eth-contract/test/unit/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
GreeterWithOverloadingBytecode,
} from '../shared_fixtures/build/GreeterWithOverloading';
import { AllGetPastEventsData, getLogsData, getPastEventsData } from '../fixtures/unitTestFixtures';
import { getSystemTestProvider } from '../fixtures/system_test_utils';
import { erc721Abi } from '../fixtures/erc721';
import { ERC20TokenAbi } from '../shared_fixtures/build/ERC20Token';
import { processAsync } from '../shared_fixtures/utils';
Expand Down Expand Up @@ -150,7 +149,7 @@ describe('Contract', () => {
});

it('should set the provider, from options, upon instantiation', () => {
const provider = getSystemTestProvider();
const provider = "http://127.0.0.1:4545";
const contract = new Contract([], '', {
provider,
});
Expand All @@ -162,7 +161,7 @@ describe('Contract', () => {
});

it('should set the provider, from context, upon instantiation', () => {
const provider = getSystemTestProvider();
const provider = "http://127.0.0.1:4545";
const contract = new Contract(
[],
'',
Expand Down Expand Up @@ -816,17 +815,18 @@ describe('Contract', () => {
'0x00000000219ab540356cBB839Cbe05303d7705Fa',
{ gas: '0x97254' },
);

contract.maxListenersWarningThreshold = 1000;

const clonnedContract = contract.clone();

expect(stringify(contract)).toStrictEqual(stringify(clonnedContract));

contract.options.jsonInterface = GreeterAbi;
});

it('should clone new contract', () => {
const contract = new Contract(sampleStorageContractABI);

contract.maxListenersWarningThreshold = 1000;

const clonnedContract = contract.clone();
expect(stringify(contract)).toStrictEqual(stringify(clonnedContract));
});
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"test:e2e:sepolia": "jest --config=./test/e2e/jest.config.js --forceExit",
"test:watch": "npm test -- --watch",
"test:unit": "jest --config=./test/unit/jest.config.js",
"test:integration": "jest --config=./test/integration/jest.config.js --runInBand --forceExit",
"test:integration": "jest --config=./test/integration/jest.config.js --runInBand",
"test:coverage:integration": "jest --config=./test/integration/jest.config.js --runInBand --forceExit --coverage=true --coverage-reporters=text",
"test:e2e:electron": "npx cypress run --headless --browser electron",
"test:e2e:chrome": "npx cypress run --headless --browser chrome",
Expand Down
Loading

1 comment on commit 5080e80

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 5080e80 Previous: 2706805 Ratio
processingTx 8980 ops/sec (±4.32%) 9037 ops/sec (±3.98%) 1.01
processingContractDeploy 38011 ops/sec (±6.45%) 39479 ops/sec (±7.28%) 1.04
processingContractMethodSend 15444 ops/sec (±9.38%) 16433 ops/sec (±7.94%) 1.06
processingContractMethodCall 28258 ops/sec (±6.66%) 28728 ops/sec (±5.91%) 1.02
abiEncode 43457 ops/sec (±6.82%) 44544 ops/sec (±7.67%) 1.03
abiDecode 31180 ops/sec (±8.37%) 30083 ops/sec (±7.18%) 0.96
sign 1518 ops/sec (±3.09%) 1568 ops/sec (±0.49%) 1.03
verify 368 ops/sec (±0.97%) 366 ops/sec (±2.62%) 0.99

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.