Skip to content

Commit 5f26a6a

Browse files
authored
refactor: moved websocket acceptance tests from server package to ws-server package (#2329)
refactor: moved ws acceptance test to ws-server package Signed-off-by: Logan Nguyen <[email protected]>
1 parent 4bc9650 commit 5f26a6a

19 files changed

+195
-108
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"acceptancetest:tokenmanagement": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@tokenmanagement' --exit",
3939
"acceptancetest:htsprecompilev1": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@htsprecompilev1' --exit",
4040
"acceptancetest:release": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@release' --exit",
41-
"acceptancetest:ws": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@web-socket' --exit",
41+
"acceptancetest:ws": "ts-mocha packages/ws-server/tests/acceptance/index.spec.ts -g '@web-socket' --exit",
4242
"acceptancetest:ws_newheads": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@web-socket-newheads' --exit",
4343
"acceptancetest:precompile-calls": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@precompile-calls' --exit",
4444
"acceptancetest:cache-service": "ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@cache-service' --exit",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// external resources
2222
import { expect } from 'chai';
2323
import { ethers, WebSocketProvider } from 'ethers';
24-
import RelayClient from '../../clients/relayClient';
24+
import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient';
2525

2626
describe('@release @web-socket eth_blockNumber', async function () {
2727
const WS_RELAY_URL = `${process.env.WS_RELAY_URL}`;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@
2020

2121
// external resources
2222
import { expect } from 'chai';
23-
import { Utils } from '../../helpers/utils';
2423
import { ethers, WebSocketProvider } from 'ethers';
25-
import ERC20MockJson from '../../contracts/ERC20Mock.json';
26-
import { AliasAccount } from '../../clients/servicesClient';
24+
import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils';
25+
import ERC20MockJson from '@hashgraph/json-rpc-server/tests/contracts/ERC20Mock.json';
26+
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/clients/servicesClient';
2727

2828
describe('@release @web-socket eth_call', async function () {
2929
const WS_RELAY_URL = `${process.env.WS_RELAY_URL}`;
3030
const METHOD_NAME = 'eth_call';
3131
const FAKE_TX_HASH = `0x${'00'.repeat(20)}`;
3232
const INVALID_PARAMS = [
33-
["{ to: '0xabcdef', data: '0x1a2b3c4d' }", 36, ''],
3433
['{}', false, '0x0'],
35-
[{ to: FAKE_TX_HASH, data: '' }, 'latest'],
34+
["{ to: '0xabcdef', data: '0x1a2b3c4d' }", 36, ''],
3635
[{ to: FAKE_TX_HASH, data: 36 }, 'latest'],
3736
];
3837

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
// external resources
2222
import WebSocket from 'ws';
2323
import { expect } from 'chai';
24-
import basicContractJson from '../../contracts/Basic.json';
25-
import { AliasAccount } from '../../clients/servicesClient';
26-
import { Contract, ethers, JsonRpcProvider, WebSocketProvider } from 'ethers';
24+
import { Contract, ethers, WebSocketProvider } from 'ethers';
25+
import basicContractJson from '@hashgraph/json-rpc-server/tests/contracts/Basic.json';
26+
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/clients/servicesClient';
2727

2828
describe('@release @web-socket eth_estimateGas', async function () {
2929
// @ts-ignore
3030
const { servicesNode, relay } = global;
3131

32-
const RELAY_URL = `${process.env.RELAY_ENDPOINT}`;
3332
const WS_RELAY_URL = `${process.env.WS_RELAY_URL}`;
3433
const BASIC_CONTRACT_PING_CALL_DATA = '0x5c36b186';
3534
const PING_CALL_ESTIMATED_GAS = '0x6122';
@@ -39,7 +38,6 @@ describe('@release @web-socket eth_estimateGas', async function () {
3938
currentPrice: number,
4039
expectedGas: number,
4140
gasPriceDeviation: number,
42-
provider: JsonRpcProvider,
4341
requestId: string,
4442
wsProvider: WebSocketProvider,
4543
webSocket: WebSocket;
@@ -48,7 +46,6 @@ describe('@release @web-socket eth_estimateGas', async function () {
4846
accounts[0] = await servicesNode.createAliasAccount(100, relay.provider, requestId);
4947
basicContract = await servicesNode.deployContract(basicContractJson);
5048
wsProvider = await new ethers.WebSocketProvider(WS_RELAY_URL);
51-
provider = new ethers.JsonRpcProvider(RELAY_URL);
5249

5350
webSocket = new WebSocket(WS_RELAY_URL);
5451
currentPrice = await relay.gasPrice(requestId);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// external resources
2222
import { expect } from 'chai';
2323
import { ethers, WebSocketProvider } from 'ethers';
24-
import RelayClient from '../../clients/relayClient';
24+
import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient';
2525

2626
describe('@release @web-socket eth_gasPrice', async function () {
2727
const WS_RELAY_URL = `${process.env.WS_RELAY_URL}`;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
// external resources
2222
import { expect } from 'chai';
2323
import { ethers, WebSocketProvider } from 'ethers';
24-
import RelayClient from '../../clients/relayClient';
25-
import { AliasAccount } from '../../clients/servicesClient';
24+
import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient';
25+
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/clients/servicesClient';
2626

2727
describe('@release @web-socket eth_getBalance', async function () {
2828
const WS_RELAY_URL = `${process.env.WS_RELAY_URL}`;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// external resources
2222
import { expect } from 'chai';
2323
import { ethers, WebSocketProvider } from 'ethers';
24-
import RelayClient from '../../clients/relayClient';
24+
import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient';
2525

2626
describe('@release @web-socket eth_getBlockByHash', async function () {
2727
const WS_RELAY_URL = `${process.env.WS_RELAY_URL}`;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// external resources
2222
import { expect } from 'chai';
2323
import { ethers, WebSocketProvider } from 'ethers';
24-
import RelayClient from '../../clients/relayClient';
24+
import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient';
2525

2626
describe('@release @web-socket eth_getBlockByNumber', async function () {
2727
const WS_RELAY_URL = `${process.env.WS_RELAY_URL}`;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
*/
2020

2121
// external resources
22-
import { expect } from 'chai';
23-
import { Contract, ethers, JsonRpcProvider, WebSocketProvider } from 'ethers';
24-
import { AliasAccount } from '../../clients/servicesClient';
2522
import WebSocket from 'ws';
26-
import basicContractJson from '../../contracts/Basic.json';
23+
import { expect } from 'chai';
24+
import { ethers, JsonRpcProvider, WebSocketProvider } from 'ethers';
25+
import basicContractJson from '@hashgraph/json-rpc-server/tests/contracts/Basic.json';
26+
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/clients/servicesClient';
2727

2828
describe('@release @web-socket eth_getCode', async function () {
2929
const RELAY_URL = `${process.env.RELAY_ENDPOINT}`;
3030
const WS_RELAY_URL = `${process.env.WS_RELAY_URL}`;
3131

3232
let accounts: AliasAccount[] = [],
33-
basicContract: Contract,
33+
basicContract: any,
3434
codeFromRPC: string,
3535
provider: JsonRpcProvider,
3636
requestId: string,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// external resources
2222
import { expect } from 'chai';
2323
import { ethers, WebSocketProvider } from 'ethers';
24-
import { AliasAccount } from '../../clients/servicesClient';
24+
import { AliasAccount } from '@hashgraph/json-rpc-server/tests/clients/servicesClient';
2525

2626
describe('@release @web-socket eth_getLogs', async function () {
2727
const WS_RELAY_URL = `${process.env.WS_RELAY_URL}`;

0 commit comments

Comments
 (0)