Skip to content

Commit 71606b2

Browse files
authored
fix: filtered acceptance tests for release testing (#2577)
* fix: filtered acceptance tests for release testing Signed-off-by: Logan Nguyen <[email protected]> * fix: fixed deploy contract logic in estimateGas.spec.ts Signed-off-by: Logan Nguyen <[email protected]> * fix: get correct gas price for different network environments in getTransactionCount.spec.ts Signed-off-by: Logan Nguyen <[email protected]> --------- Signed-off-by: Logan Nguyen <[email protected]>
1 parent 5979c5d commit 71606b2

22 files changed

+100
-61
lines changed

packages/ws-server/tests/acceptance/batchRequest.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ethers, WebSocketProvider } from 'ethers';
2424
import { WsTestConstant, WsTestHelper } from '../helper';
2525
import { predefined } from '@hashgraph/json-rpc-relay/src';
2626

27-
describe('@release @web-socket-batch-1 Batch Requests', async function () {
27+
describe('@web-socket-batch-1 Batch Requests', async function () {
2828
const METHOD_NAME = 'batch_request';
2929
let ethersWsProvider: WebSocketProvider;
3030
let batchRequests: any = [];
@@ -76,10 +76,14 @@ describe('@release @web-socket-batch-1 Batch Requests', async function () {
7676

7777
after(async () => {
7878
// expect all the connections to the WS server to be closed after all
79-
expect(global.socketServer._connections).to.eq(0);
79+
if (global && global.socketServer) {
80+
if (global && global.socketServer) {
81+
expect(global.socketServer._connections).to.eq(0);
82+
}
83+
}
8084
});
8185

82-
it(`Should submit batch requests to WS server using Standard Web Socket and retrieve batch responses`, async () => {
86+
it(`@release Should submit batch requests to WS server using Standard Web Socket and retrieve batch responses`, async () => {
8387
// call batch request
8488
const batchResponses = await WsTestHelper.sendRequestToStandardWebSocket(METHOD_NAME, batchRequests);
8589

packages/ws-server/tests/acceptance/blockNumber.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ describe('@release @web-socket-batch-1 eth_blockNumber', async function () {
3838

3939
after(async () => {
4040
// expect all the connections to the WS server to be closed after all
41-
expect(global.socketServer._connections).to.eq(0);
41+
if (global && global.socketServer) {
42+
expect(global.socketServer._connections).to.eq(0);
43+
}
4244
});
4345

4446
describe(WsTestConstant.STANDARD_WEB_SOCKET, () => {

packages/ws-server/tests/acceptance/call.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils';
2626
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount';
2727
import ERC20MockJson from '@hashgraph/json-rpc-server/tests/contracts/ERC20Mock.json';
2828

29-
describe('@release @web-socket-batch-1 eth_call', async function () {
29+
describe('@web-socket-batch-1 eth_call', async function () {
3030
const METHOD_NAME = 'eth_call';
3131
const INVALID_PARAMS = [
3232
['{}', false, '0x0'],
@@ -104,7 +104,9 @@ describe('@release @web-socket-batch-1 eth_call', async function () {
104104

105105
after(async () => {
106106
// expect all the connections to be closed after all
107-
expect(global.socketServer._connections).to.eq(0);
107+
if (global && global.socketServer) {
108+
expect(global.socketServer._connections).to.eq(0);
109+
}
108110
});
109111

110112
describe(WsTestConstant.STANDARD_WEB_SOCKET, () => {
@@ -123,7 +125,7 @@ describe('@release @web-socket-batch-1 eth_call', async function () {
123125
}
124126

125127
for (const data of VALID_DATA) {
126-
it(`Should execute eth_call on Standard Web Socket and handle valid requests correctly`, async () => {
128+
it(`@release Should execute eth_call on Standard Web Socket and handle valid requests correctly`, async () => {
127129
const tx = {
128130
to: erc20TokenAddr,
129131
data: data.sighash,
@@ -165,7 +167,7 @@ describe('@release @web-socket-batch-1 eth_call', async function () {
165167
}
166168

167169
for (const data of VALID_DATA) {
168-
it(`Should execute eth_call on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
170+
it(`@release Should execute eth_call on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
169171
const tx = {
170172
to: erc20TokenAddr,
171173
data: data.sighash,

packages/ws-server/tests/acceptance/estimateGas.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils';
2626
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount';
2727
import basicContractJson from '@hashgraph/json-rpc-server/tests/contracts/Basic.json';
2828

29-
describe('@release @web-socket-batch-1 eth_estimateGas', async function () {
29+
describe('@web-socket-batch-1 eth_estimateGas', async function () {
3030
const METHOD_NAME = 'eth_estimateGas';
3131
const PING_CALL_ESTIMATED_GAS = '0x6122';
3232
const BASIC_CONTRACT_PING_CALL_DATA = '0x5c36b186';
@@ -67,8 +67,7 @@ describe('@release @web-socket-batch-1 eth_estimateGas', async function () {
6767

6868
beforeEach(async () => {
6969
ethersWsProvider = new ethers.WebSocketProvider(WsTestConstant.WS_RELAY_URL);
70-
const wallet = new ethers.Wallet(accounts[0].wallet.privateKey, ethersWsProvider);
71-
basicContract = await Utils.deployContract(basicContractJson.abi, basicContractJson.bytecode, wallet);
70+
basicContract = await Utils.deployContract(basicContractJson.abi, basicContractJson.bytecode, accounts[0].wallet);
7271
});
7372

7473
afterEach(async () => {
@@ -77,7 +76,9 @@ describe('@release @web-socket-batch-1 eth_estimateGas', async function () {
7776

7877
after(async () => {
7978
// expect all the connections to be closed after all
80-
expect(global.socketServer._connections).to.eq(0);
79+
if (global && global.socketServer) {
80+
expect(global.socketServer._connections).to.eq(0);
81+
}
8182
});
8283

8384
it('@release should execute "eth_estimateGas" for contract call, using a websocket provider', async function () {

packages/ws-server/tests/acceptance/gasPrice.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ describe('@release @web-socket-batch-1 eth_gasPrice', async function () {
3838

3939
after(async () => {
4040
// expect all the connections to be closed after all
41-
expect(global.socketServer._connections).to.eq(0);
41+
if (global && global.socketServer) {
42+
expect(global.socketServer._connections).to.eq(0);
43+
}
4244
});
4345

4446
describe(WsTestConstant.STANDARD_WEB_SOCKET, () => {

packages/ws-server/tests/acceptance/getBalance.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { WsTestConstant, WsTestHelper } from '../helper';
2525
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount';
2626
import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils';
2727

28-
describe('@release @web-socket-batch-1 eth_getBalance', async function () {
28+
describe('@web-socket-batch-1 eth_getBalance', async function () {
2929
const METHOD_NAME = 'eth_getBalance';
3030
const INVALID_PARAMS = [
3131
[],
@@ -71,7 +71,9 @@ describe('@release @web-socket-batch-1 eth_getBalance', async function () {
7171

7272
after(async () => {
7373
// expect all the connections to be closed after all
74-
expect(global.socketServer._connections).to.eq(0);
74+
if (global && global.socketServer) {
75+
expect(global.socketServer._connections).to.eq(0);
76+
}
7577
});
7678

7779
describe(WsTestConstant.STANDARD_WEB_SOCKET, () => {
@@ -81,7 +83,7 @@ describe('@release @web-socket-batch-1 eth_getBalance', async function () {
8183
});
8284
}
8385

84-
it(`Should execute eth_getBalance on Standard Web Socket and handle valid requests correctly`, async () => {
86+
it(`@release Should execute eth_getBalance on Standard Web Socket and handle valid requests correctly`, async () => {
8587
const response = await WsTestHelper.sendRequestToStandardWebSocket(METHOD_NAME, [accounts[0].address, 'latest']);
8688
WsTestHelper.assertJsonRpcObject(response);
8789

@@ -97,7 +99,7 @@ describe('@release @web-socket-batch-1 eth_getBalance', async function () {
9799
});
98100
}
99101

100-
it(`Should execute eth_getBalance on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
102+
it(`@release Should execute eth_getBalance on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
101103
const expectedResult = await global.relay.call(METHOD_NAME, [accounts[0].address, 'latest']);
102104
const result = await ethersWsProvider.send(METHOD_NAME, [accounts[0].address, 'latest']);
103105
expect(result).to.eq(expectedResult);

packages/ws-server/tests/acceptance/getBlockByHash.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { expect } from 'chai';
2323
import { ethers, WebSocketProvider } from 'ethers';
2424
import { WsTestConstant, WsTestHelper } from '../helper';
2525

26-
describe('@release @web-socket-batch-1 eth_getBlockByHash', async function () {
26+
describe('@web-socket-batch-1 eth_getBlockByHash', async function () {
2727
const METHOD_NAME = 'eth_getBlockByHash';
2828
const INVALID_PARAMS = [
2929
[],
@@ -48,7 +48,9 @@ describe('@release @web-socket-batch-1 eth_getBlockByHash', async function () {
4848

4949
after(async () => {
5050
// expect all the connections to be closed after all
51-
expect(global.socketServer._connections).to.eq(0);
51+
if (global && global.socketServer) {
52+
expect(global.socketServer._connections).to.eq(0);
53+
}
5254
});
5355

5456
describe(WsTestConstant.STANDARD_WEB_SOCKET, () => {
@@ -58,7 +60,7 @@ describe('@release @web-socket-batch-1 eth_getBlockByHash', async function () {
5860
});
5961
}
6062

61-
it(`Should execute eth_getBlockByHash on Standard Web Socket and handle valid requests correctly`, async () => {
63+
it(`@release Should execute eth_getBlockByHash on Standard Web Socket and handle valid requests correctly`, async () => {
6264
const expectedResult = await global.relay.call('eth_getBlockByNumber', ['latest', true]);
6365
const response = await WsTestHelper.sendRequestToStandardWebSocket(METHOD_NAME, [expectedResult.hash, true]);
6466
WsTestHelper.assertJsonRpcObject(response);
@@ -73,7 +75,7 @@ describe('@release @web-socket-batch-1 eth_getBlockByHash', async function () {
7375
});
7476
}
7577

76-
it(`Should execute eth_getBlockByHash on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
78+
it(`@release Should execute eth_getBlockByHash on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
7779
const expectedResult = await global.relay.call('eth_getBlockByNumber', ['latest', true]);
7880
const result = await ethersWsProvider.send(METHOD_NAME, [expectedResult.hash, true]);
7981
expect(result).to.deep.eq(expectedResult);

packages/ws-server/tests/acceptance/getBlockByNumber.spec.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
import { expect } from 'chai';
2323
import { ethers, WebSocketProvider } from 'ethers';
2424
import { WsTestConstant, WsTestHelper } from '../helper';
25+
import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils';
2526

26-
describe('@release @web-socket-batch-1 eth_getBlockByNumber', async function () {
27+
describe('@web-socket-batch-1 eth_getBlockByNumber', async function () {
2728
const METHOD_NAME = 'eth_getBlockByNumber';
2829
const INVALID_PARAMS = [
2930
[],
@@ -48,7 +49,9 @@ describe('@release @web-socket-batch-1 eth_getBlockByNumber', async function ()
4849

4950
after(async () => {
5051
// expect all the connections to be closed after all
51-
expect(global.socketServer._connections).to.eq(0);
52+
if (global && global.socketServer) {
53+
expect(global.socketServer._connections).to.eq(0);
54+
}
5255
});
5356

5457
describe(WsTestConstant.STANDARD_WEB_SOCKET, () => {
@@ -58,9 +61,10 @@ describe('@release @web-socket-batch-1 eth_getBlockByNumber', async function ()
5861
});
5962
}
6063

61-
it(`Should execute eth_getBlockByNumber on Standard Web Socket and handle valid requests correctly`, async () => {
64+
it(`@release Should execute eth_getBlockByNumber on Standard Web Socket and handle valid requests correctly`, async () => {
6265
const expectedResult = await global.relay.call(METHOD_NAME, ['latest', false]);
6366
const response = await WsTestHelper.sendRequestToStandardWebSocket(METHOD_NAME, [expectedResult.number, true]);
67+
await Utils.wait(1000);
6468
WsTestHelper.assertJsonRpcObject(response);
6569
expect(response.result).to.deep.eq(expectedResult);
6670
});
@@ -73,9 +77,10 @@ describe('@release @web-socket-batch-1 eth_getBlockByNumber', async function ()
7377
});
7478
}
7579

76-
it(`Should execute eth_getBlockByNumber on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
80+
it(`@release Should execute eth_getBlockByNumber on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
7781
const expectedResult = await global.relay.call(METHOD_NAME, ['latest', false]);
7882
const result = await ethersWsProvider.send(METHOD_NAME, [expectedResult.number, true]);
83+
await Utils.wait(1000);
7984
expect(result).to.deep.eq(expectedResult);
8085
});
8186
});

packages/ws-server/tests/acceptance/getCode.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils';
2626
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount';
2727
import basicContractJson from '@hashgraph/json-rpc-server/tests/contracts/Basic.json';
2828

29-
describe('@release @web-socket-batch-2 eth_getCode', async function () {
29+
describe('@web-socket-batch-2 eth_getCode', async function () {
3030
const METHOD_NAME = 'eth_getCode';
3131

3232
let basicContract: ethers.Contract,
@@ -51,7 +51,9 @@ describe('@release @web-socket-batch-2 eth_getCode', async function () {
5151

5252
after(async () => {
5353
// expect all the connections to be closed after all
54-
expect(global.socketServer._connections).to.eq(0);
54+
if (global && global.socketServer) {
55+
expect(global.socketServer._connections).to.eq(0);
56+
}
5557
});
5658

5759
it('should return the code ethers WebSocketProvider', async function () {

packages/ws-server/tests/acceptance/getLogs.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { WsTestConstant, WsTestHelper } from '../helper';
2525
import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils';
2626
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount';
2727

28-
describe('@release @web-socket-batch-2 eth_getLogs', async function () {
28+
describe('@web-socket-batch-2 eth_getLogs', async function () {
2929
const EXPECTED_VALUE = 7;
3030
const METHOD_NAME = 'eth_getLogs';
3131
const INVALID_PARAMS = [
@@ -120,7 +120,9 @@ describe('@release @web-socket-batch-2 eth_getLogs', async function () {
120120

121121
after(async () => {
122122
// expect all the connections to be closed after all
123-
expect(global.socketServer._connections).to.eq(0);
123+
if (global && global.socketServer) {
124+
expect(global.socketServer._connections).to.eq(0);
125+
}
124126
});
125127

126128
describe(WsTestConstant.STANDARD_WEB_SOCKET, () => {
@@ -132,7 +134,7 @@ describe('@release @web-socket-batch-2 eth_getLogs', async function () {
132134
});
133135
}
134136

135-
it(`Should execute eth_getLogs on Standard Web Socket and handle valid requests correctly`, async () => {
137+
it(`@release Should execute eth_getLogs on Standard Web Socket and handle valid requests correctly`, async () => {
136138
const response = await WsTestHelper.sendRequestToStandardWebSocket(METHOD_NAME, [wsFilterObj]);
137139
WsTestHelper.assertJsonRpcObject(response);
138140

@@ -153,7 +155,7 @@ describe('@release @web-socket-batch-2 eth_getLogs', async function () {
153155
});
154156
}
155157

156-
it(`Should execute eth_getLogs on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
158+
it(`@release Should execute eth_getLogs on Ethers Web Socket Provider and handle valid requests correctly`, async () => {
157159
const logs = await ethersWsProvider.send(METHOD_NAME, [wsFilterObj]);
158160

159161
expect(logs[0].address.toLowerCase()).to.eq(wsFilterObj.address.toLowerCase());

0 commit comments

Comments
 (0)