mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
- 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
32 lines
762 B
Go
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
|
|
})
|
|
}
|