testutil

package
v1.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertStatusErrorWithCode

func AssertStatusErrorWithCode(t *testing.T, err error, code codes.Code)

AssertStatusErrorWithCode verifies that the provided error is a gRPC status error of the provided status code.

func DisableLogging

func DisableLogging() (reset func())

func GenerateSolanaKeypair

func GenerateSolanaKeypair(t *testing.T) ed25519.PrivateKey

func GenerateSolanaKeys

func GenerateSolanaKeys(t *testing.T, n int) []ed25519.PublicKey

func NewRandomAccount

func NewRandomAccount(t *testing.T) *common.Account

func SetupRandomSubsidizer

func SetupRandomSubsidizer(t *testing.T, data code_data.Provider) *common.Account

func WaitFor

func WaitFor(timeout, interval time.Duration, condition func() bool) error

WaitFor waits for a condition to be met before the specified timeout

Types

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Server provides a local gRPC server with basic interceptors that can be used for testing with no external dependencies.

func NewServer

func NewServer(opts ...ServerOption) (*grpc.ClientConn, *Server, error)

NewServer creates a new Server.

func (*Server) RegisterService

func (s *Server) RegisterService(registerFunc func(s *grpc.Server))

RegisterService registers a gRPC service with Server.

func (*Server) Serve

func (s *Server) Serve() (stopFunc func(), err error)

Serve asynchronously starts the server, provided it has not been previously started or stopped. Callers should use stopFunc to stop the server in order to cleanup the underlying resources.

type ServerOption

type ServerOption func(o *serverOpts)

ServerOption configures the settings when creating a test server.

func WithStreamClientInterceptor

func WithStreamClientInterceptor(i grpc.StreamClientInterceptor) ServerOption

WithStreamClientInterceptor adds a stream client interceptor to the test client.

func WithStreamServerInterceptor

func WithStreamServerInterceptor(i grpc.StreamServerInterceptor) ServerOption

WithStreamServerInterceptor adds a stream server interceptor to the test client.

func WithUnaryClientInterceptor

func WithUnaryClientInterceptor(i grpc.UnaryClientInterceptor) ServerOption

WithUnaryClientInterceptor adds a unary client interceptor to the test client.

func WithUnaryServerInterceptor

func WithUnaryServerInterceptor(i grpc.UnaryServerInterceptor) ServerOption

WithUnaryServerInterceptor adds a unary server interceptor to the test client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL