Skip to content

Commit

Permalink
issue: 1518 - rpc proxy return value for get uncles by block hash/num…
Browse files Browse the repository at this point in the history
…ber by index (#1522)

* chore: 1518

* chore: 1518 update

* fix: fix failing tests

---------

Co-authored-by: Fabio Rigamonti <73019897+fabiorigam@users.noreply.github.com>
  • Loading branch information
claytonneal and fabiorigam authored Nov 20, 2024
1 parent 2d16394 commit 42cb251
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ThorId } from '@vechain/sdk-core';
*/
const ethGetUncleByBlockHashAndIndex = async (
params: unknown[]
): Promise<object> => {
): Promise<object | null> => {
// Input validation
if (
params.length !== 2 ||
Expand All @@ -33,7 +33,7 @@ const ethGetUncleByBlockHashAndIndex = async (
{ params }
);

return await Promise.resolve({});
return await Promise.resolve(null);
};

export { ethGetUncleByBlockHashAndIndex };
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { JSONRPCInvalidParams } from '@vechain/sdk-errors';
*/
const ethGetUncleByBlockNumberAndIndex = async (
params: unknown[]
): Promise<object> => {
): Promise<object | null> => {
// Input validation
if (
params.length !== 2 ||
Expand All @@ -32,7 +32,7 @@ const ethGetUncleByBlockNumberAndIndex = async (
{ params }
);

return await Promise.resolve({});
return await Promise.resolve(null);
};

export { ethGetUncleByBlockNumberAndIndex };
4 changes: 2 additions & 2 deletions packages/network/src/provider/utils/rpc-mapper/rpc-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,13 @@ const RPCMethodsMap = (

[RPC_METHODS.eth_getUncleByBlockHashAndIndex]: async (
params
): Promise<object> => {
): Promise<object | null> => {
return await ethGetUncleByBlockHashAndIndex(params);
},

[RPC_METHODS.eth_getUncleByBlockNumberAndIndex]: async (
params
): Promise<object> => {
): Promise<object | null> => {
return await ethGetUncleByBlockNumberAndIndex(params);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('RPC Mapper - eth_getUncleByBlockHashAndIndex method tests', () => {
'0x0'
]);

expect(uncleBlock).toStrictEqual({});
expect(uncleBlock).toStrictEqual(null);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('RPC Mapper - eth_getUncleByBlockNumberAndIndex method tests', () => {
RPC_METHODS.eth_getUncleByBlockNumberAndIndex
](['latest', '0x0']);

expect(uncleBlock).toStrictEqual({});
expect(uncleBlock).toStrictEqual(null);
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/rpc-proxy/tests/e2e_rpc_proxy.solo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ describe('RPC Proxy endpoints', () => {
console.log(response.data);
expect(response.data).toHaveProperty('result');
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(response.data.result).toStrictEqual({});
expect(response.data.result).toBeNull();
});

it('eth_getUncleByBlockNumberAndIndex method call', async () => {
Expand All @@ -532,7 +532,7 @@ describe('RPC Proxy endpoints', () => {
console.log(response.data);
expect(response.data).toHaveProperty('result');
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(response.data.result).toStrictEqual({});
expect(response.data.result).toBeNull();
});

it('eth_requestAccounts method call', async () => {
Expand Down

1 comment on commit 42cb251

@github-actions
Copy link

Choose a reason for hiding this comment

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

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 99%
98.99% (4345/4389) 97.53% (1387/1422) 98.9% (901/911)
Title Tests Skipped Failures Errors Time
core 827 0 💤 0 ❌ 0 🔥 2m 23s ⏱️
network 719 0 💤 0 ❌ 0 🔥 4m 56s ⏱️
errors 42 0 💤 0 ❌ 0 🔥 16.739s ⏱️
logging 3 0 💤 0 ❌ 0 🔥 18.183s ⏱️
hardhat-plugin 19 0 💤 0 ❌ 0 🔥 1m 7s ⏱️
aws-kms-adapter 23 0 💤 0 ❌ 0 🔥 1m 22s ⏱️
ethers-adapter 5 0 💤 0 ❌ 0 🔥 1m 14s ⏱️
rpc-proxy 37 0 💤 0 ❌ 0 🔥 1m 2s ⏱️

Please sign in to comment.