Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
544 changes: 301 additions & 243 deletions packages/web3/test/e2e/fixtures/mainnet.ts

Large diffs are not rendered by default.

5,791 changes: 2,282 additions & 3,509 deletions packages/web3/test/e2e/fixtures/mainnet_block_hydrated.ts

Large diffs are not rendered by default.

1,994 changes: 1,368 additions & 626 deletions packages/web3/test/e2e/fixtures/sepolia.ts

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions packages/web3/test/e2e/get_balance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ describe(`${getSystemTestBackend()} tests - getBalance`, () => {
const provider = getSystemE2ETestProvider();
const blockData =
getSystemTestBackend() === BACKEND.SEPOLIA ? sepoliaBlockData : mainnetBlockData;
const expectedBalance =
getSystemTestBackend() === BACKEND.SEPOLIA ? '172530374997217200' : '2099795781954790368';
let expectedBalance = BigInt(0);

let web3: Web3;

beforeAll(() => {
beforeAll(async () => {
web3 = new Web3(provider);
expectedBalance = await web3.eth.getBalance(getE2ETestAccountAddress());
});

afterAll(async () => {
Expand Down Expand Up @@ -69,7 +69,13 @@ describe(`${getSystemTestBackend()} tests - getBalance`, () => {
format: [FMT_NUMBER.BIGINT, FMT_NUMBER.HEX, FMT_NUMBER.STR],
}),
)('getBalance', async ({ block, format }) => {
const result = await web3.eth.getBalance(getE2ETestAccountAddress(), blockData[block], {
let blockOrTag = blockData[block];
if (block === 'blockHash' || block === 'blockNumber') {
const b = await web3.eth.getBlock('finalized');
blockOrTag = block === 'blockHash' ? String(b.hash) : Number(b.number);
}

const result = await web3.eth.getBalance(getE2ETestAccountAddress(), blockOrTag, {
number: format as FMT_NUMBER,
bytes: FMT_BYTES.HEX,
});
Expand All @@ -83,15 +89,15 @@ describe(`${getSystemTestBackend()} tests - getBalance`, () => {
* converted to a BigInt
*/
// eslint-disable-next-line jest/no-conditional-expect
expect(result).toBe(toHex(BigInt(expectedBalance)));
expect(result).toBe(toHex(expectedBalance));
break;
case 'NUMBER_STR':
// eslint-disable-next-line jest/no-conditional-expect
expect(result).toBe(expectedBalance);
expect(result).toBe(expectedBalance.toString());
break;
case 'NUMBER_BIGINT':
// eslint-disable-next-line jest/no-conditional-expect
expect(result).toBe(BigInt(expectedBalance));
expect(result).toBe(expectedBalance);
break;
default:
throw new Error('Unhandled format');
Expand Down
8 changes: 4 additions & 4 deletions packages/web3/test/e2e/get_proof.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ describe(`${getSystemTestBackend()} tests - getProof`, () => {
| 'blockNumber';
}>({
block: [
// 'earliest', block is earlier than 128 blocks ago "Returned error: missing trie node"
'earliest',
'latest',
// 'pending', block is not available "Returned error: missing trie node"
// 'pending',
'safe',
'finalized',
'blockHash',
'blockNumber',
// 'blockHash',
// 'blockNumber',
],
}),
)('getProof', async ({ block }) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/web3/test/e2e/get_protocol_version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ describe(`${getSystemTestBackend()} tests - getProtocolVersion`, () => {
await closeOpenConnection(web3);
});

it('should get the protocol version for the connected node', async () => {
// doesn't exists with lodestar provider
it.skip('should get the protocol version for the connected node', async () => {
const result = await web3.eth.getProtocolVersion();
expect(isHexStrict(result)).toBeTruthy();
});
Expand Down
13 changes: 8 additions & 5 deletions packages/web3/test/e2e/get_transaction_count.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ describe(`${getSystemTestBackend()} tests - getTransactionCount`, () => {
],
}),
)('getTransactionCount', async ({ block }) => {
const result = await web3.eth.getTransactionCount(
getE2ETestAccountAddress(),
blockData[block],
);
let blockOrTag = blockData[block];
if (block === 'blockHash' || block === 'blockNumber') {
const b = await web3.eth.getBlock('finalized');
blockOrTag = block === 'blockHash' ? String(b.hash) : Number(b.number);
}

const result = await web3.eth.getTransactionCount(getE2ETestAccountAddress(), blockOrTag);

if (block === 'blockHash' || block === 'blockNumber') {
const expectedTxCount =
getSystemTestBackend() === BACKEND.SEPOLIA ? BigInt(1) : BigInt(11);
getSystemTestBackend() === BACKEND.SEPOLIA ? BigInt(47) : BigInt(40);
// eslint-disable-next-line jest/no-conditional-expect
expect(result).toBe(expectedTxCount);
} else {
Expand Down
9 changes: 5 additions & 4 deletions packages/web3/test/e2e/mainnet/get_storage_at.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ describe(`${getSystemTestBackend()} tests - getStorageAt`, () => {
it.each(
toAllVariants<{
storageSlot: Numbers;
block: // | 'earliest'
| 'latest'
// | 'pending'
block:
| 'earliest'
| 'latest'
| 'pending'
| 'finalized'
| 'safe'
| 'blockHash'
Expand Down Expand Up @@ -79,7 +80,7 @@ describe(`${getSystemTestBackend()} tests - getStorageAt`, () => {
} else if (block === 'blockHash' || block === 'blockNumber') {
// eslint-disable-next-line jest/no-conditional-expect
expect(result).toBe(
'0x00000000000000000000000000000000000000000000000000c354b137cba7ba',
'0x00000000000000000000000000000000000000000000000000c347d66ae6ce59',
);
} else {
// eslint-disable-next-line jest/no-conditional-expect
Expand Down
47 changes: 22 additions & 25 deletions packages/web3/test/e2e/mainnet/get_transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ describe(`${getSystemTestBackend()} tests - getTransaction`, () => {
transactionHash: Bytes;
}>({
transactionHash: [
'0x9a968248400868beb931ed96ee37517275794ff44e8d968c29f0f3430a504594',
'0x79fd3cd0c84acfbb1b9c8f2ab33517626eceb8cb42c21f1c21439ce36e0e6cab',
bytesToUint8Array(
hexToBytes(
'0x9a968248400868beb931ed96ee37517275794ff44e8d968c29f0f3430a504594',
'0x79fd3cd0c84acfbb1b9c8f2ab33517626eceb8cb42c21f1c21439ce36e0e6cab',
),
),
new Uint8Array(
hexToBytes(
'0x9a968248400868beb931ed96ee37517275794ff44e8d968c29f0f3430a504594',
'0x79fd3cd0c84acfbb1b9c8f2ab33517626eceb8cb42c21f1c21439ce36e0e6cab',
),
),
],
Expand All @@ -60,29 +60,26 @@ describe(`${getSystemTestBackend()} tests - getTransaction`, () => {
const result = await web3.eth.getTransaction(transactionHash);

expect(result).toMatchObject<TransactionInfo>({
hash: '0x9a968248400868beb931ed96ee37517275794ff44e8d968c29f0f3430a504594',
nonce: BigInt(2264),
blockHash: '0xabc81c29235c7962f5a0420644761627bdc064a560c7d1842cdf9517f7d7984e',
blockNumber: BigInt(17030310),
transactionIndex: BigInt(91),
from: '0xd67da12dc33d9730d9341bbfa4f0b67d0688b28b',
gasPrice: BigInt(19330338402),
maxPriorityFeePerGas: BigInt(100000000),
maxFeePerGas: BigInt(26848942133),
gas: BigInt(300858),
input: '0x6d78f47a000000000000000000000000a6e265667e1e18c28f2b5dc529f775c5f0d56d4a000000000000000000000000000000000000000000000001a055690d9db80000000000000000000000000000d67da12dc33d9730d9341bbfa4f0b67d0688b28b',
blockHash: '0x4cf4c590ad0c46e86c83d3156b6fafd7ec10da67da577ee8abae96854b3e474f',
blockNumber: BigInt(20866453),
from: '0xbbff54095b09940a4046e21ed5053f1ea2a1c581',
gas: BigInt(320260),
gasPrice: BigInt(11058949155),
maxFeePerGas: BigInt(13199607524),
maxPriorityFeePerGas: BigInt(3000000000),
hash: '0x79fd3cd0c84acfbb1b9c8f2ab33517626eceb8cb42c21f1c21439ce36e0e6cab',
input: '0x3d0e3ec50000000000000000000000000000000000000000000000001a33261efb6495ca000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000bbff54095b09940a4046e21ed5053f1ea2a1c5810000000000000000000000000000000000000000000000000000000066fb25a80000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000b9612ce2807de435a562b40a5ba9200ab86065e1000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
nonce: BigInt(985),
to: '0x80a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e',
transactionIndex: BigInt(6),
value: BigInt(0),
type: BigInt(2),
accessList: [],
chainId: BigInt(1),
type: BigInt('0x2'),
v: BigInt('0x0'),
s: '0x72ca073bc16b35b3191b35fd8fb0eebdd536675ecb8459b110fcad2890a98ec9',
r: '0x45496fc11c7bf9972cb732bdc579f5d9d01e4df276dd49626e75fc3b5f8b6ec4',
// TODO These values are included when fetching the transaction from
// Nethermind, but not Infura
// https://github.com/web3/web3.js/issues/5997
// data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a73560405160405180910390a36104dc806100de6000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80632e64cec1146100515780636057361d1461006f578063893d20e81461008b578063a6f9dae1146100a9575b600080fd5b6100596100c5565b60405161006691906102fb565b60405180910390f35b61008960048036038101906100849190610347565b6100ce565b005b610093610168565b6040516100a091906103b5565b60405180910390f35b6100c360048036038101906100be91906103fc565b610192565b005b60008054905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461015e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161015590610486565b60405180910390fd5b8060008190555050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610222576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161021990610486565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a73560405160405180910390a380600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000819050919050565b6102f5816102e2565b82525050565b600060208201905061031060008301846102ec565b92915050565b600080fd5b610324816102e2565b811461032f57600080fd5b50565b6000813590506103418161031b565b92915050565b60006020828403121561035d5761035c610316565b5b600061036b84828501610332565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061039f82610374565b9050919050565b6103af81610394565b82525050565b60006020820190506103ca60008301846103a6565b92915050565b6103d981610394565b81146103e457600080fd5b50565b6000813590506103f6816103d0565b92915050565b60006020828403121561041257610411610316565b5b6000610420848285016103e7565b91505092915050565b600082825260208201905092915050565b7f43616c6c6572206973206e6f74206f776e657200000000000000000000000000600082015250565b6000610470601383610429565b915061047b8261043a565b602082019050919050565b6000602082019050818103600083015261049f81610463565b905091905056fea26469706673582212201fcfa803d5c15c78e1e356cc1946c1bf14f9809acd349df1fd41362fa1a9e4d564736f6c63430008120033',
// to: null,
// value: '0x0',
// yParity: '0x0'
v: BigInt(1),
r: '0xac126c6ad95a7a8970ce4ca34d61a3a2245e8d7f11bde871dd66ac43435405c6',
s: '0x1beeda8ed32586243281807ee42d8e524d5050bd7f224f62e5dce812472ecee5',
data: '0x3d0e3ec50000000000000000000000000000000000000000000000001a33261efb6495ca000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000bbff54095b09940a4046e21ed5053f1ea2a1c5810000000000000000000000000000000000000000000000000000000066fb25a80000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000b9612ce2807de435a562b40a5ba9200ab86065e1000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
});
});
});
Loading
Loading