mock

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

TODO: remove this file once we completely migrate to Numbat Trie implementation crypto_test.go needs to be removed as well as the sha3 folder

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNonceHashConverterMock

func NewNonceHashConverterMock() *nonceHashConverterMock

Types

type AccountTrackerStub

type AccountTrackerStub struct {
	SaveAccountCalled func(accountHandler state.AccountHandler) error
	JournalizeCalled  func(entry state.JournalEntry)
}

func (*AccountTrackerStub) Journalize

func (ats *AccountTrackerStub) Journalize(entry state.JournalEntry)

func (*AccountTrackerStub) SaveAccount

func (ats *AccountTrackerStub) SaveAccount(accountHandler state.AccountHandler) error

type AccountWrapMock

type AccountWrapMock struct {
	MockValue int

	SetCodeHashWithJournalCalled func(codeHash []byte) error `json:"-"`
	SetRootHashWithJournalCalled func([]byte) error          `json:"-"`
	// contains filtered or unexported fields
}

func NewAccountWrapMock

func NewAccountWrapMock(adr state.AddressContainer, tracker state.AccountTracker) *AccountWrapMock

func (*AccountWrapMock) AddressContainer

func (awm *AccountWrapMock) AddressContainer() state.AddressContainer

func (*AccountWrapMock) DataTrie

func (awm *AccountWrapMock) DataTrie() trie.PatriciaMerkelTree

func (*AccountWrapMock) DataTrieTracker

func (awm *AccountWrapMock) DataTrieTracker() state.DataTrieTracker

func (*AccountWrapMock) GetCode

func (awm *AccountWrapMock) GetCode() []byte

func (*AccountWrapMock) GetCodeHash

func (awm *AccountWrapMock) GetCodeHash() []byte

func (*AccountWrapMock) GetRootHash

func (awm *AccountWrapMock) GetRootHash() []byte

func (*AccountWrapMock) SetCode

func (awm *AccountWrapMock) SetCode(code []byte)

func (*AccountWrapMock) SetCodeHash

func (awm *AccountWrapMock) SetCodeHash(codeHash []byte)

func (*AccountWrapMock) SetCodeHashWithJournal

func (awm *AccountWrapMock) SetCodeHashWithJournal(codeHash []byte) error

func (*AccountWrapMock) SetDataTrie

func (awm *AccountWrapMock) SetDataTrie(trie trie.PatriciaMerkelTree)

func (*AccountWrapMock) SetDataTrieTracker

func (awm *AccountWrapMock) SetDataTrieTracker(tracker state.DataTrieTracker)

func (*AccountWrapMock) SetRootHash

func (awm *AccountWrapMock) SetRootHash(rootHash []byte)

func (*AccountWrapMock) SetRootHashWithJournal

func (awm *AccountWrapMock) SetRootHashWithJournal(rootHash []byte) error

type AccountsFactoryStub

type AccountsFactoryStub struct {
	CreateAccountCalled func(address state.AddressContainer, tracker state.AccountTracker) (state.AccountHandler, error)
}

func (*AccountsFactoryStub) CreateAccount

func (afs *AccountsFactoryStub) CreateAccount(address state.AddressContainer, tracker state.AccountTracker) (state.AccountHandler, error)

type AddressDummy

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

func NewAddressDummy

func NewAddressDummy(bytes, hash []byte) *AddressDummy

func (*AddressDummy) Bytes

func (ad *AddressDummy) Bytes() []byte

func (*AddressDummy) Hash

func (ad *AddressDummy) Hash() []byte

type AddressMock

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

AddressMock implements a mock address generator used in testing

func NewAddressMock

func NewAddressMock() *AddressMock

NewAddressMock generates a new address

func NewAddressMockFromBytes

func NewAddressMockFromBytes(buff []byte) *AddressMock

NewAddressMockFromBytes generates a new address

func (*AddressMock) Bytes

func (address *AddressMock) Bytes() []byte

Bytes returns the address' bytes

