Skip to content

Commit

Permalink
feat: display test cases discovered by the fuzzer (#382)
Browse files Browse the repository at this point in the history
* feat: display test cases discovered by the fuzzer

* check whether optimization test case has started
  • Loading branch information
0xalpharush authored and s4nsec committed Jul 8, 2024
1 parent 3259c27 commit 3cbe484
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit 3cbe484

Please sign in to comment.