Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix e2e test error "project ID request rate exceeded" #7290

Merged
4 changes: 2 additions & 2 deletions .github/workflows/e2e_network_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
needs: build
runs-on: ubuntu-latest
env:
INFURA_SEPOLIA_HTTP: ${{ secrets.INFURA_SEPOLIA_HTTP }}
INFURA_MAINNET_HTTP: ${{ secrets.INFURA_MAINNET_HTTP }}
INFURA_SEPOLIA_HTTP: ${{ secrets.CS_ETH_SEPOLIA }}
INFURA_MAINNET_HTTP: ${{ secrets.CS_ETH_MAINNET }}
MODE: ${{ matrix.mode }}
TEST_ACCOUNT_ADDRESS: ${{ fromJSON('{"sepolia":"0xa127C5E6a7E3600Ac34A9a9928E52521677e7211","mainnet":"0x98AF911164f9d4E0f5983ed114949c3Bfe3ADc9d"}')[matrix.network] }}
ALLOWED_SEND_TRANSACTION: ${{ secrets.E2E_TESTS_ALLOWED_SEND_TRANSACTION }}
Expand Down
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.

25 changes: 18 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,18 @@ 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') {
/**
* @NOTE Getting a block too far back in history
* results in a missing trie node error, so
* we get latest block for this test
*/
const b = await web3.eth.getBlock('finalized');
blockOrTag = block === 'blockHash' ? String(b.hash) : Number(b.number);
avkos marked this conversation as resolved.
Show resolved Hide resolved
}

const result = await web3.eth.getBalance(getE2ETestAccountAddress(), blockOrTag, {
number: format as FMT_NUMBER,
bytes: FMT_BYTES.HEX,
});
Expand All @@ -83,15 +94,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
51 changes: 32 additions & 19 deletions packages/web3/test/e2e/get_block_transaction_count.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,46 @@ describe(`${getSystemTestBackend()} tests - getBlockTransactionCount`, () => {
)('getBlockTransactionCount', async ({ block, format }) => {
let _blockData = blockData[block];
if (block === 'blockHash' || block === 'blockNumber') {
/**
* @NOTE Getting a block too far back in history
* results in a missing trie node error, so
* we get latest block for this test
*/
const latestBlock = await web3.eth.getBlock('finalized');
_blockData =
block === 'blockHash' ? (latestBlock.hash as string) : Number(latestBlock.number);
}

const result = await web3.eth.getBlockTransactionCount(_blockData, {
number: format as FMT_NUMBER,
bytes: FMT_BYTES.HEX,
});
switch (format) {
case 'NUMBER_NUMBER':
// eslint-disable-next-line jest/no-conditional-expect
expect(isNumber(result)).toBeTruthy();
break;
case 'NUMBER_HEX':
// eslint-disable-next-line jest/no-conditional-expect
expect(isHexStrict(result)).toBeTruthy();
break;
case 'NUMBER_STR':
// eslint-disable-next-line jest/no-conditional-expect
expect(isString(result)).toBeTruthy();
break;
case 'NUMBER_BIGINT':
// eslint-disable-next-line jest/no-conditional-expect
expect(isBigInt(result)).toBeTruthy();
break;
default:
throw new Error('Unhandled format');
if (block === 'pending') {
// eslint-disable-next-line no-null/no-null
const expectedResult = result === null || Number(result) > 0;
// eslint-disable-next-line jest/no-conditional-expect
expect(expectedResult).toBeTruthy();
} else {
switch (format) {
case 'NUMBER_NUMBER':
// eslint-disable-next-line jest/no-conditional-expect
expect(isNumber(result)).toBeTruthy();
break;
case 'NUMBER_HEX':
// eslint-disable-next-line jest/no-conditional-expect
expect(isHexStrict(result)).toBeTruthy();
break;
case 'NUMBER_STR':
// eslint-disable-next-line jest/no-conditional-expect
expect(isString(result)).toBeTruthy();
break;
case 'NUMBER_BIGINT':
// eslint-disable-next-line jest/no-conditional-expect
expect(isBigInt(result)).toBeTruthy();
break;
default:
throw new Error('Unhandled format');
}
}
});
});
6 changes: 3 additions & 3 deletions packages/web3/test/e2e/get_block_uncle_count.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
import Web3 from '../../src';
import { Web3 } from '../../src';
import { getSystemE2ETestProvider } from './e2e_utils';
import {
closeOpenConnection,
Expand Down Expand Up @@ -74,8 +74,8 @@ describeIf(getSystemTestBackend() !== 'hardhat')(
: Number(latestBlock.number);
}
const result = await web3.eth.getBlockUncleCount(_blockData);

expect(result).toBe(BigInt(0));
// eslint-disable-next-line no-null/no-null
expect(result).toBe(block === 'pending' || block === 'earliest' ? null : BigInt(0));
});
},
);
2 changes: 1 addition & 1 deletion packages/web3/test/e2e/get_fee_history.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe(`${getSystemTestBackend()} tests - estimateGas`, () => {
format: string;
}>({
blockCount: [1, '2', 3, BigInt(4)],
newestBlock: ['earliest', 'latest', 'pending', 'safe', 'finalized', 'blockNumber'],
newestBlock: ['earliest', 'latest', 'safe', 'finalized', 'blockNumber'],
rewardPercentiles: [['0xa', '20', 30, BigInt(40)]],
format: Object.values(FMT_NUMBER),
}),
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', // error "distance to target block exceeds maximum proof window"
'latest',
// 'pending', block is not available "Returned error: missing trie node"
// 'pending', // error "unknown block number"
'safe',
'finalized',
'blockHash',
'blockNumber',
// 'blockHash', // error "distance to target block exceeds maximum proof window"
// 'blockNumber', // error "distance to target block exceeds maximum proof window"
],
}),
)('getProof', async ({ block }) => {
Expand Down
18 changes: 13 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,22 @@ 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') {
/**
* @NOTE Getting a block too far back in history
* results in a missing trie node error, so
* we get latest block for this test
*/
const b = await web3.eth.getBlock('finalized');
blockOrTag = block === 'blockHash' ? String(b.hash) : Number(b.number);
avkos marked this conversation as resolved.
Show resolved Hide resolved
}

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
20 changes: 13 additions & 7 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 All @@ -61,10 +62,15 @@ describe(`${getSystemTestBackend()} tests - getStorageAt`, () => {
)('getStorageAt', async ({ storageSlot, block }) => {
let blockData = mainnetBlockData[block];
if (block === 'blockHash' || block === 'blockNumber') {
const blockNumber = await web3.eth.getBlockNumber();
blockData = Number(blockNumber);
/**
* @NOTE Getting a block too far back in history
* results in a missing trie node error, so
* we get latest block for this test
*/
const b = await web3.eth.getBlock('finalized');
blockData = Number(b.number);
if (block === 'blockHash') {
blockData = (await web3.eth.getBlock(blockNumber)).hash as string;
blockData = b.hash as string;
}
}
const result = await web3.eth.getStorageAt(
Expand All @@ -79,7 +85,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