type CacherStub

type CacherStub struct {
	ClearCalled           func()
	PutCalled             func(key []byte, value interface{}) (evicted bool)
	GetCalled             func(key []byte) (value interface{}, ok bool)
	HasCalled             func(key []byte) bool
	PeekCalled            func(key []byte) (value interface{}, ok bool)
	HasOrAddCalled        func(key []byte, value interface{}) (ok, evicted bool)
	RemoveCalled          func(key []byte)
	RemoveOldestCalled    func()
	KeysCalled            func() [][]byte
	LenCalled             func() int
	RegisterHandlerCalled func(func(key []byte))
}

func (*CacherStub) Clear

func (cs *CacherStub) Clear()

func (*CacherStub) Get

func (cs *CacherStub) Get(key []byte) (value interface{}, ok bool)

func (*CacherStub) Has

func (cs *CacherStub) Has(key []byte) bool

func (*CacherStub) HasOrAdd

func (cs *CacherStub) HasOrAdd(key []byte, value interface{}) (ok, evicted bool)

func (*CacherStub) Keys

func (cs *CacherStub) Keys() [][]byte

func (*CacherStub) Len

func (cs *CacherStub) Len() int

func (*CacherStub) Peek

func (cs *CacherStub) Peek(key []byte) (value interface{}, ok bool)

func (*CacherStub) Put

func (cs *CacherStub) Put(key []byte, value interface{}) (evicted bool)

func (*CacherStub) RegisterHandler

func (cs *CacherStub) RegisterHandler(handler func(key []byte))

func (*CacherStub) Remove

func (cs *CacherStub) Remove(key []byte)

func (*CacherStub) RemoveOldest

func (cs *CacherStub) RemoveOldest()

type ConcurrentTrie

type ConcurrentTrie struct {
	*trie.Trie
	// contains filtered or unexported fields
}

ConcurrentTrie is a trie implementation that sould be concurrent safe

func NewConcurrentTrie

func NewConcurrentTrie(root []byte, dbw trie.DBWriteCacher, hsh hashing.Hasher) (*ConcurrentTrie, error)

NewConcurrentTrie returns a new trie that should be concurrent safe

func (*ConcurrentTrie) Commit

func (ct *ConcurrentTrie) Commit(onleaf trie.LeafCallback) (root []byte, err error)

Commit calls underlying trie's commit method. Concurrent safe

func (*ConcurrentTrie) Copy

Copy will call underlying trie's Copy() func. Concurrent safe

func (*ConcurrentTrie) DBW

func (ct *ConcurrentTrie) DBW() trie.DBWriteCacher

DBW returns the underlying trie's DatabaseWriteCacher object

func (*ConcurrentTrie) Delete

func (ct *ConcurrentTrie) Delete(key []byte) error

Deletes data from the underlying trie. Concurrent safe

func (*ConcurrentTrie) Get

func (ct *ConcurrentTrie) Get(key []byte) ([]byte, error)

Get fetches data from the underlying trie. Concurrent safe

func (*ConcurrentTrie) Recreate

func (ct *ConcurrentTrie) Recreate(root []byte, dbw trie.DBWriteCacher) (trie.PatriciaMerkelTree, error)

Recreates the trie from the input hash. Concurrent safe

func (*ConcurrentTrie) Root

func (ct *ConcurrentTrie) Root() []byte

Root computes trie root hash of the underlying trie. Concurrent safe

func (*ConcurrentTrie) SetCacheLimit

func (ct *ConcurrentTrie) SetCacheLimit(l uint16)

SetCacheLimit calls the underlying trie's equivalent method

func (*ConcurrentTrie) Update

func (ct *ConcurrentTrie) Update(key, value []byte) error

Update changes data from the underlying trie. Concurrent safe

type DBWriteCacherMock

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

DBWriteCacherMock that will be used for testing

func NewMockDBWriteCacher

func NewMockDBWriteCacher() *DBWriteCacherMock

