Documentation
¶
Index ¶
- func CheckMetrics(t *testing.T, url string, expectedMetrics ...string)
- func CheckServerStopped(t *testing.T, addr string) bool
- func EnsurePersistedTxStatus(ctx context.Context, t *testing.T, r StatusRetriever, txIDs []string, ...)
- func EventuallyIntMetric(t *testing.T, expected int, m prometheus.Metric, waitFor, tick time.Duration, ...)
- func FailHandler(t *testing.T)
- func GetIntMetricValue(t *testing.T, m prometheus.Metric) int
- func GetMetricValue(t *testing.T, m prometheus.Metric) float64
- func GetMetricValueFromURL(t *testing.T, url, metricName string) int
- func LogStruct(t *testing.T, name string, v any)
- func RequireIntMetricValue(t *testing.T, expected int, m prometheus.Metric)
- func RequireProtoElementsMatch[T proto.Message](t require.TestingT, expected, actual []T, msgAndArgs ...any)
- func RequireProtoEqual(t require.TestingT, expected, actual proto.Message)
- func RunGrpcServerForTest(ctx context.Context, tb testing.TB, serverConfig *connection.ServerConfig, ...) *grpc.Server
- func RunServiceAndGrpcForTest(ctx context.Context, t *testing.T, service connection.Service, ...) *channel.Ready
- func RunServiceForTest(ctx context.Context, tb testing.TB, service func(ctx context.Context) error, ...) *channel.Ready
- func ServerToClientConfig(servers ...*connection.ServerConfig) *connection.ClientConfig
- func SetupDebugging()
- func WaitUntilGrpcServerIsDown(ctx context.Context, t *testing.T, conn grpc.ClientConnInterface)
- func WaitUntilGrpcServerIsReady(ctx context.Context, t *testing.T, conn grpc.ClientConnInterface)
- type BroadcastStream
- type Broadcaster
- type GrpcServers
- type StatusRetriever
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckMetrics ¶
CheckMetrics checks the metrics endpoint for the expected metrics.
func CheckServerStopped ¶
CheckServerStopped returns true if the grpc server listening on a given address has been stopped.
func EnsurePersistedTxStatus ¶
func EnsurePersistedTxStatus( ctx context.Context, t *testing.T, r StatusRetriever, txIDs []string, expected map[string]*protoblocktx.StatusWithHeight, )
EnsurePersistedTxStatus fails the test if the given TX IDs does not match the expected status.
func EventuallyIntMetric ¶
func EventuallyIntMetric( t *testing.T, expected int, m prometheus.Metric, waitFor, tick time.Duration, msgAndArgs ...any, )
EventuallyIntMetric fail the test if the integer metric is not equal to the expected value after the given duration.
func GetIntMetricValue ¶
func GetIntMetricValue(t *testing.T, m prometheus.Metric) int
GetIntMetricValue returns the value of a prometheus metric, rounded to the nearest integer.
func GetMetricValue ¶
func GetMetricValue(t *testing.T, m prometheus.Metric) float64
GetMetricValue returns the value of a prometheus metric.
func GetMetricValueFromURL ¶
GetMetricValueFromURL reads the metrics endpoint and fetch the value of a specific metric.
func RequireIntMetricValue ¶
func RequireIntMetricValue(t *testing.T, expected int, m prometheus.Metric)
RequireIntMetricValue fail the test if the integer metric is not equal to the expected value.
func RequireProtoElementsMatch ¶
func RequireProtoElementsMatch[T proto.Message]( t require.TestingT, expected, actual []T, msgAndArgs ...any, )
RequireProtoElementsMatch verifies that two arrays of proto have the same elements.
func RequireProtoEqual ¶
RequireProtoEqual verifies that two proto are equal.
func RunGrpcServerForTest ¶
func RunGrpcServerForTest( ctx context.Context, tb testing.TB, serverConfig *connection.ServerConfig, register func(server *grpc.Server), ) *grpc.Server
RunGrpcServerForTest starts a GRPC server using a register method. It handles the cleanup of the GRPC server at the end of a test, and ensure the test is ended only when the GRPC server is down. It also updates the server config endpoint port to the actual port if the configuration did not specify a port. The method asserts that the GRPC server did not end with failure.
func RunServiceAndGrpcForTest ¶
func RunServiceAndGrpcForTest( ctx context.Context, t *testing.T, service connection.Service, serverConfig ...*connection.ServerConfig, ) *channel.Ready
RunServiceAndGrpcForTest combines running a service and its GRPC server. It is intended for services that implements the Service API (i.e., command line services).
func RunServiceForTest ¶
func RunServiceForTest( ctx context.Context, tb testing.TB, service func(ctx context.Context) error, waitFunc func(ctx context.Context) bool, ) *channel.Ready
RunServiceForTest runs a service using the given service method, and waits for it to be ready given the waitFunc method. It handles the cleanup of the service at the end of a test, and ensure the test is ended only when the service return. The method asserts that the service did not end with failure. Returns a ready flag that indicate that the service is done.
func ServerToClientConfig ¶
func ServerToClientConfig(servers ...*connection.ServerConfig) *connection.ClientConfig
ServerToClientConfig is used to create client configuration from existing server(s).
func SetupDebugging ¶
func SetupDebugging()
SetupDebugging can be added for development to tests that required additional debugging info.
func WaitUntilGrpcServerIsDown ¶ added in v0.1.6
WaitUntilGrpcServerIsDown uses the health check API to check a service is down.
func WaitUntilGrpcServerIsReady ¶
func WaitUntilGrpcServerIsReady( ctx context.Context, t *testing.T, conn grpc.ClientConnInterface, )
WaitUntilGrpcServerIsReady uses the health check API to check a service readiness.
Types ¶
type BroadcastStream ¶ added in v0.1.6
type BroadcastStream struct { Broadcaster ConnectionManager *ordererconn.ConnectionManager }
BroadcastStream implements broadcast, with the addition of automatically signing the envelope.
func NewBroadcastStream ¶ added in v0.1.6
func NewBroadcastStream(ctx context.Context, config *ordererconn.Config) (*BroadcastStream, error)
NewBroadcastStream starts a new broadcast stream (non-production).
func (*BroadcastStream) Close ¶ added in v0.1.6
func (s *BroadcastStream) Close()
Close closes all the connections for the stream.
type Broadcaster ¶ added in v0.1.6
Broadcaster can be either CFT or BFT broadcast.
type GrpcServers ¶
type GrpcServers struct { Servers []*grpc.Server Configs []*connection.ServerConfig }
GrpcServers holds the server instances and their respective configurations.
func StartGrpcServersForTest ¶
func StartGrpcServersForTest( ctx context.Context, t *testing.T, numService int, register func(*grpc.Server, int), ) *GrpcServers
StartGrpcServersForTest starts multiple GRPC servers with a default configuration.
func StartGrpcServersWithConfigForTest ¶
func StartGrpcServersWithConfigForTest( ctx context.Context, t *testing.T, sc []*connection.ServerConfig, register func(*grpc.Server, int), ) *GrpcServers
StartGrpcServersWithConfigForTest starts multiple GRPC servers with given configurations.
type StatusRetriever ¶
type StatusRetriever interface { GetTransactionsStatus(context.Context, *protoblocktx.QueryStatus, ...grpc.CallOption) ( *protoblocktx.TransactionsStatus, error, ) }
StatusRetriever provides implementation retrieve status of given transaction identifiers.