mock

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransferRPC       = "trisa.api.v1beta1.TRISANetwork/Transfer"
	TransferStreamRPC = "trisa.api.v1beta1.TRISANetwork/TransferStream"
	KeyExchangeRPC    = "trisa.api.v1beta1.TRISANetwork/KeyExchange"
	ConfirmAddressRPC = "trisa.api.v1beta1.TRISANetwork/ConfirmAddress"
	StatusRPC         = "trisa.api.v1beta1.TRISAHealth/Status"
)

RPC names as defined by the grpc info method; used for tracking calls.

Variables

This section is empty.

Functions

This section is empty.

Types

type TRISA

type TRISA struct {
	api.UnimplementedTRISAHealthServer
	api.UnimplementedTRISANetworkServer

	Calls map[string]int

	OnTransfer       func(context.Context, *api.SecureEnvelope) (*api.SecureEnvelope, error)
	OnTransferStream func(api.TRISANetwork_TransferStreamServer) error
	OnKeyExchange    func(context.Context, *api.SigningKey) (*api.SigningKey, error)
	OnConfirmAddress func(context.Context, *api.Address) (*api.AddressConfirmation, error)
	OnStatus         func(context.Context, *api.HealthCheck) (*api.ServiceState, error)
	// contains filtered or unexported fields
}

TRISA implements the TRISANetwork and TRISAHealth services for mocking tests for clients that might call a remote server.

func New

func New(bufnet *bufconn.Listener, opts ...grpc.ServerOption) *TRISA

func (*TRISA) Channel

func (s *TRISA) Channel() *bufconn.Listener

func (*TRISA) ConfirmAddress

func (s *TRISA) ConfirmAddress(ctx context.Context, in *api.Address) (*api.AddressConfirmation, error)

func (*TRISA) KeyExchange

func (s *TRISA) KeyExchange(ctx context.Context, in *api.SigningKey) (*api.SigningKey, error)

func (*TRISA) Reset

func (s *TRISA) Reset()

func (*TRISA) Shutdown

func (s *TRISA) Shutdown()

func (*TRISA) Status

func (s *TRISA) Status(ctx context.Context, in *api.HealthCheck) (*api.ServiceState, error)

func (*TRISA) Transfer

func (s *TRISA) Transfer(ctx context.Context, in *api.SecureEnvelope) (*api.SecureEnvelope, error)

func (*TRISA) TransferStream

func (s *TRISA) TransferStream(stream api.TRISANetwork_TransferStreamServer) error

func (*TRISA) UseError

func (s *TRISA) UseError(rpc string, code codes.Code, msg string) error

UseError allows you to specify a gRPC status error to return from the specified RPC.

func (*TRISA) UseFixture

func (s *TRISA) UseFixture(rpc, path string) (err error)

UseFixture loadsa a JSON fixture from disk (usually in a testdata folder) to use as the protocol buffer response to the specified RPC, simplifying handler mocking.

Jump to

Keyboard shortcuts

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