NewMockDBWriteCacher returns a new DBWriteCacherMock

func (*DBWriteCacherMock) AppendMockTrie

func (mdbw *DBWriteCacherMock) AppendMockTrie(mockTrie *TrieMock)

AppendMockTrie adds a new 'trie'

func (*DBWriteCacherMock) CachedNode

func (mdbw *DBWriteCacherMock) CachedNode(hash []byte, cachegen uint16) trie.Node

CachedNode is an empty func

func (*DBWriteCacherMock) Cap

func (mdbw *DBWriteCacherMock) Cap(limit float64) error

Cap is an empty func

func (*DBWriteCacherMock) Commit

func (mdbw *DBWriteCacherMock) Commit(node []byte, report bool) error

Commit is an empty func

func (*DBWriteCacherMock) Dereference

func (mdbw *DBWriteCacherMock) Dereference(root []byte)

Dereference is an empty func

func (*DBWriteCacherMock) InsertBlob

func (mdbw *DBWriteCacherMock) InsertBlob(hash []byte, blob []byte)

InsertBlob is an empty func

func (*DBWriteCacherMock) InsertWithLock

func (mdbw *DBWriteCacherMock) InsertWithLock(hash []byte, blob []byte, node trie.Node)

InsertWithLock is an empty func

func (*DBWriteCacherMock) Node

func (mdbw *DBWriteCacherMock) Node(hash []byte) ([]byte, error)

Node is an empty func

func (*DBWriteCacherMock) Reference

func (mdbw *DBWriteCacherMock) Reference(child []byte, parent []byte)

Reference is an empty func

func (*DBWriteCacherMock) RetrieveMockTrie

func (mdbw *DBWriteCacherMock) RetrieveMockTrie(root []byte) (trie.PatriciaMerkelTree, error)

RetrieveMockTrie retrieves a stored 'trie' or nil if not found

func (*DBWriteCacherMock) Size

func (mdbw *DBWriteCacherMock) Size() (float64, float64)

Size is an empty func

func (*DBWriteCacherMock) Storer

func (mdbw *DBWriteCacherMock) Storer() storage.Storer

PersistDB is an empty func

type DataTrieTrackerStub

type DataTrieTrackerStub struct {
	ClearDataCachesCalled func()
	DirtyDataCalled       func() map[string][]byte
	OriginalValueCalled   func(key []byte) []byte
	RetrieveValueCalled   func(key []byte) ([]byte, error)
	SaveKeyValueCalled    func(key []byte, value []byte)
	SetDataTrieCalled     func(tr trie.PatriciaMerkelTree)
	DataTrieCalled        func() trie.PatriciaMerkelTree
}

func (*DataTrieTrackerStub) ClearDataCaches

func (dtts *DataTrieTrackerStub) ClearDataCaches()

func (*DataTrieTrackerStub) DataTrie

func (dtts *DataTrieTrackerStub) DataTrie() trie.PatriciaMerkelTree

func (*DataTrieTrackerStub) DirtyData

func (dtts *DataTrieTrackerStub) DirtyData() map[string][]byte

func (*DataTrieTrackerStub) OriginalValue

func (dtts *DataTrieTrackerStub) OriginalValue(key []byte) []byte

func (*DataTrieTrackerStub) RetrieveValue

func (dtts *DataTrieTrackerStub) RetrieveValue(key []byte) ([]byte, error)

func (*DataTrieTrackerStub) SaveKeyValue

func (dtts *DataTrieTrackerStub) SaveKeyValue(key []byte, value []byte)

func (*DataTrieTrackerStub) SetDataTrie

func (dtts *DataTrieTrackerStub) SetDataTrie(tr trie.PatriciaMerkelTree)

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

func (HasherMock) Size() int

Size return the required size in bytes

type HasherMock127

type HasherMock127 struct {
}

func (HasherMock127) Compute

func (HasherMock127) Compute(s string) []byte

func (HasherMock127) EmptyHash

func (HasherMock127) EmptyHash() []byte

