Skip to content

Commit

Permalink
fix: Added the web3_clientVersion to the websocket server.
Browse files Browse the repository at this point in the history
Signed-off-by: ebadiere <ebadiere@gmail.com>
  • Loading branch information
ebadiere committed May 13, 2024
1 parent 88b6eea commit bd96afa
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/ws-server/src/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ const handleSendingRequestsToRelay = async ({

try {
const resolvedParams = resolveParams(method, params);
const txRes = await relay.eth()[method.split('_')[1]](...resolvedParams, requestIdPrefix);
let txRes;
if (method.split('_')[0] === 'eth') {
txRes = await relay.eth()[method.split('_')[1]](...resolvedParams, requestIdPrefix);
} else {
txRes = await relay.web3()[method.split('_')[1]](...resolvedParams, requestIdPrefix);
}
if (!txRes) {
logger.trace(
`${connectionIdPrefix} ${requestIdPrefix}: Fail to retrieve result for request=${JSON.stringify(
Expand Down
40 changes: 40 additions & 0 deletions packages/ws-server/tests/acceptance/web3ClientVersion.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*-
*
* Hedera JSON RPC Relay
*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

// external resources
import { expect } from 'chai';
import { WsTestHelper } from '../helper';
import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils';

describe('@web-socket-batch-2 web3_clientVersion', async function () {
const METHOD_NAME = 'web3_clientVersion';

let requestId: string;

before(async () => {
requestId = Utils.generateRequestId();
});

it(`Should execute web3_clientVersion on Standard Web Socket and handle valid requests correctly`, async () => {
const response = await WsTestHelper.sendRequestToStandardWebSocket(METHOD_NAME, []);
expect(response.result).to.exist;
expect(response.result).to.be.a('string');
});
});

0 comments on commit bd96afa

Please sign in to comment.