Files
evm/metrics/metricstest/metrics.go
zeekay 7eb168a91e feat: update EVM implementation for compatibility
- Updated auth and bind interfaces for improved transaction handling
- Enhanced network configuration and database wrappers
- Improved validator state management and uptime tracking
- Updated sync client and gossip test implementations
- Fixed mock interfaces and handler implementations
- Updated dependencies in go.mod/go.sum
2025-08-04 06:38:07 +00:00

32 lines
762 B
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package metricstest
import (
"sync"
"testing"
"github.com/luxfi/geth/metrics"
)
var metricsLock sync.Mutex
// WithMetrics enables go-ethereum metrics globally for the test.
// If the metrics.Enabled() is already true, nothing is done.
// Otherwise, it is set to true and is reverted to false when the test finishes.
func WithMetrics(t *testing.T) {
metricsLock.Lock()
t.Cleanup(func() {
metricsLock.Unlock()
})
if metrics.Enabled() {
return
}
metrics.Enable()
t.Cleanup(func() {
// Note: There's no way to disable metrics once enabled in geth v1.16.1
// This is a limitation of the current geth metrics implementation
})
}