diff --git a/packages/web3-eth-contract/package.json b/packages/web3-eth-contract/package.json
index 20b368174c8..0cd539d966b 100644
--- a/packages/web3-eth-contract/package.json
+++ b/packages/web3-eth-contract/package.json
@@ -39,7 +39,7 @@
"test:ci": "jest --coverage=true --coverage-reporters=json --verbose",
"test:watch": "npm test -- --watch",
"test:unit": "jest --config=./test/unit/jest.config.js",
- "test:integration": "jest --config=./test/integration/jest.config.js --runInBand",
+ "test:integration": "jest --config=./test/integration/jest.config.js --runInBand --detectOpenHandles",
"test:e2e:electron": "npx cypress run --headless --browser electron --env grep='ignore',invert=true",
"test:e2e:chrome": "npx cypress run --headless --browser chrome --env grep='ignore',invert=true",
"test:e2e:firefox": "npx cypress run --headless --browser firefox --env grep='ignore',invert=true"
diff --git a/packages/web3-eth-contract/test/integration/contract_accesslist.test.ts b/packages/web3-eth-contract/test/integration/contract_accesslist.test.ts
index 3173f452c33..8200bfd8f7b 100644
--- a/packages/web3-eth-contract/test/integration/contract_accesslist.test.ts
+++ b/packages/web3-eth-contract/test/integration/contract_accesslist.test.ts
@@ -23,6 +23,7 @@ import {
describeIf,
getSystemTestBackend,
BACKEND,
+ closeOpenConnection,
} from '../fixtures/system_test_utils';
describe('contract', () => {
@@ -46,6 +47,10 @@ describe('contract', () => {
sendOptions = { from: acc.address, gas: '1000000' };
});
+ afterAll(async () => {
+ await closeOpenConnection(contract);
+ });
+
it('create access list for setter', async () => {
const deployedContract = await contract.deploy(deployOptions).send(sendOptions);
deployedContract.defaultAccount = acc.address;
diff --git a/packages/web3-eth-contract/test/integration/contract_clone.test.ts b/packages/web3-eth-contract/test/integration/contract_clone.test.ts
index 873ac0658ea..ca042470eb5 100644
--- a/packages/web3-eth-contract/test/integration/contract_clone.test.ts
+++ b/packages/web3-eth-contract/test/integration/contract_clone.test.ts
@@ -16,13 +16,18 @@ along with web3.js. If not, see .
*/
import { Contract } from '../../src';
import { GreeterBytecode, GreeterAbi } from '../shared_fixtures/build/Greeter';
-import { getSystemTestProvider, createTempAccount } from '../fixtures/system_test_utils';
+import {
+ getSystemTestProvider,
+ createTempAccount,
+ closeOpenConnection,
+} from '../fixtures/system_test_utils';
describe('contract', () => {
describe('clone', () => {
let contract: Contract;
let deployOptions: Record;
let sendOptions: Record;
+
beforeAll(async () => {
contract = new Contract(GreeterAbi, undefined, {
provider: getSystemTestProvider(),
@@ -37,12 +42,18 @@ describe('contract', () => {
sendOptions = { from: acc.address, gas: '1000000' };
});
+ afterAll(async () => {
+ await closeOpenConnection(contract);
+ });
+
it('should clone the contract but with same address', async () => {
const deployedContract = await contract.deploy(deployOptions).send(sendOptions);
const newContract = deployedContract.clone();
expect(newContract).toBeInstanceOf(Contract);
expect(newContract).not.toBe(deployedContract);
expect(newContract.options.address).toBe(deployedContract.options.address);
+
+ await closeOpenConnection(newContract);
});
});
});
diff --git a/packages/web3-eth-contract/test/integration/contract_defaults.test.ts b/packages/web3-eth-contract/test/integration/contract_defaults.x.ts
similarity index 95%
rename from packages/web3-eth-contract/test/integration/contract_defaults.test.ts
rename to packages/web3-eth-contract/test/integration/contract_defaults.x.ts
index b481237c739..52639b2af42 100644
--- a/packages/web3-eth-contract/test/integration/contract_defaults.test.ts
+++ b/packages/web3-eth-contract/test/integration/contract_defaults.x.ts
@@ -20,7 +20,11 @@ import { Web3Context } from 'web3-core';
import { Contract } from '../../src';
import { GreeterBytecode, GreeterAbi } from '../shared_fixtures/build/Greeter';
-import { getSystemTestProvider, createTempAccount } from '../fixtures/system_test_utils';
+import {
+ getSystemTestProvider,
+ createTempAccount,
+ closeOpenConnection,
+} from '../fixtures/system_test_utils';
describe('contract', () => {
describe('defaults', () => {
@@ -43,6 +47,10 @@ describe('contract', () => {
sendOptions = { from: acc.address, gas: '1000000' };
});
+ afterAll(async () => {
+ await closeOpenConnection(contract);
+ });
+
it('should use "defaultAccount" on "instance" level instead of "from"', async () => {
const deployedContract = await contract.deploy(deployOptions).send(sendOptions);
// eslint-disable-next-line prefer-destructuring
diff --git a/packages/web3-eth-contract/test/integration/contract_defaults_extra.test.ts b/packages/web3-eth-contract/test/integration/contract_defaults_extra.x.ts
similarity index 99%
rename from packages/web3-eth-contract/test/integration/contract_defaults_extra.test.ts
rename to packages/web3-eth-contract/test/integration/contract_defaults_extra.x.ts
index 206b10ee709..eba08ad3b40 100644
--- a/packages/web3-eth-contract/test/integration/contract_defaults_extra.test.ts
+++ b/packages/web3-eth-contract/test/integration/contract_defaults_extra.x.ts
@@ -59,7 +59,7 @@ describe('contract defaults (extra)', () => {
sendOptions = { from: acc.address, gas: '1000000' };
});
- afterEach(async () => {
+ afterAll(async () => {
await closeOpenConnection(contract);
});
diff --git a/packages/web3-eth-contract/test/integration/contract_deploy.test.ts b/packages/web3-eth-contract/test/integration/contract_deploy.x.ts
similarity index 100%
rename from packages/web3-eth-contract/test/integration/contract_deploy.test.ts
rename to packages/web3-eth-contract/test/integration/contract_deploy.x.ts
diff --git a/packages/web3-eth-contract/test/integration/contract_empty_string.test.ts b/packages/web3-eth-contract/test/integration/contract_empty_string.x.ts
similarity index 89%
rename from packages/web3-eth-contract/test/integration/contract_empty_string.test.ts
rename to packages/web3-eth-contract/test/integration/contract_empty_string.x.ts
index 25540c2ebf4..332801421be 100644
--- a/packages/web3-eth-contract/test/integration/contract_empty_string.test.ts
+++ b/packages/web3-eth-contract/test/integration/contract_empty_string.x.ts
@@ -16,13 +16,18 @@ along with web3.js. If not, see .
*/
import { Contract } from '../../src';
-import { getSystemTestProvider, createTempAccount } from '../fixtures/system_test_utils';
+import {
+ getSystemTestProvider,
+ createTempAccount,
+ closeOpenConnection,
+} from '../fixtures/system_test_utils';
import { MyContractAbi, MyContractBytecode } from '../fixtures/MyContract';
describe('request empty string from contract', () => {
let contract: Contract;
let deployOptions: Record;
let sendOptions: Record;
+
beforeAll(async () => {
contract = new Contract(MyContractAbi, undefined, {
provider: getSystemTestProvider(),
@@ -37,6 +42,10 @@ describe('request empty string from contract', () => {
sendOptions = { from: acc.address, gas: '1000000' };
});
+ afterAll(async () => {
+ await closeOpenConnection(contract);
+ });
+
it('should fetch empty string', async () => {
const deployedContract = await contract.deploy(deployOptions).send(sendOptions);
diff --git a/packages/web3-eth-contract/test/integration/contract_erc20.test.ts b/packages/web3-eth-contract/test/integration/contract_erc20.x.ts
similarity index 99%
rename from packages/web3-eth-contract/test/integration/contract_erc20.test.ts
rename to packages/web3-eth-contract/test/integration/contract_erc20.x.ts
index 890163239b5..5dea78f2c50 100644
--- a/packages/web3-eth-contract/test/integration/contract_erc20.test.ts
+++ b/packages/web3-eth-contract/test/integration/contract_erc20.x.ts
@@ -80,10 +80,6 @@ describe('contract', () => {
contractDeployed = await contract.deploy(deployOptions).send(sendOptions);
});
- afterAll(async () => {
- await closeOpenConnection(contractDeployed);
- });
-
describe('methods', () => {
it('should return the name', async () => {
expect(await contractDeployed.methods.name().call()).toBe('Gold');
diff --git a/packages/web3-eth-contract/test/integration/contract_erc721.test.ts b/packages/web3-eth-contract/test/integration/contract_erc721.x.ts
similarity index 99%
rename from packages/web3-eth-contract/test/integration/contract_erc721.test.ts
rename to packages/web3-eth-contract/test/integration/contract_erc721.x.ts
index 14e3d9fa859..e42893f5697 100644
--- a/packages/web3-eth-contract/test/integration/contract_erc721.test.ts
+++ b/packages/web3-eth-contract/test/integration/contract_erc721.x.ts
@@ -54,7 +54,6 @@ describe('contract', () => {
afterAll(async () => {
await closeOpenConnection(contract);
- await closeOpenConnection(contractDeployed);
});
it('should deploy the contract', async () => {
diff --git a/packages/web3-eth-contract/test/integration/contract_estimateGas_without_0x.test.ts b/packages/web3-eth-contract/test/integration/contract_estimateGas_without_0x.x.ts
similarity index 100%
rename from packages/web3-eth-contract/test/integration/contract_estimateGas_without_0x.test.ts
rename to packages/web3-eth-contract/test/integration/contract_estimateGas_without_0x.x.ts
diff --git a/packages/web3-eth-contract/test/integration/contract_events.test.ts b/packages/web3-eth-contract/test/integration/contract_events.x.ts
similarity index 99%
rename from packages/web3-eth-contract/test/integration/contract_events.test.ts
rename to packages/web3-eth-contract/test/integration/contract_events.x.ts
index 3f7d78db643..1bf3340d4a1 100644
--- a/packages/web3-eth-contract/test/integration/contract_events.test.ts
+++ b/packages/web3-eth-contract/test/integration/contract_events.x.ts
@@ -43,7 +43,6 @@ describe('contract', () => {
afterAll(async () => {
await closeOpenConnection(contract);
- await closeOpenConnection(contractDeployed);
});
beforeEach(async () => {
diff --git a/packages/web3-eth-contract/test/integration/contract_filter_events.test.ts b/packages/web3-eth-contract/test/integration/contract_filter_events.x.ts
similarity index 100%
rename from packages/web3-eth-contract/test/integration/contract_filter_events.test.ts
rename to packages/web3-eth-contract/test/integration/contract_filter_events.x.ts
diff --git a/packages/web3-eth-contract/test/integration/contract_methods.test.ts b/packages/web3-eth-contract/test/integration/contract_methods.x.ts
similarity index 100%
rename from packages/web3-eth-contract/test/integration/contract_methods.test.ts
rename to packages/web3-eth-contract/test/integration/contract_methods.x.ts
diff --git a/packages/web3-eth-contract/test/integration/contract_methods_errors.test.ts b/packages/web3-eth-contract/test/integration/contract_methods_errors.x.ts
similarity index 100%
rename from packages/web3-eth-contract/test/integration/contract_methods_errors.test.ts
rename to packages/web3-eth-contract/test/integration/contract_methods_errors.x.ts
diff --git a/packages/web3-eth-contract/test/integration/contract_negative_numbers.test.ts b/packages/web3-eth-contract/test/integration/contract_negative_numbers.x.ts
similarity index 100%
rename from packages/web3-eth-contract/test/integration/contract_negative_numbers.test.ts
rename to packages/web3-eth-contract/test/integration/contract_negative_numbers.x.ts
diff --git a/packages/web3-eth-contract/test/integration/contract_simple_overloaded.test.ts b/packages/web3-eth-contract/test/integration/contract_simple_overloaded.x.ts
similarity index 100%
rename from packages/web3-eth-contract/test/integration/contract_simple_overloaded.test.ts
rename to packages/web3-eth-contract/test/integration/contract_simple_overloaded.x.ts
diff --git a/packages/web3-eth-contract/test/integration/local_account/contract_deploy.test.ts b/packages/web3-eth-contract/test/integration/local_account/contract_deploy.x.ts
similarity index 96%
rename from packages/web3-eth-contract/test/integration/local_account/contract_deploy.test.ts
rename to packages/web3-eth-contract/test/integration/local_account/contract_deploy.x.ts
index 821101ca225..108f50d6d17 100644
--- a/packages/web3-eth-contract/test/integration/local_account/contract_deploy.test.ts
+++ b/packages/web3-eth-contract/test/integration/local_account/contract_deploy.x.ts
@@ -20,7 +20,11 @@ import Web3 from 'web3';
// eslint-disable-next-line import/no-extraneous-dependencies
import { Web3Account } from 'web3-eth-accounts';
import { GreeterBytecode, GreeterAbi } from '../../shared_fixtures/build/Greeter';
-import { getSystemTestProvider, createLocalAccount } from '../../fixtures/system_test_utils';
+import {
+ getSystemTestProvider,
+ createLocalAccount,
+ closeOpenConnection,
+} from '../../fixtures/system_test_utils';
import { Contract } from '../../../src';
describe('contract', () => {
@@ -45,6 +49,10 @@ describe('contract', () => {
};
});
+ afterAll(async () => {
+ await closeOpenConnection(contract);
+ });
+
it.each(['0x1', '0x2'])('should emit the "sending" event', async txType => {
const handler = jest.fn();
const acc = await createLocalAccount(web3);
diff --git a/packages/web3-eth-contract/test/integration/local_account/contract_erc20.test.ts b/packages/web3-eth-contract/test/integration/local_account/contract_erc20.x.ts
similarity index 97%
rename from packages/web3-eth-contract/test/integration/local_account/contract_erc20.test.ts
rename to packages/web3-eth-contract/test/integration/local_account/contract_erc20.x.ts
index edff03fe598..564d9b6623f 100644
--- a/packages/web3-eth-contract/test/integration/local_account/contract_erc20.test.ts
+++ b/packages/web3-eth-contract/test/integration/local_account/contract_erc20.x.ts
@@ -21,7 +21,11 @@ import Web3 from 'web3';
import { Web3Account } from 'web3-eth-accounts';
import { Contract } from '../../../src';
import { ERC20TokenAbi, ERC20TokenBytecode } from '../../shared_fixtures/build/ERC20Token';
-import { getSystemTestProvider, createLocalAccount } from '../../fixtures/system_test_utils';
+import {
+ getSystemTestProvider,
+ createLocalAccount,
+ closeOpenConnection,
+} from '../../fixtures/system_test_utils';
const initialSupply = BigInt('5000000000');
@@ -53,6 +57,10 @@ describe('contract', () => {
contractDeployed = await contract.deploy(deployOptions).send(sendOptions);
});
+ afterAll(async () => {
+ await closeOpenConnection(contract);
+ });
+
it('should deploy the contract', () => {
expect(contractDeployed.options.address).toBeDefined();
});
diff --git a/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts b/packages/web3-eth-contract/test/integration/local_account/contract_erc721..ts
similarity index 98%
rename from packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts
rename to packages/web3-eth-contract/test/integration/local_account/contract_erc721..ts
index d9226c580f1..9399564a68c 100644
--- a/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts
+++ b/packages/web3-eth-contract/test/integration/local_account/contract_erc721..ts
@@ -21,7 +21,11 @@ import Web3 from 'web3';
import { Web3Account } from 'web3-eth-accounts';
import { Contract } from '../../../src';
import { ERC721TokenAbi, ERC721TokenBytecode } from '../../shared_fixtures/build/ERC721Token';
-import { getSystemTestProvider, createLocalAccount } from '../../fixtures/system_test_utils';
+import {
+ getSystemTestProvider,
+ createLocalAccount,
+ closeOpenConnection,
+} from '../../fixtures/system_test_utils';
import { toUpperCaseHex } from '../../shared_fixtures/utils';
describe('contract', () => {
@@ -32,6 +36,7 @@ describe('contract', () => {
let localAccount: Web3Account;
let web3: Web3;
let contractDeployed: Contract;
+
beforeAll(async () => {
web3 = new Web3(getSystemTestProvider());
localAccount = await createLocalAccount(web3);
@@ -53,6 +58,10 @@ describe('contract', () => {
.send({ ...sendOptions, gas: '3000000' });
});
+ afterAll(async () => {
+ await closeOpenConnection(contract);
+ });
+
it('should deploy the contract', () => {
expect(contractDeployed.options.address).toBeDefined();
});
diff --git a/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts b/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.x.ts
similarity index 95%
rename from packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts
rename to packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.x.ts
index 96985cda3a7..dacea9de7f1 100644
--- a/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts
+++ b/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.x.ts
@@ -23,7 +23,11 @@ import { utf8ToHex } from 'web3-utils';
import { EventLog } from 'web3-types';
import { Contract } from '../../../src';
import { ERC721TokenAbi, ERC721TokenBytecode } from '../../shared_fixtures/build/ERC721Token';
-import { getSystemTestProvider, createLocalAccount } from '../../fixtures/system_test_utils';
+import {
+ getSystemTestProvider,
+ createLocalAccount,
+ closeOpenConnection,
+} from '../../fixtures/system_test_utils';
import { toUpperCaseHex } from '../../shared_fixtures/utils';
describe('contract ERC721 overloaded functions', () => {
@@ -55,6 +59,10 @@ describe('contract ERC721 overloaded functions', () => {
.send({ ...sendOptions, gas: '3000000' });
});
+ afterAll(async () => {
+ await closeOpenConnection(contract);
+ });
+
it('transferFrom with 4 arguments', async () => {
const tempAccount = await createLocalAccount(web3);
const toAccount = await createLocalAccount(web3);