Skip to content

Commit

Permalink
eth_getBlockByNumber tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shunjizhan committed Oct 9, 2024
1 parent 96c42c7 commit 3ed7108
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { describe, expect, it } from 'vitest';

import { deployErc20, eth_getBlockByNumber, testSetup } from '../utils';

const { wallet, provider } = testSetup;

describe('eth_getBlockByNumber', () => {
it('get correct block info', async () => {
const token = await deployErc20(wallet);
const txHash = token.deployTransaction.hash;

const curBlockNumber = await provider.getBlockNumber();

const res = (await eth_getBlockByNumber([curBlockNumber, false])).data.result;
const resFull = (await eth_getBlockByNumber([curBlockNumber, true])).data.result;

expect(Number(res.number)).toEqual(curBlockNumber);
expect(res.transactions[0]).to.eq(txHash);

expect(Number(resFull.number)).toEqual(curBlockNumber);
expect(resFull.transactions[0]).to.contain({
hash: txHash,
from: wallet.address.toLowerCase(),
to: null,
value: '0x0',
});
});
});
6 changes: 0 additions & 6 deletions packages/eth-rpc-adapter/src/__tests__/utils/eth-rpc-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,4 @@ export const eth_getFilterLogs = rpcGet<{
}>('eth_getFilterLogs');
export const eth_uninstallFilter = rpcGet('eth_uninstallFilter');
export const net_listening = rpcGet('net_listening');

/* ---------- karura mainnet rpc methods ---------- */
export const eth_blockNumber_karura = rpcGet('eth_blockNumber', KARURA_ETH_RPC_URL);
export const eth_getTransactionReceipt_karura = rpcGet('eth_getTransactionReceipt', KARURA_ETH_RPC_URL);
export const eth_getTransactionByHash_karura = rpcGet('eth_getTransactionByHash', KARURA_ETH_RPC_URL);
export const eth_getBlockByNumber_karura = rpcGet('eth_getBlockByNumber', KARURA_ETH_RPC_URL);
export const eth_getStorageAt = rpcGet('eth_getStorageAt', ETH_RPC_URL);

0 comments on commit 3ed7108

Please sign in to comment.