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

test: Fix "missing revert data" error; fix / debug integration tests #2804

Merged
merged 6 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ impl MainNodeBuilder {
subscriptions_limit: Some(rpc_config.subscriptions_limit()),
batch_request_size_limit: Some(rpc_config.max_batch_request_size()),
response_body_size_limit: Some(rpc_config.max_response_body_size()),
with_extended_tracing: rpc_config.extended_api_tracing,
slowli marked this conversation as resolved.
Show resolved Hide resolved
..Default::default()
};
self.node.add_layer(Web3ServerLayer::http(
Expand Down
36 changes: 16 additions & 20 deletions core/tests/ts-integration/tests/api/web3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('web3 API compatibility tests', () => {

test('Should test web3 response extensions', async () => {
if (testMaster.isFastMode()) {
// This test requires a new L1 batch to be created, which may be very time consuming on stage.
// This test requires a new L1 batch to be created, which may be very time-consuming on stage.
return;
}

Expand Down Expand Up @@ -333,7 +333,7 @@ describe('web3 API compatibility tests', () => {

// Pubsub notifier is not reactive + tests are being run in parallel, so we can't expect that the next block
// would be expected one. Instead, we just want to receive an event with the particular block number.
wsProvider.on('block', (block) => {
await wsProvider.on('block', (block) => {
if (block >= currentBlock) {
newBlock = block;
}
Expand All @@ -355,7 +355,6 @@ describe('web3 API compatibility tests', () => {
// ...though the gap should not be *too* big.
expect(newBlock).toBeLessThan(currentBlock + 100);
await tx.wait(); // To not leave a hanging promise.
wsProvider.removeAllListeners();
slowli marked this conversation as resolved.
Show resolved Hide resolved
await wsProvider.destroy();
});

Expand All @@ -368,7 +367,7 @@ describe('web3 API compatibility tests', () => {

let newTxHash: string | null = null;
// We can't use `once` as there may be other pending txs sent together with our one.
wsProvider.on('pending', async (txHash) => {
await wsProvider.on('pending', async (txHash) => {
const tx = await alice.provider.getTransaction(txHash);
// We're waiting for the exact transaction to appear.
if (!tx || tx.to != uniqueRecipient) {
Expand All @@ -392,7 +391,6 @@ describe('web3 API compatibility tests', () => {

expect(newTxHash as string).toEqual(tx.hash);
await tx.wait(); // To not leave a hanging promise.
wsProvider.removeAllListeners();
await wsProvider.destroy();
});

Expand All @@ -404,7 +402,7 @@ describe('web3 API compatibility tests', () => {
// We're sending a few transfers from the wallet, so we'll use a new account to make event unique.
let uniqueRecipient = testMaster.newEmptyAccount().address;

// Setup a filter for an ERC20 transfer.
// Set up a filter for an ERC20 transfer.
const erc20TransferTopic = ethers.id('Transfer(address,address,uint256)');
let filter = {
address: l2Token,
Expand All @@ -414,15 +412,15 @@ describe('web3 API compatibility tests', () => {
ethers.zeroPadValue(uniqueRecipient, 32) // Recipient
]
};
wsProvider.once(filter, (event) => {
await wsProvider.once(filter, (event) => {
newEvent = event;
});

// Setup a filter that should not match anything.
// Set up a filter that should not match anything.
let incorrectFilter = {
address: alice.address
};
wsProvider.once(incorrectFilter, (_) => {
await wsProvider.once(incorrectFilter, (_) => {
expect(null).fail('Found log for incorrect filter');
});

Expand All @@ -439,7 +437,6 @@ describe('web3 API compatibility tests', () => {

expect((newEvent as any).transactionHash).toEqual(tx.hash);
await tx.wait(); // To not leave a hanging promise.
wsProvider.removeAllListeners();
await wsProvider.destroy();
});

Expand Down Expand Up @@ -608,7 +605,7 @@ describe('web3 API compatibility tests', () => {

// Pubsub notify is not reactive and may be laggy, so we want to increase the chances
// for test to pass. So we try to sleep a few iterations until we receive expected amount
// of events. If we won't receive them, we continue and the test will fail anyway.
// of events. If we don't receive them, we continue and the test will fail anyway.
const expectedTrivialEventsCount = 2;
const expectedSimpleEventsCount = 2;
const expectedIndexedEventsCount = 1;
Expand Down Expand Up @@ -697,12 +694,11 @@ describe('web3 API compatibility tests', () => {

// There are around `0.5 * maxLogsLimit` logs in [tx1Receipt.blockNumber, tx1Receipt.blockNumber] range,
// so query with such filter should succeed.
await expect(
alice.provider.getLogs({
fromBlock: tx1Receipt.blockNumber,
toBlock: tx1Receipt.blockNumber
})
).resolves;
const logs = await alice.provider.getLogs({
fromBlock: tx1Receipt.blockNumber,
toBlock: tx1Receipt.blockNumber
});
expect(logs.length).toBeGreaterThanOrEqual(maxLogsLimit / 2);

// There are at least `1.5 * maxLogsLimit` logs in [tx1Receipt.blockNumber, tx3Receipt.blockNumber] range,
// so query with such filter should fail.
Expand All @@ -716,7 +712,7 @@ describe('web3 API compatibility tests', () => {

test('Should throw error for estimate gas for account with balance < tx.value', async () => {
let poorBob = testMaster.newEmptyAccount();
expect(
await expect(
poorBob.estimateGas({ value: 1, to: alice.address })
).toBeRejected(/*'insufficient balance for transfer'*/);
});
Expand Down Expand Up @@ -860,7 +856,7 @@ describe('web3 API compatibility tests', () => {
const getLogsByHash = (await alice.provider.getLogs({ blockHash: latestBlock.hash || undefined })).map((x) => {
return new zksync.types.Log({ ...x, l1BatchNumber: 0 }, alice.provider); // Set bogus value.
});
await expect(getLogsByNumber).toEqual(getLogsByHash);
expect(getLogsByNumber).toEqual(getLogsByHash);

// Check that incorrect queries are rejected.
await expect(
Expand Down Expand Up @@ -1030,7 +1026,7 @@ describe('web3 API compatibility tests', () => {
const incrementFunctionData = contract2.interface.encodeFunctionData('increment', [1]);

// Assert that the estimation fails because the increment function is not present in contract1
expect(
await expect(
alice.provider.estimateGas({
to: contract1Address.toString(),
data: incrementFunctionData
Expand Down
34 changes: 19 additions & 15 deletions core/tests/upgrade-test/tests/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ describe('Upgrade test', function () {
);
executeOperation = chainUpgradeCalldata;

console.log('Sending scheduleTransparentOperation');
slowli marked this conversation as resolved.
Show resolved Hide resolved
await sendGovernanceOperation(stmUpgradeData.scheduleTransparentOperation);
console.log('Sending executeOperation');
await sendGovernanceOperation(stmUpgradeData.executeOperation);

console.log('Sending chain admin operation');
await sendChainAdminOperation(setTimestampCalldata);

// Wait for server to process L1 event.
Expand Down Expand Up @@ -371,23 +373,25 @@ describe('Upgrade test', function () {
});

async function sendGovernanceOperation(data: string) {
await (
await ecosystemGovWallet.sendTransaction({
to: await governanceContract.getAddress(),
data: data,
type: 0
})
).wait();
const transaction = await ecosystemGovWallet.sendTransaction({
to: await governanceContract.getAddress(),
data: data,
type: 0
});
console.log(`Sent governance operation, tx_hash=${transaction.hash}, nonce=${transaction.nonce}`);
await transaction.wait();
console.log(`Governance operation succeeded, tx_hash=${transaction.hash}`);
}

async function sendChainAdminOperation(data: string) {
await (
await adminGovWallet.sendTransaction({
to: await chainAdminContract.getAddress(),
data: data,
type: 0
})
).wait();
const transaction = await adminGovWallet.sendTransaction({
to: await chainAdminContract.getAddress(),
data: data,
type: 0
});
console.log(`Sent chain admin operation, tx_hash=${transaction.hash}, nonce=${transaction.nonce}`);
await transaction.wait();
console.log(`Chain admin operation succeeded, tx_hash=${transaction.hash}`);
}
});

Expand Down
2 changes: 1 addition & 1 deletion docker-compose-cpu-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'
services:
reth:
restart: always
image: "ghcr.io/paradigmxyz/reth:v0.2.0-beta.2"
image: "ghcr.io/paradigmxyz/reth:v1.0.6"
volumes:
- type: bind
source: ./volumes/reth/data
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-gpu-runner-cuda-12-0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'
services:
reth:
restart: always
image: "ghcr.io/paradigmxyz/reth:v0.2.0-beta.2"
image: "ghcr.io/paradigmxyz/reth:v1.0.6"
volumes:
- type: bind
source: ./volumes/reth/data
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-gpu-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'
services:
reth:
restart: always
image: "ghcr.io/paradigmxyz/reth:v0.2.0-beta.2"
image: "ghcr.io/paradigmxyz/reth:v1.0.6"
volumes:
- type: bind
source: ./volumes/reth/data
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'
services:
reth:
restart: always
image: "ghcr.io/paradigmxyz/reth:v0.2.0-beta.2"
image: "ghcr.io/paradigmxyz/reth:v1.0.6"
ports:
- 127.0.0.1:8545:8545
volumes:
Expand Down
Loading