mock

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMockMarshalizer = errors.New("MarshalizerMock generic error")

ErrMockMarshalizer -

Functions

This section is empty.

Types

type AppStatusHandlerMock

type AppStatusHandlerMock struct {
}

AppStatusHandlerMock -

func (*AppStatusHandlerMock) AddUint64

func (a *AppStatusHandlerMock) AddUint64(key string, val uint64)

AddUint64 -

func (*AppStatusHandlerMock) Close

func (a *AppStatusHandlerMock) Close()

Close -

func (*AppStatusHandlerMock) Decrement

func (a *AppStatusHandlerMock) Decrement(key string)

Decrement -

func (*AppStatusHandlerMock) Increment

func (a *AppStatusHandlerMock) Increment(key string)

Increment -

func (*AppStatusHandlerMock) IsInterfaceNil

func (a *AppStatusHandlerMock) IsInterfaceNil() bool

IsInterfaceNil -

func (*AppStatusHandlerMock) SetInt64Value

func (a *AppStatusHandlerMock) SetInt64Value(key string, value int64)

SetInt64Value -

func (*AppStatusHandlerMock) SetStringValue

func (a *AppStatusHandlerMock) SetStringValue(key string, value string)

SetStringValue -

func (*AppStatusHandlerMock) SetUInt64Value

func (a *AppStatusHandlerMock) SetUInt64Value(key string, value uint64)

SetUInt64Value -

type EpochStartNotifierStub

type EpochStartNotifierStub struct {
	RegisterHandlerCalled   func(handler epochStart.ActionHandler)
	UnregisterHandlerCalled func(handler epochStart.ActionHandler)
	NotifyAllPrepareCalled  func(hdr data.HeaderHandler, body data.BodyHandler)
	NotifyAllCalled         func(hdr data.HeaderHandler)
}

EpochStartNotifierStub -

func (*EpochStartNotifierStub) IsInterfaceNil

func (esnm *EpochStartNotifierStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*EpochStartNotifierStub) NotifyAll

func (esnm *EpochStartNotifierStub) NotifyAll(hdr data.HeaderHandler)

NotifyAll -

func (*EpochStartNotifierStub) NotifyAllPrepare

func (esnm *EpochStartNotifierStub) NotifyAllPrepare(metaHdr data.HeaderHandler, body data.BodyHandler)

NotifyAllPrepare -

func (*EpochStartNotifierStub) RegisterHandler

func (esnm *EpochStartNotifierStub) RegisterHandler(handler epochStart.ActionHandler)

RegisterHandler -

func (*EpochStartNotifierStub) UnregisterHandler

func (esnm *EpochStartNotifierStub) UnregisterHandler(handler epochStart.ActionHandler)

UnregisterHandler -

type HasherMock

type HasherMock struct {
}

HasherMock that will be used for testing

func (HasherMock) Compute

func (sha HasherMock) Compute(s string) []byte

Compute will output the SHA's equivalent of the input string

func (HasherMock) EmptyHash

func (sha HasherMock) EmptyHash() []byte

EmptyHash will return the equivalent of empty string SHA's

func (HasherMock) IsInterfaceNil

