mocksrv

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartAdminApiServer

func StartAdminApiServer(t *testing.T, service *AdminServiceMock) string

func StartServer

func StartServer(t *testing.T, services map[string]interface{}) string

func StartStateApiServer

func StartStateApiServer(t *testing.T, service *StateServiceMock) string

Types

type AdminServiceMock

type AdminServiceMock struct {
	InfoResponse *abrpc.NodeInfoResponse
}

func NewAdminServiceMock

func NewAdminServiceMock(opts ...Option) *AdminServiceMock

func (*AdminServiceMock) GetNodeInfo

func (s *AdminServiceMock) GetNodeInfo() (*abrpc.NodeInfoResponse, error)

type Option

type Option func(*Options)

func WithError

func WithError(err error) Option

func WithInfoResponse

func WithInfoResponse(infoResponse *abrpc.NodeInfoResponse) Option

func WithOwnerUnit

func WithOwnerUnit(unit *abrpc.Unit[any]) Option

func WithRoundNumber

func WithRoundNumber(roundNumber uint64) Option

func WithTxProof

func WithTxProof(txHash []byte, txProof *abrpc.TransactionRecordAndProof) Option

func WithUnit

func WithUnit(unit *abrpc.Unit[any]) Option

func WithUnits

func WithUnits(units ...*abrpc.Unit[any]) Option

type Options

type Options struct {
	Err          error
	RoundNumber  uint64
	TxProofs     map[string]*abrpc.TransactionRecordAndProof
	Units        map[string]*abrpc.Unit[any]
	OwnerUnits   map[string][]types.UnitID
	InfoResponse *abrpc.NodeInfoResponse
}

type StateServiceMock

type StateServiceMock struct {
	RoundNumber  uint64
	Units        map[string]*abrpc.Unit[any]
	OwnerUnitIDs map[string][]types.UnitID
	TxProofs     map[string]*abrpc.TransactionRecordAndProof
	Block        types.Bytes
	SentTxs      map[string]*types.TransactionOrder
	Err          error
}

func NewStateServiceMock

func NewStateServiceMock(opts ...Option) *StateServiceMock

func (*StateServiceMock) GetBlock

func (s *StateServiceMock) GetBlock(ctx context.Context, roundNumber types.Uint64) (types.Bytes, error)

func (*StateServiceMock) GetRoundNumber

func (s *StateServiceMock) GetRoundNumber(ctx context.Context) (types.Uint64, error)

func (*StateServiceMock) GetTransactionProof

func (s *StateServiceMock) GetTransactionProof(ctx context.Context, txHash types.Bytes) (*abrpc.TransactionRecordAndProof, error)

func (*StateServiceMock) GetUnit

func (s *StateServiceMock) GetUnit(unitID types.UnitID, includeStateProof bool) (*abrpc.Unit[any], error)

func (*StateServiceMock) GetUnitsByOwnerID

func (s *StateServiceMock) GetUnitsByOwnerID(ownerID types.Bytes) ([]types.UnitID, error)

func (*StateServiceMock) Reset

func (s *StateServiceMock) Reset()

func (*StateServiceMock) SendTransaction

func (s *StateServiceMock) SendTransaction(ctx context.Context, tx types.Bytes) (types.Bytes, error)

Jump to

Keyboard shortcuts

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