I know something is definitely wrong with this function because my test runs smoothly once taken away. All the code seems right to me I can find my mistake.
Hi
I don’t know what you are testing exactly but I think I found one issue.
The first for loop
for(uint i = orders.length ....){
if(orders[i].price ...){
....
}
}
Array index starts from 0.
Let’s say that orders array looks like: [10,20,30].
Then orders.length = 3.
In the first if statement, you are accessing orders[3] that doesn’t exist.
Hint:
If you get this kind of revert error, first check array. 90% of the problems are caused by accessing undefined element.
1 Like