Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test for custom type decoding #6587

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions crates/forge/tests/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| {
cmd.assert_err();
});

// <https://github.com/foundry-rs/foundry/issues/6531>
forgetest_init!(repro_6531, |prj, cmd| {
prj.wipe_contracts();

Expand Down Expand Up @@ -401,3 +402,33 @@ contract USDCCallingTest is Test {

cmd.args(["test", "-vvvv"]).unchecked_output().stdout_matches_content(&expected);
});

// <https://github.com/foundry-rs/foundry/issues/6579>
forgetest_init!(include_custom_types_in_traces, |prj, cmd| {
prj.wipe_contracts();

prj.add_test(
"Contract.t.sol",
r#"
import {Test} from "forge-std/Test.sol";

error PoolNotInitialized();
event MyEvent(uint256 a);

contract CustomTypesTest is Test {
function testErr() public pure {
revert PoolNotInitialized();
}
function testEvent() public {
emit MyEvent(100);
}
}
"#,
)
.unwrap();

cmd.args(["test", "-vvvv"]).unchecked_output().stdout_matches_path(
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests/fixtures/include_custom_types_in_traces.stdout"),
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Compiling 1 files with 0.8.23
Solc 0.8.23 finished in 798.51ms
Compiler run successful!

Running 2 tests for test/Contract.t.sol:CustomTypesTest
[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 231)
Traces:
[231] CustomTypesTest::testErr()
└─ ← PoolNotInitialized()

[PASS] testEvent() (gas: 1312)
Traces:
[1312] CustomTypesTest::testEvent()
├─ emit MyEvent(a: 100)
└─ ← ()

Test result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.88ms

Ran 1 test suites: 1 tests passed, 1 failed, 0 skipped (2 total tests)

Failing tests:
Encountered 1 failing test in test/Contract.t.sol:CustomTypesTest
[FAIL. Reason: PoolNotInitialized()] testErr() (gas: 231)

Encountered a total of 1 failing tests, 1 tests succeeded