func (HasherMock127) Size

func (HasherMock127) Size() int

type Keccak256

type Keccak256 struct {
}

func (*Keccak256) Compute

func (*Keccak256) Compute(input string) []byte

func (*Keccak256) EmptyHash

func (k *Keccak256) EmptyHash() []byte

func (*Keccak256) Size

func (*Keccak256) Size() int

type MarshalizerMock

type MarshalizerMock struct {
	Fail bool
}

MarshalizerMock that will be used for testing

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

func (*MarshalizerMock) Version

func (*MarshalizerMock) Version() string

Version is deprecated and will be removed

type MemoryStorerMock

type MemoryStorerMock struct {
	Fail bool
	// contains filtered or unexported fields
}

func NewMemoryStorerMock

func NewMemoryStorerMock() *MemoryStorerMock

func (*MemoryStorerMock) ClearCache

func (msm *MemoryStorerMock) ClearCache()

func (*MemoryStorerMock) DestroyUnit

func (msm *MemoryStorerMock) DestroyUnit() error

func (*MemoryStorerMock) Get

func (msm *MemoryStorerMock) Get(key []byte) ([]byte, error)

func (*MemoryStorerMock) Has

func (msm *MemoryStorerMock) Has(key []byte) error

func (*MemoryStorerMock) HasOrAdd

func (msm *MemoryStorerMock) HasOrAdd(key []byte, value []byte) error

func (*MemoryStorerMock) Put

func (msm *MemoryStorerMock) Put(key, data []byte) error

func (*MemoryStorerMock) Remove

func (msm *MemoryStorerMock) Remove(key []byte) error

type ShardCoordinatorMock

type ShardCoordinatorMock struct {
	SelfID     uint32
	NrOfShards uint32
}

func (ShardCoordinatorMock) CommunicationIdentifier

func (scm ShardCoordinatorMock) CommunicationIdentifier(destShardID uint32) string

func (ShardCoordinatorMock) ComputeId

func (scm ShardCoordinatorMock) ComputeId(address state.AddressContainer) uint32

func (ShardCoordinatorMock) NumberOfShards

func (scm ShardCoordinatorMock) NumberOfShards() uint32

func (ShardCoordinatorMock) SameShard

func (scm ShardCoordinatorMock) SameShard(firstAddress, secondAddress state.AddressContainer) bool

func (ShardCoordinatorMock) SelfId

func (scm ShardCoordinatorMock) SelfId() uint32

func (ShardCoordinatorMock) SetSelfId

func (scm ShardCoordinatorMock) SetSelfId(shardId uint32) error

type ShardedDataStub

type ShardedDataStub struct {
	RegisterHandlerCalled         func(func(key []byte))
	ShardDataStoreCalled          func(cacheId string) (c storage.Cacher)
	AddDataCalled                 func(key []byte, data interface{}, cacheId string)
	SearchFirstDataCalled         func(key []byte) (value interface{}, ok bool)
	RemoveDataCalled              func(key []byte, cacheId string)
	RemoveDataFromAllShardsCalled func(key []byte)
	MergeShardStoresCalled        func(sourceCacheId, destCacheId string)
	MoveDataCalled                func(sourceCacheId, destCacheId string, key [][]byte)
	ClearCalled                   func()
	ClearShardStoreCalled         func(cacheId string)
	RemoveSetOfDataFromPoolCalled func(keys [][]byte, destCacheId string)
	CreateShardStoreCalled        func(destCacheId string)
}

func (*ShardedDataStub) AddData

func (sd *ShardedDataStub) AddData(key []byte, data interface{}, cacheId string)

func (*ShardedDataStub) Clear

func (sd *ShardedDataStub) Clear()

func (*ShardedDataStub) ClearShardStore

func (sd *ShardedDataStub) ClearShardStore(cacheId string)

func (*ShardedDataStub) CreateShardStore

func (sd *ShardedDataStub) CreateShardStore(cacheId string)

func (*ShardedDataStub) MergeShardStores

func (sd *ShardedDataStub) MergeShardStores(sourceCacheId, destCacheId string)

func (*ShardedDataStub) MoveData

func (sd *ShardedDataStub) MoveData(sourceCacheId, destCacheId string, key [][]byte)

func (*ShardedDataStub) RegisterHandler

func (sd *ShardedDataStub) RegisterHandler(handler func(key []byte))

func (*ShardedDataStub) RemoveData

func (sd *ShardedDataStub) RemoveData(key []byte, cacheId string)

func (*ShardedDataStub) RemoveDataFromAllShards

func (sd *ShardedDataStub) RemoveDataFromAllShards(key []byte)

func (*ShardedDataStub) RemoveSetOfDataFromPool

func (sd *ShardedDataStub) RemoveSetOfDataFromPool(keys [][]byte, cacheId string)

func (*ShardedDataStub) SearchFirstData

func (sd *ShardedDataStub) SearchFirstData(key []byte) (value interface{}, ok bool)

func (*ShardedDataStub) ShardDataStore

func (sd *ShardedDataStub) ShardDataStore(cacheId string) (c storage.Cacher)

type StorerStub

type StorerStub struct {
	PutCalled         func(key, data []byte) error
	GetCalled         func(key []byte) ([]byte, error)
	HasCalled         func(key []byte) error
	HasOrAddCalled    func(key []byte, value []byte) error
	RemoveCalled      func(key []byte) error
	ClearCacheCalled  func()
	DestroyUnitCalled func() error
}

func (*StorerStub) ClearCache

func (ss *StorerStub) ClearCache()

func (*StorerStub) DestroyUnit

func (ss *StorerStub) DestroyUnit() error

func (*StorerStub) Get

func (ss *StorerStub) Get(key []byte) ([]byte, error)

func (*StorerStub) Has

func (ss *StorerStub) Has(key []byte) error

func (*StorerStub) HasOrAdd

func (ss *StorerStub) HasOrAdd(key []byte, value []byte) error

func (*StorerStub) Put

func (ss *StorerStub) Put(key, data []byte) error

func (*StorerStub) Remove

func (ss *StorerStub) Remove(key []byte) error

type TrieMock

type TrieMock struct {
	Fail         bool
	FailRecreate bool
	FailGet      bool
	TTFGet       int
	FailUpdate   bool
	TTFUpdate    int
	// contains filtered or unexported fields
}

TrieMock that will be used for testing

func NewMockTrie

func NewMockTrie() *TrieMock

NewMockTrie creates a new TrieMock obj

func NewMockTrieWithDBW

func NewMockTrieWithDBW(cacher trie.DBWriteCacher) *TrieMock

NewMockTrieWithDBW creates a new TrieMock obj on the same cacher object

func (*TrieMock) Commit

func (mt *TrieMock) Commit(onleaf trie.LeafCallback) (root []byte, err error)

Commit make changes to be permanent (calls the commit on underlining cacher)

func (*TrieMock) Copy

func (mt *TrieMock) Copy() trie.PatriciaMerkelTree

Copy returns a new 'trie'

func (*TrieMock) DBW

func (mt *TrieMock) DBW() trie.DBWriteCacher

DBW returns the underling cacher

func (*TrieMock) Delete

func (mt *TrieMock) Delete(key []byte) error

Delete erases the data from the 'trie'

func (*TrieMock) Get

func (mt *TrieMock) Get(key []byte) ([]byte, error)

Get returns the data from the 'trie'

func (*TrieMock) Recreate

func (mt *TrieMock) Recreate(root []byte, dbw trie.DBWriteCacher) (trie.PatriciaMerkelTree, error)

Recreate returns a new 'trie' based on the root hash and underlying cacher

func (*TrieMock) Root

func (mt *TrieMock) Root() []byte

Root returns the hash of the entire 'trie'

func (*TrieMock) SetCacheLimit

func (mt *TrieMock) SetCacheLimit(l uint16)

SetCacheLimit is an empty func

func (*TrieMock) Update

func (mt *TrieMock) Update(key, value []byte) error

Update inserts or modifies the data in the 'trie'

type TrieStub

type TrieStub struct {
	SetCacheLimitCalled func(l uint16)
	GetCalled           func(key []byte) ([]byte, error)
	UpdateCalled        func(key, value []byte) error
	DeleteCalled        func(key []byte) error
	RootCalled          func() []byte
	CommitCalled        func(onleaf trie.LeafCallback) (root []byte, err error)
	DBWCalled           func() trie.DBWriteCacher
	RecreateCalled      func(root []byte, dbw trie.DBWriteCacher) (trie.PatriciaMerkelTree, error)
	CopyCalled          func() trie.PatriciaMerkelTree
}

func (*TrieStub) Commit

func (ts *TrieStub) Commit(onleaf trie.LeafCallback) (root []byte, err error)

func (*TrieStub) Copy

func (ts *TrieStub) Copy() trie.PatriciaMerkelTree

func (*TrieStub) DBW

func (ts *TrieStub) DBW() trie.DBWriteCacher

func (*TrieStub) Delete

func (ts *TrieStub) Delete(key []byte) error

func (*TrieStub) Get

func (ts *TrieStub) Get(key []byte) ([]byte, error)

func (*TrieStub) Recreate

func (ts *TrieStub) Recreate(root []byte, dbw trie.DBWriteCacher) (trie.PatriciaMerkelTree, error)

func (*TrieStub) Root

func (ts *TrieStub) Root() []byte

func (*TrieStub) SetCacheLimit

func (ts *TrieStub) SetCacheLimit(l uint16)

func (*TrieStub) Update

func (ts *TrieStub) Update(key, value []byte) error

type Uint64CacherStub

type Uint64CacherStub struct {
	ClearCalled           func()
	PutCalled             func(uint64, []byte) bool
	GetCalled             func(uint64) ([]byte, bool)
	HasCalled             func(uint64) bool
	PeekCalled            func(uint64) ([]byte, bool)
	HasOrAddCalled        func(uint64, []byte) (bool, bool)
	RemoveCalled          func(uint64)
	RemoveOldestCalled    func()
	KeysCalled            func() []uint64
	LenCalled             func() int
	RegisterHandlerCalled func(handler func(nonce uint64))
}

func (*Uint64CacherStub) Clear

func (ucs *Uint64CacherStub) Clear()

func (*Uint64CacherStub) Get

func (ucs *Uint64CacherStub) Get(nonce uint64) ([]byte, bool)

func (*Uint64CacherStub) Has

func (ucs *Uint64CacherStub) Has(nonce uint64) bool

func (*Uint64CacherStub) HasOrAdd

func (ucs *Uint64CacherStub) HasOrAdd(nonce uint64, value []byte) (bool, bool)

func (*Uint64CacherStub) Keys

func (ucs *Uint64CacherStub) Keys() []uint64

func (*Uint64CacherStub) Len

func (ucs *Uint64CacherStub) Len() int

func (*Uint64CacherStub) Peek

func (ucs *Uint64CacherStub) Peek(nonce uint64) ([]byte, bool)

func (*Uint64CacherStub) Put

func (ucs *Uint64CacherStub) Put(nonce uint64, value []byte) bool

func (*Uint64CacherStub) RegisterHandler

func (ucs *Uint64CacherStub) RegisterHandler(handler func(nonce uint64))

func (*Uint64CacherStub) Remove

func (ucs *Uint64CacherStub) Remove(nonce uint64)

func (*Uint64CacherStub) RemoveOldest

func (ucs *Uint64CacherStub) RemoveOldest()

type UpdaterStub

type UpdaterStub struct {
	UpdateCalled func(key, value []byte) error
}

func (*UpdaterStub) Update

func (updater *UpdaterStub) Update(key, value []byte) error

Directories

Path Synopsis
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