go-ethereum/libevm/ethtest
Jonathan Oppenheimer b4a7f35411
test: add log handler for error promotion to testing.TB (#259)
This adds a test logger for libevm, that treats errors as they _should_
be treated.

- Logs at `log.LevelWarn` and above trigger `t.Errorf()`, causing tests
to fail
- Critical logs fail immediately: Logs at `log.LevelCrit` trigger
`t.Fatalf()`
- Info/debug logs pass through: Lower severity logs use `t.Logf()` for
informational output

You can use the logger like this: 

```go
  import (
      "github.com/ava-labs/libevm/ethtest"
      "github.com/ava-labs/libevm/log"
  )

  func TestSomething(t *testing.T) {
     logger := log.NewLogger(ethtest.NewTBLogHandler(t, log.LevelDebug))

     // Or to set globally
     log.SetDefault(log.NewLogger(ethtest.NewTBLogHandler(t, log.LevelDebug))
  }
```

I was thinking about adding tests to show this works, but it seemed
silly to test a testing utility.

---------

Signed-off-by: Jonathan Oppenheimer <147infiniti@gmail.com>
Co-authored-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
2026-01-28 15:45:30 +00:00
..
devkey.go feat: ethtest.UNSAFEDeterministicPrivateKey() (#244) 2025-11-12 18:29:15 +00:00
devkey_test.go feat: ethtest.UNSAFEDeterministicPrivateKey() (#244) 2025-11-12 18:29:15 +00:00
dummy.go feat: vm.Hooks.PreprocessingGasCharge() (#235) 2025-12-15 20:49:13 +00:00
evm.go feat: vm.Hooks.PreprocessingGasCharge() (#235) 2025-12-15 20:49:13 +00:00
logger.go test: add log handler for error promotion to testing.TB (#259) 2026-01-28 15:45:30 +00:00
logger_test.go test: add log handler for error promotion to testing.TB (#259) 2026-01-28 15:45:30 +00:00
rand.go test: lock in types.Header RLP encoding (#87) 2024-12-12 13:00:02 +00:00