fake

package
v0.4.7-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: BSD-3-Clause Imports: 41 Imported by: 0

Documentation

Overview

Package fake provides fake implementations for interfaces commonly used in the repository. The implementations offer configuration to return errors when it is needed by the unit test and it is also possible to record the call of functions of an object in some cases.

Index

Constants

View Source
const (
	// GoodFormat should register working format engines.
	GoodFormat = serde.Format("FakeGood")

	// BadFormat should register non-working format engines.
	BadFormat = serde.Format("FakeBad")

	// MsgFormat should register an engine for fake.Message.
	MsgFormat = serde.Format("FakeMsg")
)
View Source
const SignatureByte = 0xfe

SignatureByte is the byte returned when marshaling a fake signature.

Variables

View Source
var BasicConfiguration = types.Configuration{
	MainTitle: "formTitle",
	Scaffold: []types.Subject{
		{
			ID:       "aa",
			Title:    "subject1",
			Order:    nil,
			Subjects: nil,
			Selects: []types.Select{
				{
					ID:      "bb",
					Title:   "Select your favorite snacks",
					MaxN:    3,
					MinN:    0,
					Choices: []string{"snickers", "mars", "vodka", "babibel"},
				},
			},
			Ranks: []types.Rank{},
			Texts: nil,
		},
		{
			ID:       "dd",
			Title:    "subject2",
			Order:    nil,
			Subjects: nil,
			Selects:  nil,
			Ranks:    nil,
			Texts: []types.Text{
				{
					ID:        "ee",
					Title:     "dissertation",
					MaxN:      1,
					MinN:      1,
					MaxLength: 3,
					Regex:     "",
					Choices:   []string{"write yes in your language"},
				},
			},
		},
	},
}

BasicConfiguration returns a basic form configuration

Functions

func CheckLog

func CheckLog(msg string) (zerolog.Logger, func(t *testing.T))

CheckLog returns a logger and a check function. When called, the function will verify if the logger has seen the message printed.

func Err

func Err(msg string) string

Err returns the expected format of an error returned by a fake component.

func GetError

func GetError() error

GetError returns the fake error.

func GetFakeFormatValue

func GetFakeFormatValue() []byte

GetFakeFormatValue returns the value of the fake format serialization.

func GetTracerForAddrWithError

func GetTracerForAddrWithError(addr string) (opentracing.Tracer, error)

GetTracerForAddr is used to mock `tracing.GetTracerForAddr` with an error.

func MakeCertificate

func MakeCertificate(t *testing.T, n int, ips ...net.IP) *tls.Certificate

MakeCertificate generates a valid certificate for the localhost address and for an hour.

func NewBadContext

func NewBadContext() serde.Context

NewBadContext returns a new serde context that produces errors.

func NewBadContextWithDelay

func NewBadContextWithDelay(delay int) serde.Context

NewBadContextWithDelay returns a new serde context that produces errors after some calls.

func NewContext

func NewContext() serde.Context

NewContext returns a new serde context.

func NewContextWithFormat

func NewContextWithFormat(f serde.Format) serde.Context

NewContextWithFormat returns a new serde context that is using the provided format.

func NewForm

func NewForm(formID string) types.Form

func NewKCPointsMarshalled

func NewKCPointsMarshalled(k int) ([]kyber.Point, []kyber.Point, kyber.Point)

func NewMsgContext

func NewMsgContext() serde.Context

NewMsgContext returns a new serde context that always produces a fake message.

func NewScalar

func NewScalar() kyber.Scalar

func NewSigner

func NewSigner() crypto.Signer

NewSigner returns a new instance of the fake signer.

func WaitLog

func WaitLog(msg string, t time.Duration) (zerolog.Logger, func(t *testing.T))

WaitLog is a helper to wait for a log to be printed. It executes the callback when it detects it.

Types

type Address

type Address struct {
	mino.Address
	// contains filtered or unexported fields
}

Address is a fake implementation of an address.

- implements mino.Address

func NewAddress

func NewAddress(index int) Address

NewAddress returns a fake address with the given index.

func NewBadAddress

func NewBadAddress() Address

NewBadAddress returns a fake address that returns an error when appropriate.

func (Address) Equal

func (a Address) Equal(o mino.Address) bool

Equal implements mino.Address.

func (Address) MarshalText

func (a Address) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Address) String

func (a Address) String() string

String implements fmt.Stringer.

type AddressFactory

type AddressFactory struct {
	mino.AddressFactory
}

AddressFactory is a fake implementation of an address factory.

- implements mino.AddressFactory

func (AddressFactory) FromText

func (f AddressFactory) FromText(text []byte) mino.Address

FromText implements mino.AddressFactory.

type AddressIterator

type AddressIterator struct {
	mino.AddressIterator
	// contains filtered or unexported fields
}

AddressIterator is a fake implementation an address iterator.

- implements mino.AddressIterator

func NewAddressIterator

func NewAddressIterator(addrs []mino.Address) *AddressIterator

NewAddressIterator returns a new address iterator

func (*AddressIterator) GetNext

func (i *AddressIterator) GetNext() mino.Address

GetNext implements mino.AddressIterator.

func (*AddressIterator) HasNext

func (i *AddressIterator) HasNext() bool

HasNext implements mino.AddressIterator.

func (*AddressIterator) Seek

func (i *AddressIterator) Seek(index int)

Seek implements mino.AddressIterator.

type Authority

type Authority struct {
	CollectiveAuthority
}

Authority is a fake implementation of ordering.cosipbft.authority.Authority.

- implements ordering.cosipbft.Authority

func (Authority) Apply

Apply implements ordering.cosipbft.Authority Apply must apply the change set to the collective authority. It should first remove, then add the new players.

func (Authority) Diff

Diff implements ordering.cosipbft.Authority Diff should return the change set to apply to get the given authority.

func (Authority) Fingerprint

func (f Authority) Fingerprint(writer io.Writer) error

Fingerprint implements serde.Fingerprinter

func (Authority) Len

func (f Authority) Len() int

func (Authority) Serialize

func (f Authority) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message

type BadPedersen

type BadPedersen struct {
	Err error
}

- implements dkg.DKG

func (BadPedersen) GetActor

func (f BadPedersen) GetActor(formID []byte) (dkg.Actor, bool)

func (BadPedersen) Listen

func (f BadPedersen) Listen(formID []byte, txmngr txn.Manager) (dkg.Actor, error)

type Bucket

type Bucket struct {
	kv.Bucket
	// contains filtered or unexported fields
}

Bucket is a fake key/value storage bucket.

- implements kv.Bucket

func NewBadDeleteBucket

func NewBadDeleteBucket() *Bucket

NewBadDeleteBucket returns a new empty bucket that fails to delete.

func NewBadWriteBucket

func NewBadWriteBucket() *Bucket

NewBadWriteBucket returns a new empty bucket that fails to write.

func NewBucket

func NewBucket() *Bucket

NewBucket returns a new empty bucket.

func (*Bucket) Delete

func (b *Bucket) Delete(key []byte) error

Delete implements kv.Bucket.

func (*Bucket) ForEach

func (b *Bucket) ForEach(fn func(key, value []byte) error) error

ForEach implements kv.Bucket.

func (*Bucket) Get

func (b *Bucket) Get(key []byte) []byte

Get implements kv.Bucket.

func (*Bucket) Set

func (b *Bucket) Set(key, value []byte) error

Set implements kv.Bucket.

type Call

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

Call is a tool to keep track of a function calls.

func NewCall

func NewCall() *Call

NewCall returns a new empty call monitor.

func (*Call) Add

func (c *Call) Add(args ...interface{})

Add adds a call to the list.

func (*Call) Clear

func (c *Call) Clear()

Clear clears the array of calls.

func (*Call) Get

func (c *Call) Get(n, i int) interface{}

Get returns the nth call ith parameter.

func (*Call) Len

func (c *Call) Len() int

Len returns the number of calls.

type ChangeSet

type ChangeSet struct {
}

ChangeSet is a fake implementation of ordering.cosipbft.authority.ChangeSet.

- implements ordering.cosipbft.ChangeSet

func (ChangeSet) GetNewAddresses

func (f ChangeSet) GetNewAddresses() []mino.Address

GetNewAddresses returns the list of addresses for the new members.

func (ChangeSet) NumChanges

func (f ChangeSet) NumChanges() int

NumChanges returns the number of changes that will be applied with this change set.

func (ChangeSet) Serialize

func (f ChangeSet) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message

type ChangeSetFactory

type ChangeSetFactory struct {
}

ChangeSet is a fake implementation of ordering.cosipbft.authority.ChangeSetFactory.

- implements ordering.cosipbft.ChangeSetFactory

func (ChangeSetFactory) ChangeSetOf

func (ChangeSetFactory) Deserialize

func (f ChangeSetFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory

type CollectiveAuthority

type CollectiveAuthority struct {
	crypto.CollectiveAuthority

	Call           *Call
	PubkeyNotFound bool
	// contains filtered or unexported fields
}

CollectiveAuthority is a fake implementation of a collective authority.

- implements crypto.CollectiveAuthority

func NewAuthority

func NewAuthority(n int, g GenSigner) CollectiveAuthority

NewAuthority returns a new collective authority of n members with new signers generated by g.

func NewAuthorityFromMino

func NewAuthorityFromMino(g GenSigner, instances ...mino.Mino) CollectiveAuthority

NewAuthorityFromMino returns a new fake collective authority using the addresses of the Mino instances.

func NewAuthorityWithBase

func NewAuthorityWithBase(base int, n int, g GenSigner) CollectiveAuthority

NewAuthorityWithBase returns a new fake collective authority of size n with a given starting base index.

func (CollectiveAuthority) AddressIterator

func (ca CollectiveAuthority) AddressIterator() mino.AddressIterator

AddressIterator implements mino.Players.

func (CollectiveAuthority) GetAddress

func (ca CollectiveAuthority) GetAddress(index int) mino.Address

GetAddress returns the address at the provided index.

func (CollectiveAuthority) GetPublicKey

func (ca CollectiveAuthority) GetPublicKey(addr mino.Address) (crypto.PublicKey, int)

GetPublicKey implements crypto.CollectiveAuthority.

func (CollectiveAuthority) GetSigner

func (ca CollectiveAuthority) GetSigner(index int) crypto.Signer

GetSigner returns the signer at the provided index.

func (CollectiveAuthority) Len

func (ca CollectiveAuthority) Len() int

Len implements mino.Players.

func (CollectiveAuthority) PublicKeyIterator

func (ca CollectiveAuthority) PublicKeyIterator() crypto.PublicKeyIterator

PublicKeyIterator implements crypto.CollectiveAuthority.

func (CollectiveAuthority) Take

func (ca CollectiveAuthority) Take(updaters ...mino.FilterUpdater) mino.Players

Take implements mino.Players.

type ContextEngine

type ContextEngine struct {
	Count *Counter
	// contains filtered or unexported fields
}

ContextEngine is a fake implementation of a serde context engine that is using JSON as the underlying marshaler.

- implements serde.ContextEngine

func (ContextEngine) GetFormat

func (ctx ContextEngine) GetFormat() serde.Format

GetFormat implements serde.ContextEngine.

func (ContextEngine) Marshal

func (ctx ContextEngine) Marshal(m interface{}) ([]byte, error)

Marshal implements serde.ContextEngine.

func (ContextEngine) Unmarshal

func (ctx ContextEngine) Unmarshal(data []byte, m interface{}) error

Unmarshal implements serde.ContextEngine.

type Counter

type Counter struct {
	Value int
}

Counter is a helper to delay errors or actions. It can be nil without panics.

func NewCounter

func NewCounter(value int) *Counter

NewCounter returns a new counter set to the given value.

func (*Counter) Decrease

func (c *Counter) Decrease()

Decrease decrements the counter.

func (*Counter) Done

func (c *Counter) Done() bool

Done returns true when the counter reached zero.

type DKGActor

type DKGActor struct {
	Err    error
	PubKey kyber.Point
}

- implements dkg.Actor

func (DKGActor) ComputePubshares

func (f DKGActor) ComputePubshares() error

func (DKGActor) Decrypt

func (f DKGActor) Decrypt(K, C kyber.Point) ([]byte, error)

func (DKGActor) Encrypt

func (f DKGActor) Encrypt(message []byte) (K, C kyber.Point, remainder []byte, err error)

func (DKGActor) GetPublicKey

func (f DKGActor) GetPublicKey() (kyber.Point, error)

func (DKGActor) MarshalJSON

func (f DKGActor) MarshalJSON() ([]byte, error)

func (DKGActor) Reshare

func (f DKGActor) Reshare() error

func (DKGActor) Setup

func (f DKGActor) Setup() (pubKey kyber.Point, err error)

func (DKGActor) Status

func (f DKGActor) Status() dkg.Status

type Factory

type Factory struct {
}

Factory is a fake implementation of ordering.cosipbft.authority.Factory.

- implements ordering.cosipbft.Factory

func (Factory) AuthorityOf

func (f Factory) AuthorityOf(serde.Context, []byte) (authority.Authority, error)

AuthorityOf implements ordering.cosipbft.Factory

func (Factory) Deserialize

func (f Factory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory

type Format

type Format struct {
	Msg  serde.Message
	Call *Call
	// contains filtered or unexported fields
}

Format is a fake format engine implementation.

- implements serde.FormatEngine

func NewBadFormat

func NewBadFormat() Format

NewBadFormat returns a new format engine that always return an error.

func (Format) Decode

func (f Format) Decode(ctx serde.Context, data []byte) (serde.Message, error)

Decode implements serde.FormatEngine.

func (Format) Encode

func (f Format) Encode(ctx serde.Context, m serde.Message) ([]byte, error)

Encode implements serde.FormatEngine.

type GenSigner

type GenSigner func() crypto.Signer

GenSigner is a function to generate a signer.

type Hash

type Hash struct {
	hash.Hash

	Call *Call
	// contains filtered or unexported fields
}

Hash is a fake implementation of hash.Hash.

- implements hash.Hash

func NewBadHash

func NewBadHash() *Hash

NewBadHash returns a fake hash that returns an error when appropriate.

func NewBadHashWithDelay

func NewBadHashWithDelay(delay int) *Hash

NewBadHashWithDelay returns a fake hash that returns an error after a certain amount of calls.

func (*Hash) MarshalBinary

func (h *Hash) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*Hash) Size

func (h *Hash) Size() int

Size implements hash.Hash.

func (*Hash) Sum

func (h *Hash) Sum([]byte) []byte

Sum implements hash.Hash.

func (*Hash) UnmarshalBinary

func (h *Hash) UnmarshalBinary([]byte) error

UnmarshalBinary implements encodi8ng.BinaryUnmarshaler.

func (*Hash) Write

func (h *Hash) Write(in []byte) (int, error)

Write implements hash.Hash.

type HashFactory

type HashFactory struct {
	// contains filtered or unexported fields
}

HashFactory is a fake implementation of a hash factory.

- implements crypto.HashFactory

func NewHashFactory

func NewHashFactory(h *Hash) HashFactory

NewHashFactory returns a fake hash factory.

func (HashFactory) New

func (f HashFactory) New() hash.Hash

New implements crypto.HashFactory.

type InMemoryDB

type InMemoryDB struct {
	// contains filtered or unexported fields
}

InMemoryDB is a fake implementation of a key/value storage.

- implements kv.DB

func NewBadDB

func NewBadDB() *InMemoryDB

NewBadDB returns a new database that will return an error inside the transactions, and when closing the database.

func NewBadViewDB

func NewBadViewDB() *InMemoryDB

NewBadViewDB returns a new database that fails to open view transactions.

func NewInMemoryDB

func NewInMemoryDB() *InMemoryDB

NewInMemoryDB returns a new empty database.

func (*InMemoryDB) Close

func (db *InMemoryDB) Close() error

Close implements kv.DB.

func (*InMemoryDB) SetBucket

func (db *InMemoryDB) SetBucket(name []byte, b *Bucket)

SetBucket allows to define a bucket in the database.

func (*InMemoryDB) Update

func (db *InMemoryDB) Update(fn func(tx kv.WritableTx) error) error

Update implements kv.DB.

func (*InMemoryDB) View

func (db *InMemoryDB) View(fn func(tx kv.ReadableTx) error) error

View implements kv.DB.

type InMemorySnapshot

type InMemorySnapshot struct {
	store.Snapshot

	ErrRead   error
	ErrWrite  error
	ErrDelete error
	// contains filtered or unexported fields
}

InMemorySnapshot is a fake implementation of a store snapshot.

- implements store.Snapshot

func NewBadSnapshot

func NewBadSnapshot() *InMemorySnapshot

NewBadSnapshot creates a new empty snapshot that will always return an error.

func NewSnapshot

func NewSnapshot() *InMemorySnapshot

NewSnapshot creates a new empty snapshot.

func (*InMemorySnapshot) Delete

func (snap *InMemorySnapshot) Delete(key []byte) error

Delete implements store.Snapshot.

func (*InMemorySnapshot) Get

func (snap *InMemorySnapshot) Get(key []byte) ([]byte, error)

Get implements store.Snapshot.

func (*InMemorySnapshot) Set

func (snap *InMemorySnapshot) Set(key, value []byte) error

Set implements store.Snapshot.

type Manager

type Manager struct {
	txn.Manager
}

Manager is a fake manager

- implements txn.Manager

func (Manager) Make

func (m Manager) Make(args ...txn.Arg) (txn.Transaction, error)

func (Manager) Sync

func (m Manager) Sync() error

type Message

type Message struct {
	Digest []byte
}

Message is a fake implementation if a serde message.

- implements serde.Message

func (Message) Fingerprint

func (m Message) Fingerprint(w io.Writer) error

Fingerprint implements serde.Fingerprinter.

func (Message) Serialize

func (m Message) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message.

type MessageFactory

type MessageFactory struct {
	// contains filtered or unexported fields
}

MessageFactory is a fake implementation of a serde factory.

- implements serde.Factory

func NewBadMessageFactory

func NewBadMessageFactory() MessageFactory

NewBadMessageFactory returns a new message factory that returns an error.

func (MessageFactory) Deserialize

func (f MessageFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory.

type MessageFormat

type MessageFormat struct{}

MessageFormat is a format engine to encode and decode fake messages.

- implements serde.FormatEngine

func NewMsgFormat

func NewMsgFormat() MessageFormat

NewMsgFormat creates a new format.

func (MessageFormat) Decode

func (f MessageFormat) Decode(serde.Context, []byte) (serde.Message, error)

Decode implements serde.FormatEngine.

func (MessageFormat) Encode

func (f MessageFormat) Encode(ctx serde.Context, m serde.Message) ([]byte, error)

Encode implements serde.FormatEngine.

type Mino

type Mino struct {
	mino.Mino
	// contains filtered or unexported fields
}

Mino is a fake implementation of mino.

- implements mino.Mino

func NewBadMino

func NewBadMino() Mino

NewBadMino returns a Mino instance that returns an error when appropriate.

func (Mino) CreateRPC

func (m Mino) CreateRPC(string, mino.Handler, serde.Factory) (mino.RPC, error)

CreateRPC implements mino.Mino.

func (Mino) GetAddress

func (m Mino) GetAddress() mino.Address

GetAddress implements mino.Mino.

func (Mino) GetAddressFactory

func (m Mino) GetAddressFactory() mino.AddressFactory

GetAddressFactory implements mino.Mino.

func (Mino) WithSegment

func (m Mino) WithSegment(segment string) mino.Mino

WithSegment implements mino.Mino.

type Pedersen

type Pedersen struct {
	Actors map[string]dkg.Actor
}

- implements dkg.DKG

func (Pedersen) GetActor

func (f Pedersen) GetActor(formID []byte) (dkg.Actor, bool)

func (Pedersen) Listen

func (f Pedersen) Listen(formID []byte, txmngr txn.Manager) (dkg.Actor, error)

type Pool

type Pool struct {
	Err         error
	Transaction Transaction
	Service     *Service
}

Pool is a fake implementation of Pool.

- implements txn.pool.Pool

func (*Pool) Add

func (f *Pool) Add(transaction txn.Transaction) error

func (Pool) AddFilter

func (f Pool) AddFilter(filter pool.Filter)

func (Pool) Close

func (f Pool) Close() error

func (Pool) Gather

func (f Pool) Gather(ctx context.Context, config pool.Config) []txn.Transaction

func (Pool) Len

func (f Pool) Len() int

func (Pool) Remove

func (f Pool) Remove(transaction txn.Transaction) error

func (Pool) SetPlayers

func (f Pool) SetPlayers(players mino.Players) error

type Proof

type Proof struct {
	// contains filtered or unexported fields
}

Proof

- implements ordering.Proof

func (Proof) GetKey

func (f Proof) GetKey() []byte

GetKey implements ordering.Proof. It returns the key associated to the proof.

func (Proof) GetValue

func (f Proof) GetValue() []byte

GetValue implements ordering.Proof. It returns the value associated to the proof if the key exists, otherwise it returns nil.

type PublicKey

type PublicKey struct {
	crypto.PublicKey
	// contains filtered or unexported fields
}

PublicKey is a fake implementation of crypto.PublicKey.

- implements crypto.PublicKey

func NewBadPublicKey

func NewBadPublicKey() PublicKey

NewBadPublicKey returns a new fake public key that returns error when appropriate.

func NewInvalidPublicKey

func NewInvalidPublicKey() PublicKey

NewInvalidPublicKey returns a fake public key that never verifies.

func (PublicKey) Equal

func (pk PublicKey) Equal(other interface{}) bool

Equal implements crypto.PublicKey.

func (PublicKey) MarshalBinary

func (pk PublicKey) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (PublicKey) MarshalText

func (pk PublicKey) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (PublicKey) Serialize

func (pk PublicKey) Serialize(serde.Context) ([]byte, error)

Serialize implements serde.Message.

func (PublicKey) String

func (pk PublicKey) String() string

String implements fmt.Stringer.

func (PublicKey) Verify

func (pk PublicKey) Verify([]byte, crypto.Signature) error

Verify implements crypto.PublicKey.

type PublicKeyFactory

type PublicKeyFactory struct {
	// contains filtered or unexported fields
}

PublicKeyFactory is a fake implementation of a public key factory.

- implements crypto.PublicKeyFactory.

func NewBadPublicKeyFactory

func NewBadPublicKeyFactory() PublicKeyFactory

NewBadPublicKeyFactory returns a fake public key factory that returns an error when appropriate.

func NewPublicKeyFactory

func NewPublicKeyFactory(pubkey PublicKey) PublicKeyFactory

NewPublicKeyFactory returns a fake public key factory that returns the given public key.

func (PublicKeyFactory) Deserialize

func (f PublicKeyFactory) Deserialize(serde.Context, []byte) (serde.Message, error)

Deserialize implements serde.Factory.

func (PublicKeyFactory) FromBytes

func (f PublicKeyFactory) FromBytes([]byte) (crypto.PublicKey, error)

FromBytes implements crypto.PublicKeyFactory.

func (PublicKeyFactory) PublicKeyOf

func (f PublicKeyFactory) PublicKeyOf(serde.Context, []byte) (crypto.PublicKey, error)

PublicKeyOf implements crypto.PublicKeyFactory.

type PublicKeyIterator

type PublicKeyIterator struct {
	// contains filtered or unexported fields
}

PublicKeyIterator is a fake implementation of a public key iterator.

- implements crypto.PublicKeyIterator

func NewPublicKeyIterator

func NewPublicKeyIterator(signers []crypto.Signer) *PublicKeyIterator

NewPublicKeyIterator returns a new address iterator

func (*PublicKeyIterator) GetNext

func (i *PublicKeyIterator) GetNext() crypto.PublicKey

GetNext implements crypto.PublicKeyIterator.

func (*PublicKeyIterator) HasNext

func (i *PublicKeyIterator) HasNext() bool

HasNext implements crypto.PublicKeyIterator.

func (*PublicKeyIterator) Seek

func (i *PublicKeyIterator) Seek(index int)

Seek implements crypto.PublicKeyIterator.

type RPC

type RPC struct {
	mino.RPC
	Calls *Call
	// contains filtered or unexported fields
}

RPC is a fake implementation of an RPC.

- implements mino.RPC

func NewBadRPC

func NewBadRPC() *RPC

NewBadRPC returns a fake rpc that returns an error when appropriate.

func NewRPC

func NewRPC() *RPC

NewRPC returns a fake rpc.

func NewStreamRPC

func NewStreamRPC(r *Receiver, s Sender) *RPC

NewStreamRPC returns a fake rpc with specific stream options.

func (*RPC) Call

func (rpc *RPC) Call(ctx context.Context,
	m serde.Message, p mino.Players) (<-chan mino.Response, error)

Call implements mino.RPC.

func (*RPC) Done

func (rpc *RPC) Done()

Done closes the response channel.

func (*RPC) Reset

func (rpc *RPC) Reset()

Reset resets the channels.

func (*RPC) SendResponse

func (rpc *RPC) SendResponse(from mino.Address, msg serde.Message)

SendResponse fills the rpc with a message.

func (*RPC) SendResponseWithError

func (rpc *RPC) SendResponseWithError(from mino.Address, err error)

SendResponseWithError fills the rpc with an error.

func (*RPC) Stream

func (rpc *RPC) Stream(ctx context.Context, p mino.Players) (mino.Sender, mino.Receiver, error)

Stream implements mino.RPC.

type Receiver

type Receiver struct {
	mino.Receiver

	Msgs []ReceiverMessage
	// contains filtered or unexported fields
}

Receiver is a fake RPC stream receiver. It will return the consecutive messages stored in the Msg slice.

- implements mino.Receiver

func NewBadReceiver

func NewBadReceiver(msg ...ReceiverMessage) *Receiver

NewBadReceiver returns a new receiver that returns an error.

func NewBlockingReceiver

func NewBlockingReceiver() *Receiver

NewBlockingReceiver returns a new fake receiver that is blocking until the context is done.

func NewReceiver

func NewReceiver(msgs ...ReceiverMessage) *Receiver

NewReceiver returns a new receiver

func (*Receiver) Recv

Recv implements mino.Receiver.

type ReceiverMessage

type ReceiverMessage struct {
	Address mino.Address
	Message serde.Message
}

ReceiverMessage is the combination of an address and a message that is returned by the receiver.

func NewRecvMsg

func NewRecvMsg(addr mino.Address, msg serde.Message) ReceiverMessage

NewRecvMsg creates a new receiver message.

type RosterFac

type RosterFac struct {
	authority.Factory
	// contains filtered or unexported fields
}

This fake RosterFac always returns roster upon Deserialize

func NewRosterFac

func NewRosterFac(roster authority.Roster) RosterFac

func (RosterFac) AuthorityOf

func (f RosterFac) AuthorityOf(serde.Context, []byte) (authority.Authority, error)

type Sender

type Sender struct {
	mino.Sender
	// contains filtered or unexported fields
}

Sender is a fake RPC stream sender.

- implements mino.Sender

func NewBadSender

func NewBadSender() Sender

NewBadSender returns a sender that always returns an error.

func (Sender) Send

func (s Sender) Send(serde.Message, ...mino.Address) <-chan error

Send implements mino.Sender.

type Service

type Service struct {
	Err     error
	Forms   map[string]formTypes.Form
	Pool    *Pool
	Status  bool
	Channel chan ordering.Event
	Context serde.Context
}

Service

- implements ordering.Service

func NewService

func NewService(formID string, form formTypes.Form, ctx serde.Context) Service

NewService returns a new initialized service

func (*Service) AddTx

func (f *Service) AddTx(tx Transaction)

func (Service) Close

func (f Service) Close() error

func (Service) GetProof

func (f Service) GetProof(key []byte) (ordering.Proof, error)

GetProof implements ordering.Service. It returns the proof associated to the form.

func (Service) GetStore

func (f Service) GetStore() store.Readable

GetStore implements ordering.Service. It returns the store associated to the service.

func (*Service) Watch

func (f *Service) Watch(ctx context.Context) <-chan ordering.Event

Watch implements ordering.Service. It returns the events that occurred within the service.

type Signature

type Signature struct {
	crypto.Signature
	// contains filtered or unexported fields
}

Signature is a fake implementation of the signature.

- implements crypto.Signature

func NewBadSignature

func NewBadSignature() Signature

NewBadSignature returns a signature that will return error when appropriate.

func (Signature) Equal

func (s Signature) Equal(o crypto.Signature) bool

Equal implements crypto.Signature.

func (Signature) MarshalBinary

func (s Signature) MarshalBinary() ([]byte, error)

MarshalBinary implements crypto.Signature.

func (Signature) Serialize

func (s Signature) Serialize(serde.Context) ([]byte, error)

Serialize implements serde.Message.

func (Signature) String

func (s Signature) String() string

String implements fmt.Stringer.

type SignatureFactory

type SignatureFactory struct {
	Counter *Counter
	// contains filtered or unexported fields
}

SignatureFactory is a fake implementation of the signature factory.

- implements crypto.SignatureFactory

func NewBadSignatureFactory

func NewBadSignatureFactory() SignatureFactory

NewBadSignatureFactory returns a signature factory that will return an error when appropriate.

func NewBadSignatureFactoryWithDelay

func NewBadSignatureFactoryWithDelay(value int) SignatureFactory

NewBadSignatureFactoryWithDelay returns a signature factory that will return an error after some calls.

func NewSignatureFactory

func NewSignatureFactory(s Signature) SignatureFactory

NewSignatureFactory returns a fake signature factory.

func (SignatureFactory) Deserialize

func (f SignatureFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory.

func (SignatureFactory) SignatureOf

func (f SignatureFactory) SignatureOf(serde.Context, []byte) (crypto.Signature, error)

SignatureOf implements crypto.SignatureFactory.

type Signer

type Signer struct {
	crypto.AggregateSigner
	// contains filtered or unexported fields
}

Signer is a fake implementation of the crypto.AggregateSigner interface.

- implements crypto.Signer

func NewAggregateSigner

func NewAggregateSigner() Signer

NewAggregateSigner returns a new signer that implements aggregation.

func NewBadSigner

func NewBadSigner() Signer

NewBadSigner returns a fake signer that will return an error when appropriate.

func NewSignerWithPublicKey

func NewSignerWithPublicKey(k PublicKey) Signer

NewSignerWithPublicKey returns a new fake signer with the specific public key.

func NewSignerWithSignatureFactory

func NewSignerWithSignatureFactory(f SignatureFactory) Signer

NewSignerWithSignatureFactory returns a fake signer with the provided factory.

func NewSignerWithVerifierFactory

func NewSignerWithVerifierFactory(f VerifierFactory) Signer

NewSignerWithVerifierFactory returns a new fake signer with the specific verifier factory.

func (Signer) Aggregate

func (s Signer) Aggregate(...crypto.Signature) (crypto.Signature, error)

Aggregate implements crypto.AggregateSigner.

func (Signer) GetPublicKey

func (s Signer) GetPublicKey() crypto.PublicKey

GetPublicKey implements crypto.Signer.

func (Signer) GetPublicKeyFactory

func (s Signer) GetPublicKeyFactory() crypto.PublicKeyFactory

GetPublicKeyFactory implements crypto.Signer.

func (Signer) GetSignatureFactory

func (s Signer) GetSignatureFactory() crypto.SignatureFactory

GetSignatureFactory implements crypto.Signer.

func (Signer) GetVerifierFactory

func (s Signer) GetVerifierFactory() crypto.VerifierFactory

GetVerifierFactory implements crypto.Signer.

func (Signer) Sign

func (s Signer) Sign([]byte) (crypto.Signature, error)

Sign implements crypto.Signer.

type Transaction

type Transaction struct {
	Nonce uint64
	Id    []byte
}

Transaction is a fake implementation of Transaction.

- implements txn.Transaction

func (Transaction) Fingerprint

func (f Transaction) Fingerprint(writer io.Writer) error

func (Transaction) GetArg

func (f Transaction) GetArg(key string) []byte

func (Transaction) GetID

func (f Transaction) GetID() []byte

func (Transaction) GetIdentity

func (f Transaction) GetIdentity() access.Identity

func (Transaction) GetNonce

func (f Transaction) GetNonce() uint64

func (Transaction) Serialize

func (f Transaction) Serialize(ctx serde.Context) ([]byte, error)

type TransactionResult

type TransactionResult struct {
	// contains filtered or unexported fields
}

TransactionResult is a fake implementation of TransactionResult.

- implements validation.TransactionResult

func (TransactionResult) GetStatus

func (f TransactionResult) GetStatus() (bool, string)

GetStatus implements TransactionResult. It returns the status of the execution.

func (TransactionResult) GetTransaction

func (f TransactionResult) GetTransaction() txn.Transaction

GetTransaction implements TransactionResult. It returns the transaction associated to the result.

func (TransactionResult) Serialize

func (f TransactionResult) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements TransactionResult.

type ValidationService

type ValidationService struct {
	Execution execution.Service
	Fac       validation.ResultFactory
}

ValidationService is a fake implementation of Service

- implements validation.Service

func (ValidationService) Accept

Accept returns nil if the transaction will be accepted by the service. The leeway parameter allows to reduce some constraints.

func (ValidationService) GetFactory

GetFactory returns the result factory.

func (ValidationService) GetNonce

GetNonce returns the nonce associated with the identity. The value returned should be used for the next transaction to be valid.

func (ValidationService) Validate

Validate takes a snapshot and a list of transactions and returns a result.

type Verifier

type Verifier struct {
	crypto.Verifier
	// contains filtered or unexported fields
}

Verifier is a fake implementation of crypto.Verifier.

- implements crypto.Verifier

func NewBadVerifier

func NewBadVerifier() Verifier

NewBadVerifier returns a verifier that will return an error when appropriate.

func NewBadVerifierWithDelay

func NewBadVerifierWithDelay(value int) Verifier

NewBadVerifierWithDelay returns a verifier that will return an error after a given delay.

func (Verifier) Verify

func (v Verifier) Verify(msg []byte, s crypto.Signature) error

Verify implements crypto.Verifier.

type VerifierFactory

type VerifierFactory struct {
	crypto.VerifierFactory
	// contains filtered or unexported fields
}

VerifierFactory is a fake implementation of crypto.VerifierFactory.

- implements crypto.VerifierFactory

func NewBadVerifierFactory

func NewBadVerifierFactory() VerifierFactory

NewBadVerifierFactory returns a fake verifier factory that returns an error when appropriate.

func NewVerifierFactory

func NewVerifierFactory(v Verifier) VerifierFactory

NewVerifierFactory returns a new fake verifier factory.

func NewVerifierFactoryWithCalls

func NewVerifierFactoryWithCalls(c *Call) VerifierFactory

NewVerifierFactoryWithCalls returns a new verifier factory that will register the calls.

func (VerifierFactory) FromArray

func (f VerifierFactory) FromArray(pubkeys []crypto.PublicKey) (crypto.Verifier, error)

FromArray implements crypto.VerifierFactory.

func (VerifierFactory) FromAuthority

FromAuthority implements crypto.VerifierFactory.

Jump to

Keyboard shortcuts

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