You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed that the stack traces provided for failing tests only include top-level calls from my test contract, and are missing any external calls that occur while executing the top-level call, which normally are included when using vanilla foundry. For example, I have the following contracts and test:
contractA {
function revertIfEven(uint256number) publicpurereturns (uint256) {
if (number %2==0) {
revert("Number is even");
}
return number;
}
}
contractB {
A public a;
constructor(A _a) {
a = _a;
}
function callRevertIfEven(uint256number) publicviewreturns (uint256) {
return a.revertIfEven(number);
}
}
contractC {
B public b;
constructor(B _b) {
b = _b;
}
function isEven(uint256number) publicviewreturns (bool) {
try b.callRevertIfEven(number) {
returnfalse;
} catchError(stringmemory) {
returntrue;
}
}
}
contractABCTestisTest {
A public a;
B public b;
C public c;
function setUp() public {
a =newA();
b =newB(a);
c =newC(b);
}
function test_StackTraceDepth() public {
// Call C.isEven, which calls B.callRevertIfEven, which calls A.revertIfEven
c.isEven(2);
// Force test to fail so we can see the stack traceassertTrue(false);
}
}
When this test fails, we can observe the following stack trace (after replacing addresses with contract names):
Component
Forge
Describe the feature you would like
I have noticed that the stack traces provided for failing tests only include top-level calls from my test contract, and are missing any external calls that occur while executing the top-level call, which normally are included when using vanilla foundry. For example, I have the following contracts and test:
When this test fails, we can observe the following stack trace (after replacing addresses with contract names):
But I would expect the stack trace to look like this:
Additional context
Minimal reproducible example:
https://github.com/webthethird/min-reproducible-missing-stack-trace-depth
The text was updated successfully, but these errors were encountered: