fake

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 27 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

This section is empty.

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 GetTracerForAddrEmpty

func GetTracerForAddrEmpty(_ string) (opentracing.Tracer, error)

GetTracerForAddrEmpty is used to mock `tracing.GetTracerForAddr` with an empty tracer.

func GetTracerForAddrWithError

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

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

func MakeCertificate

func MakeCertificate(t *testing.T, ips ...net.IP) []byte

MakeCertificate generates a valid certificate for the localhost address and for an hour. It outputs only its byte representation.

func MakeCertificateChain

func MakeCertificateChain(t *testing.T) []byte

MakeCertificateChain creates a valid certificate chain with an intermediary certificate.

func MakeFullCertificate

func MakeFullCertificate(t *testing.T) (*tls.Certificate, []byte)

MakeFullCertificate generates a valid certificate for the localhost address and for an hour. it outputs the TLS certificate and its byte representation.

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 NewMsgContext

func NewMsgContext() serde.Context

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

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) ConnectionType

func (a Address) ConnectionType() mino.AddressConnectionType

ConnectionType always returns ACTgRPCS

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 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 NewBadForeachBucket

func NewBadForeachBucket() *Bucket

NewBadForeachBucket returns a new empty bucket that fails to iterate

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 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 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 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 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 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 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 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