zksync-cli icon indicating copy to clipboard operation
zksync-cli copied to clipboard

`tx.wait` behaves unexpectantly in tests

Open spacesailor24 opened this issue 11 months ago • 2 comments

🐛 Bug Report for zkSync CLI

📝 Description

There seems to be some sort of delay between a transaction that transfers ETH being included in a block, and the ETH balance of the receiving account being update and queryable via provider.getBalance - tx.wait doesn't seem to have an affect

🔄 Reproduction Steps

I've created a minimal reproduction repo here

🤔 Expected Behavior

After doing:

const tx = await wallet.sendTransaction({ value: parseEther('1'), to: receiver });
await tx.wait();

console.log(await wallet.provider.getBalance(receiver));

The console.loged value should immediately be 1000000000000000000n

😯 Current Behavior

The immediate console.log (and many after) log 0n, after sometime getBalance finally returns the expected incremented balance for the receiver

🖥️ Environment

  • Package version: 1.5.1
  • Node version: v20.11.1
  • NPM/Yarn version: pnpm 8.15.4
  • Operating System & Version: macOS Sonoma 14.3.1
  • Other relevant environment details:

📋 Additional Context

See reproduction repo

spacesailor24 avatar Mar 12 '24 19:03 spacesailor24

Using the cli, I created a new project using ethersv5 and it doesn't seem to be an issue anymore

spacesailor24 avatar Mar 12 '24 21:03 spacesailor24

hey @spacesailor24 this might be related to the cache that ethers v6 has implemented by default. This has been mentioned across different issues (example here. Please try disabling the cache by initialising your provider this way:

const provider = new Provider(url, undefined, {cacheTimeout: -1});

uF4No avatar Mar 21 '24 15:03 uF4No

Closing due to staleness.

dutterbutter avatar Sep 18 '24 01:09 dutterbutter