func (sha HasherMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (HasherMock) Size

func (HasherMock) Size() int

Size return the required size in bytes

type KeyGenMock

type KeyGenMock struct {
	GeneratePairMock            func() (crypto.PrivateKey, crypto.PublicKey)
	PrivateKeyFromByteArrayMock func(b []byte) (crypto.PrivateKey, error)
	PublicKeyFromByteArrayMock  func(b []byte) (crypto.PublicKey, error)
	SuiteMock                   func() crypto.Suite
}

KeyGenMock mocks a key generation implementation

func (*KeyGenMock) CheckPublicKeyValid

func (keyGen *KeyGenMock) CheckPublicKeyValid(_ []byte) error

CheckPublicKeyValid -

func (*KeyGenMock) GeneratePair

func (keyGen *KeyGenMock) GeneratePair() (crypto.PrivateKey, crypto.PublicKey)

GeneratePair generates a pair of private and public keys

func (*KeyGenMock) IsInterfaceNil

func (keyGen *KeyGenMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*KeyGenMock) PrivateKeyFromByteArray

func (keyGen *KeyGenMock) PrivateKeyFromByteArray(b []byte) (crypto.PrivateKey, error)

PrivateKeyFromByteArray generates the private key from it's byte array representation

func (*KeyGenMock) PublicKeyFromByteArray

func (keyGen *KeyGenMock) PublicKeyFromByteArray(_ []byte) (crypto.PublicKey, error)

PublicKeyFromByteArray generates a public key from it's byte array representation

func (*KeyGenMock) Suite

func (keyGen *KeyGenMock) Suite() crypto.Suite

Suite -

type MarshalizerMock

type MarshalizerMock struct {
	Fail bool
}

MarshalizerMock that will be used for testing

func (MarshalizerMock) IsInterfaceNil

func (mm MarshalizerMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (MarshalizerMock) Marshal

func (mm MarshalizerMock) Marshal(obj interface{}) ([]byte, error)

Marshal converts the input object in a slice of bytes

func (MarshalizerMock) Unmarshal

func (mm MarshalizerMock) Unmarshal(obj interface{}, buff []byte) error

Unmarshal applies the serialized values over an instantiated object

type MultipleShardsCoordinatorMock

type MultipleShardsCoordinatorMock struct {
	NoShards        uint32
	CurrentShard    uint32
	ComputeIdCalled func(address []byte) uint32
	SelfIDCalled    func() uint32
}

MultipleShardsCoordinatorMock -

func NewMultiShardsCoordinatorMock

func NewMultiShardsCoordinatorMock(nrShard uint32) *MultipleShardsCoordinatorMock

NewMultiShardsCoordinatorMock -

func (*MultipleShardsCoordinatorMock) CommunicationIdentifier

func (scm *MultipleShardsCoordinatorMock) CommunicationIdentifier(destShardID uint32) string

CommunicationIdentifier returns the identifier between current shard ID and destination shard ID identifier is generated such as the first shard from identifier is always smaller than the last

func (*MultipleShardsCoordinatorMock) ComputeId

func (scm *MultipleShardsCoordinatorMock) ComputeId(address []byte) uint32

ComputeId -

func (*MultipleShardsCoordinatorMock) IsInterfaceNil

func (scm *MultipleShardsCoordinatorMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MultipleShardsCoordinatorMock) NumberOfShards

func (scm *MultipleShardsCoordinatorMock) NumberOfShards() uint32

NumberOfShards -

func (*MultipleShardsCoordinatorMock) SameShard

func (scm *MultipleShardsCoordinatorMock) SameShard(_, _ []byte) bool

SameShard -

func (*MultipleShardsCoordinatorMock) SelfId

func (scm *MultipleShardsCoordinatorMock) SelfId() uint32

SelfId -

func (*MultipleShardsCoordinatorMock) SetNoShards

func (scm *MultipleShardsCoordinatorMock) SetNoShards(noShards uint32)

SetNoShards -

func (*MultipleShardsCoordinatorMock) SetSelfId

func (scm *MultipleShardsCoordinatorMock) SetSelfId(_ uint32) error

SetSelfId -

type NodesSetupStub

type NodesSetupStub struct {
	InitialNodesPubKeysCalled                 func() map[uint32][]string
	InitialEligibleNodesPubKeysForShardCalled func(shardId uint32) ([]string, error)
}

NodesSetupStub -

func (*NodesSetupStub) InitialEligibleNodesPubKeysForShard

func (n *NodesSetupStub) InitialEligibleNodesPubKeysForShard(shardId uint32) ([]string, error)

InitialEligibleNodesPubKeysForShard -

func (*NodesSetupStub) InitialNodesPubKeys

func (n *NodesSetupStub) InitialNodesPubKeys() map[uint32][]string

InitialNodesPubKeys -

func (*NodesSetupStub) IsInterfaceNil

func (n *NodesSetupStub) IsInterfaceNil() bool

IsInterfaceNil -

type PathManagerStub

type PathManagerStub struct {
	PathForEpochCalled  func(shardId string, epoch uint32, identifier string) string
	PathForStaticCalled func(shardId string, identifier string) string
}

PathManagerStub -

func (*PathManagerStub) IsInterfaceNil

func (p *PathManagerStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*PathManagerStub) PathForEpoch

func (p *PathManagerStub) PathForEpoch(shardId string, epoch uint32, identifier string) string

PathForEpoch -

func (*PathManagerStub) PathForStatic

func (p *PathManagerStub) PathForStatic(shardId string, identifier string) string

PathForStatic -

type PointMock

type PointMock struct {
	X int
	Y int

	GetUnderlyingObjStub func() interface{}
	MarshalBinaryStub    func(x, y int) ([]byte, error)
	UnmarshalBinaryStub  func([]byte) (x, y int, err error)
}

PointMock represents a mock implementation for a Point

func (*PointMock) Add

func (po *PointMock) Add(_ crypto.Point) (crypto.Point, error)

Add returns the result of adding receiver with Point p given as parameter, so that their scalars add homomorphically

func (*PointMock) Base

func (po *PointMock) Base() crypto.Point

Base returns the Group's base point.

func (*PointMock) Clone

func (po *PointMock) Clone() crypto.Point

Clone returns a clone of the receiver.

func (*PointMock) Equal

func (po *PointMock) Equal(p crypto.Point) (bool, error)

Equal tests if receiver is equal with the Point p given as parameter. Both Points need to be derived from the same Group

func (*PointMock) GetUnderlyingObj

func (po *PointMock) GetUnderlyingObj() interface{}

GetUnderlyingObj returns the object the implementation wraps

func (*PointMock) IsInterfaceNil

func (po *PointMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PointMock) MarshalBinary

func (po *PointMock) MarshalBinary() ([]byte, error)

MarshalBinary transforms the Point into a byte array

func (*PointMock) Mul

func (po *PointMock) Mul(s crypto.Scalar) (crypto.Point, error)

Mul returns the result of multiplying receiver by the scalar s. Mock multiplies the scalar to both X and Y fields

func (*PointMock) Neg

func (po *PointMock) Neg() crypto.Point

Neg returns the negation of receiver

func (*PointMock) Null

func (po *PointMock) Null() crypto.Point

Null returns the neutral identity element.

func (*PointMock) Pick

func (po *PointMock) Pick() (crypto.Point, error)

Pick returns a fresh random or pseudo-random Point.

func (*PointMock) Set

func (po *PointMock) Set(_ crypto.Point) error

Set sets the receiver equal to another Point p.

func (*PointMock) Sub

func (po *PointMock) Sub(_ crypto.Point) (crypto.Point, error)

Sub returns the result of subtracting from receiver the Point p given as parameter, so that their scalars subtract homomorphically

func (*PointMock) UnmarshalBinary

func (po *PointMock) UnmarshalBinary(point []byte) error

UnmarshalBinary recreates the Point from a byte array

type PrivateKeyMock

type PrivateKeyMock struct {
	GeneratePublicMock func() crypto.PublicKey
	ToByteArrayMock    func() ([]byte, error)
	SuiteMock          func() crypto.Suite
	ScalarMock         func() crypto.Scalar
}

PrivateKeyMock mocks a private key implementation

func (*PrivateKeyMock) GeneratePublic

func (privKey *PrivateKeyMock) GeneratePublic() crypto.PublicKey

GeneratePublic mocks generating a public key from the private key

func (*PrivateKeyMock) IsInterfaceNil

func (privKey *PrivateKeyMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PrivateKeyMock) Scalar

func (privKey *PrivateKeyMock) Scalar() crypto.Scalar

Scalar -

func (*PrivateKeyMock) Suite

func (privKey *PrivateKeyMock) Suite() crypto.Suite

Suite -

func (*PrivateKeyMock) ToByteArray

func (privKey *PrivateKeyMock) ToByteArray() ([]byte, error)

ToByteArray mocks converting the private key to a byte array

type PubkeyConverterStub

type PubkeyConverterStub struct {
	LenCalled    func() int
	DecodeCalled func(humanReadable string) ([]byte, error)
	EncodeCalled func(pkBytes []byte) string
}

PubkeyConverterStub -

func (*PubkeyConverterStub) Decode

func (pcs *PubkeyConverterStub) Decode(humanReadable string) ([]byte, error)

Decode -

func (*PubkeyConverterStub) Encode

func (pcs *PubkeyConverterStub) Encode(pkBytes []byte) string

Encode -

func (*PubkeyConverterStub) IsInterfaceNil

func (pcs *PubkeyConverterStub) IsInterfaceNil() bool

IsInterfaceNil -

func (*PubkeyConverterStub) Len

func (pcs *PubkeyConverterStub) Len() int

Len -

type PublicKeyMock

type PublicKeyMock struct {
	ToByteArrayMock func() ([]byte, error)
	SuiteMock       func() crypto.Suite
	PointMock       func() crypto.Point
}

PublicKeyMock mocks a public key implementation

func (*PublicKeyMock) IsInterfaceNil

func (pubKey *PublicKeyMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*PublicKeyMock) Point

func (pubKey *PublicKeyMock) Point() crypto.Point

Point -

func (*PublicKeyMock) Suite

func (pubKey *PublicKeyMock) Suite() crypto.Suite

Suite -

func (*PublicKeyMock) ToByteArray

func (pubKey *PublicKeyMock) ToByteArray() ([]byte, error)

ToByteArray mocks converting a public key to a byte array

type ScalarMock

type ScalarMock struct {
	X int

	MarshalBinaryStub    func(x int) ([]byte, error)
	UnmarshalBinaryStub  func([]byte) (int, error)
	GetUnderlyingObjStub func() interface{}
}

ScalarMock represents a mock implementation of a Scalar

func (*ScalarMock) Add

func (sm *ScalarMock) Add(_ crypto.Scalar) (crypto.Scalar, error)

Add returns the modular sum of receiver with scalar s given as parameter

func (*ScalarMock) Clone

func (sm *ScalarMock) Clone() crypto.Scalar

Clone creates a new Scalar with same value as receiver

func (*ScalarMock) Div

func (sm *ScalarMock) Div(_ crypto.Scalar) (crypto.Scalar, error)

Div returns the modular division between receiver and scalar s given as parameter

func (*ScalarMock) Equal

func (sm *ScalarMock) Equal(_ crypto.Scalar) (bool, error)

Equal tests if receiver is equal with the scalar s given as parameter. Both scalars need to be derived from the same Group

func (*ScalarMock) GetUnderlyingObj

func (sm *ScalarMock) GetUnderlyingObj() interface{}

GetUnderlyingObj returns the object the implementation wraps

func (*ScalarMock) Inv

func (sm *ScalarMock) Inv(_ crypto.Scalar) (crypto.Scalar, error)

Inv returns the modular inverse of scalar s given as parameter

func (*ScalarMock) IsInterfaceNil

func (sm *ScalarMock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ScalarMock) MarshalBinary

func (sm *ScalarMock) MarshalBinary() ([]byte, error)

MarshalBinary transforms the Scalar into a byte array

func (*ScalarMock) Mul

func (sm *ScalarMock) Mul(_ crypto.Scalar) (crypto.Scalar, error)

Mul returns the modular product of receiver with scalar s given as parameter

func (*ScalarMock) Neg

func (sm *ScalarMock) Neg() crypto.Scalar

Neg returns the modular negation of receiver

func (*ScalarMock) One

func (sm *ScalarMock) One() crypto.Scalar

One returns the multiplicative identity (1)

func (*ScalarMock) Pick

func (sm *ScalarMock) Pick() (crypto.Scalar, error)

Pick returns a fresh random or pseudo-random scalar For the mock set X to the original scalar.X *2

func (*ScalarMock) Set

func (sm *ScalarMock) Set(_ crypto.Scalar) error

Set sets the receiver to Scalar s given as parameter

func (*ScalarMock) SetBytes

func (sm *ScalarMock) SetBytes([]byte) (crypto.Scalar, error)

SetBytes sets the scalar from a byte-slice, reducing if necessary to the appropriate modulus.

func (*ScalarMock) SetInt64

func (sm *ScalarMock) SetInt64(_ int64)

SetInt64 sets the receiver to a small integer value v given as parameter

func (*ScalarMock) Sub

func (sm *ScalarMock) Sub(_ crypto.Scalar) (crypto.Scalar, error)

Sub returns the modular difference between receiver and scalar s given as parameter

func (*ScalarMock) UnmarshalBinary

func (sm *ScalarMock) UnmarshalBinary(val []byte) error

UnmarshalBinary recreates the Scalar from a byte array

func (*ScalarMock) Zero

func (sm *ScalarMock) Zero() crypto.Scalar

Zero returns the the additive identity (0)

type Streamer

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

Streamer -

func NewStreamer

func NewStreamer() *Streamer

NewStreamer -

func (*Streamer) XORKeyStream

func (stream *Streamer) XORKeyStream(dst, src []byte)

XORKeyStream -

type SuiteStub

type SuiteStub struct {
	StringStub               func() string
	ScalarLenStub            func() int
	CreateScalarStub         func() crypto.Scalar
	PointLenStub             func() int
	CreatePointStub          func() crypto.Point
	CreatePointForScalarStub func(scalar crypto.Scalar) (crypto.Point, error)
	RandomStreamStub         func() cipher.Stream
	CreateKeyPairStub        func() (crypto.Scalar, crypto.Point)
	IsPointValidStub         func([]byte) error
	GetUnderlyingSuiteStub   func() interface{}
}

SuiteStub -

func (*SuiteStub) CheckPointValid

func (s *SuiteStub) CheckPointValid(pointBytes []byte) error

IsPointValid -

func (*SuiteStub) CreateKeyPair

func (s *SuiteStub) CreateKeyPair() (crypto.Scalar, crypto.Point)

CreateKeyPair -

func (*SuiteStub) CreatePoint

func (s *SuiteStub) CreatePoint() crypto.Point

CreatePoint -

func (*SuiteStub) CreatePointForScalar

func (s *SuiteStub) CreatePointForScalar(scalar crypto.Scalar) (crypto.Point, error)

CreatePointForScalar -

func (*SuiteStub) CreateScalar

func (s *SuiteStub) CreateScalar() crypto.Scalar

CreateScalar -

func (*SuiteStub) GetUnderlyingSuite

func (s *SuiteStub) GetUnderlyingSuite() interface{}

GetUnderlyingSuite -

func (*SuiteStub) IsInterfaceNil

func (s *SuiteStub) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*SuiteStub) PointLen

func (s *SuiteStub) PointLen() int

PointLen -

func (*SuiteStub) RandomStream

func (s *SuiteStub) RandomStream() cipher.Stream

RandomStream -

func (*SuiteStub) ScalarLen

func (s *SuiteStub) ScalarLen() int

ScalarLen -

func (*SuiteStub) String

func (s *SuiteStub) String() string

String -

Jump to

Keyboard shortcuts

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