tests
Package tests
import "github.com/luxfi/node/tests"Functions
ContextWithTimeout
func ContextWithTimeout(tc TestContext, duration time.Duration) context.ContextHelper simplifying use of a timed context by canceling the context with the test context.
DefaultContext
func DefaultContext(tc TestContext) context.ContextHelper simplifying use of a timed context configured with the default timeout.
DefaultNotifyContext
func DefaultNotifyContext(duration time.Duration, cleanup func(func())) context.ContextDefaultNotifyContext returns a context that is marked done when signals indicating process termination are received. If a non-zero duration is provided, the parent to the notify context will be a context with a timeout for that duration.
GetMetricValue
func GetMetricValue(metrics NodeMetrics, name string, labels metric.Labels) (float64, bool)GetMetricValue returns the value of the specified metric which has the required labels.
If multiple metrics match the provided labels, the first metric found is returned.
Only Counter and Gauge metrics are supported.
NewDefaultLogger
func NewDefaultLogger(prefix string) log.LoggerOutf
func Outf(format string, args ...interface{})Outputs to stdout.
Examples:
- Out("{{green}}{{bold}}hi there %q{{/}}", "aa")
- Out("{{magenta}}{{bold}}hi therea{{/}} {{cyan}}{{underline}}b{{/}}")
See https://github.com/onsi/ginkgo/blob/v2.0.0/formatter/formatter.go#L52-L73 for an exhaustive list of color options.
WithDefaultContext
func WithDefaultContext(tc TestContext) common.OptionHelper simplifying use via an option of a timed context configured with the default timeout.
Types
NodeMetrics
"metric name" -> "metric value"
func GetNodeMetrics(ctx context.Context, nodeURI string) (NodeMetrics, error)NodesMetrics
URI -> "metric name" -> "metric value"
func GetNodesMetrics(ctx context.Context, nodeURIs []string) (NodesMetrics, error)SimpleNodeMetrics
"metric name" -> "metric value"
func GetMetricsValue(url string, metrics ...string) (SimpleNodeMetrics, error)func GetSimpleNodeMetrics(nodeURI string, metricNames ...string) (SimpleNodeMetrics, error)SimpleNodesMetrics
URI -> "metric name" -> "metric value"
func GetSimpleNodesMetrics(nodeURIs []string, metricNames ...string) (SimpleNodesMetrics, error)SimpleTestContext
func NewTestContext(log log.Logger) *SimpleTestContextfunc NewTestContextWithArgs(
_ context.Context,
log log.Logger,
errorfHandler func(format string, args ...any),
panicHandler func(r any),
) *SimpleTestContextfunc (tc *SimpleTestContext) By(_ string, _ ...func())func (tc *SimpleTestContext) Cleanup()func (tc *SimpleTestContext) ContextWithTimeout(duration time.Duration) context.Contextfunc (tc *SimpleTestContext) DefaultContext() context.Contextfunc (tc *SimpleTestContext) DeferCleanup(cleanup func())func (tc *SimpleTestContext) Errorf(format string, args ...interface{})func (tc *SimpleTestContext) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msg string)func (*SimpleTestContext) FailNow()func (tc *SimpleTestContext) Log() log.Loggerfunc (tc *SimpleTestContext) Recover()func (tc *SimpleTestContext) WithDefaultContext() common.Option