zksync-cli
zksync-cli copied to clipboard
`tx.wait` behaves unexpectantly in tests
🐛 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.log
ed 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
Using the cli, I created a new project using ethersv5 and it doesn't seem to be an issue anymore
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});
Closing due to staleness.