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

feat: display test cases discovered by the fuzzer #382

Merged
merged 3 commits into from
Jul 2, 2024
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
3 changes: 3 additions & 0 deletions fuzzing/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ func (f *Fuzzer) RegisterTestCase(testCase TestCase) {
f.testCasesLock.Lock()
defer f.testCasesLock.Unlock()

// Display what is being tested
f.logger.Info(testCase.LogMessage().Elements()...)

// Append our test case to our list
f.testCases = append(f.testCases, testCase)
}
Expand Down
10 changes: 6 additions & 4 deletions fuzzing/test_case_optimization.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ func (t *OptimizationTestCase) LogMessage() *logging.LogBuffer {

// Note that optimization tests will always pass
buffer.Append(colors.GreenBold, fmt.Sprintf("[%s] ", t.Status()), colors.Bold, t.Name(), colors.Reset, "\n")
buffer.Append(fmt.Sprintf("Test for method \"%s.%s\" resulted in the maximum value: ", t.targetContract.Name(), t.targetMethod.Sig))
buffer.Append(colors.Bold, t.value, colors.Reset, "\n")
buffer.Append(colors.Bold, "[Call Sequence]", colors.Reset, "\n")
buffer.Append(t.CallSequence().Log().Elements()...)
if t.Status() != TestCaseStatusNotStarted {
buffer.Append(fmt.Sprintf("Test for method \"%s.%s\" resulted in the maximum value: ", t.targetContract.Name(), t.targetMethod.Sig))
buffer.Append(colors.Bold, t.value, colors.Reset, "\n")
buffer.Append(colors.Bold, "[Call Sequence]", colors.Reset, "\n")
buffer.Append(t.CallSequence().Log().Elements()...)
}
// If an execution trace is attached then add it to the message
if t.optimizationTestTrace != nil {
buffer.Append(colors.Bold, "[Optimization Test Execution Trace]", colors.Reset, "\n")
Expand Down