Ethereum error: 900000ms timeout has exceeded *
Evaluated by intelligent Ethereum based contracts in Hardhat, more than 900000ms has exceeded “from the equivalent of your lottery transaction. This problem can take up the test case is to clean the homework.
unding error
There is a different message from Sugary that there was a tea time for regulating the execution time more time (900000ms). However, this is not necessary relatively relatively relative to theme there are several factors that can cause this issuing:
- Network latency : Your intelligent contract can be a slow network connection, let it be delayed in performing tests.
- High calculation load : Running complex simulations or generating CPU consumption and memorial resources, determining the case of expiration.
- Async operations : Your case of being involved asynchronous operations (eg, RPCS Web3 calls, I/O tasks), which may take a long time to complete.
Solution
To solve this problem, you can try your souls:
- Present -See Async Operations Code : Make sure all Async operations are expected or properly using call calls. You can keywords or
.hen ()
chain to wait for asynchronous operations.
- Reduce the calculation task
: Limit amunt data generated, simulate the script and minimize the calculations in your tests.
- Improve the network connection : Optimize -RPC Web3 calls and ensure a minimum latent stack network connection.
4
Example of solution
Here is updated for example to have a small number of incorporates to have optimizations:
`Javacrpt
const {etherers} = requires ("hardhat");
Describe ("Lottery contract", () => {{
Leave the lottery;
forward (Async Function () {
// load the lottery contract
const [account1, account2] = await ethers.getsigers ();
(wait for etherers.getcontractFactry ("lottery")). The ((Loterycontract) => {{{{{{{{{
LotteryContract.Peploy (cont.1address);
LotteryContract.PPLOY (account2.address);
return lotteryContract.dalyed ();
});
});
IT (Shold choose a winner, "async function () {
// reset the lottery
Wait (wait LotteryContract.reset ()). (() => {{{
// choose a winner
consist result = wait (wait LotteryContract.pickwinner ()). Theten ((winner) => {{{{{
Returns Ethers.utils.Formatbytes (
"0x" + feedback,
["Hex"]
);
});
console.log (result);
});
});
});
`
Byess solutions and adapt your case to optimize for async operations, as well as the time range and success.
Additional Tip
- Remember that the time duct to make an extension of lickers like networks are supplier.
- If you have experience from persistent problems with time intervals, the reacons of robust consideration “Jest” or “Mocha”.
- Always monitor the execution time of the test suite and adjust your tests accordingly to prevent-dimets.