Documentation ¶
Index ¶
- func NewMultiStore() sdk.MultiStore
- func NewRouter() sdk.Router
- func NewTestKVStore() interfaces.KVStore
- type BlockChain
- func (bc *BlockChain) AddNodes(nodes ...*Node)
- func (bc BlockChain) CurrentHeight() int64
- func (bc *BlockChain) Start()
- func (bc *BlockChain) Submit(msg sdk.Msg) <-chan *Result
- func (bc *BlockChain) WaitNBlocks(n int64)
- func (bc BlockChain) WithBlockSize(size int) *BlockChain
- func (bc BlockChain) WithBlockTimeOut(timeOut time.Duration) *BlockChain
- type MultiStore
- type Node
- type Result
- type Router
- type TestKVStore
- func (t TestKVStore) CacheWrap() sdk.CacheWrap
- func (t TestKVStore) CacheWrapWithListeners(storeKey types.StoreKey, listeners []types.WriteListener) types.CacheWrap
- func (t TestKVStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) sdk.CacheWrap
- func (t TestKVStore) Delete(key []byte)
- func (t TestKVStore) Get(key []byte) []byte
- func (t TestKVStore) GetStoreType() sdk.StoreType
- func (t TestKVStore) Has(key []byte) bool
- func (t TestKVStore) Iterator(start, end []byte) sdk.Iterator
- func (t TestKVStore) ReverseIterator(start, end []byte) sdk.Iterator
- func (t TestKVStore) Set(key, value []byte)
- type Tofnd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMultiStore ¶
func NewMultiStore() sdk.MultiStore
NewMultiStore returns a new Multistore instance used for testing
func NewTestKVStore ¶
func NewTestKVStore() interfaces.KVStore
NewTestKVStore returns a new kv store instance for testing
Types ¶
type BlockChain ¶
type BlockChain struct {
// contains filtered or unexported fields
}
BlockChain is a fake that emulates the behaviour of a full blockchain network (consensus and message dissemination) for testing
func NewBlockchain ¶
func NewBlockchain() *BlockChain
NewBlockchain returns a faked blockchain with default parameters. Use the With* functions to specify different parameters. By default, the blockchain does not time out, so a block will only be disseminated once the specified block size is reached.
func (*BlockChain) AddNodes ¶
func (bc *BlockChain) AddNodes(nodes ...*Node)
AddNodes adds a node to the blockchain. This node will receive blocks from the blockchain.
func (BlockChain) CurrentHeight ¶
func (bc BlockChain) CurrentHeight() int64
CurrentHeight returns the current block height.
func (*BlockChain) Start ¶
func (bc *BlockChain) Start()
Start starts the block dissemination. Only call once all parameters and nodes are fully set up.
func (*BlockChain) Submit ¶
func (bc *BlockChain) Submit(msg sdk.Msg) <-chan *Result
Submit sends a message to the blockchain. It returns a channel with the result.
func (*BlockChain) WaitNBlocks ¶
func (bc *BlockChain) WaitNBlocks(n int64)
WaitNBlocks waits for n blocks to be disseminated before returning. Do not use without setting a block timeout or the test will deadlock.
func (BlockChain) WithBlockSize ¶
func (bc BlockChain) WithBlockSize(size int) *BlockChain
WithBlockSize returns a blockchain with blocks of at most the specified size.
func (BlockChain) WithBlockTimeOut ¶
func (bc BlockChain) WithBlockTimeOut(timeOut time.Duration) *BlockChain
WithBlockTimeOut returns a blockchain with a timeout. The timeout resets whenever a message is received. When the timer runs out it disseminates the next block regardless of its size.
type MultiStore ¶
type MultiStore struct { *mock.MultiStoreMock // contains filtered or unexported fields }
MultiStore is a simple multistore used for testing
type Node ¶
Node is a fake that emulates the behaviour of a Cosmos node by retrieving blocks from the network, unpacking the messages and routing them to the correct modules
func NewNode ¶
func NewNode(moniker string, ctx sdk.Context, router sdk.Router, queriers map[string]sdk.Querier) *Node
NewNode creates a new node that can be added to the blockchain. The moniker is used to differentiate nodes for logging purposes. The context will be passed on to the registered handlers.
func (*Node) RegisterEventListener ¶
RegisterEventListener registers a listener for events that satisfy the predicate. Events will be dropped if the event channel fills up
func (*Node) WithEndBlockers ¶
func (n *Node) WithEndBlockers(endBlockers ...func(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate) *Node
WithEndBlockers returns a node with the specified EndBlocker functions. They are executed in the order they are provided.
type Result ¶
Result contains either the result of a successful message execution or the error that occurred
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a fake that is used by the Node to route messages to the correct module handlers
type TestKVStore ¶
type TestKVStore struct {
// contains filtered or unexported fields
}
TestKVStore is a kv store for testing
func (TestKVStore) CacheWrap ¶
func (t TestKVStore) CacheWrap() sdk.CacheWrap
CacheWrap is not implemented
func (TestKVStore) CacheWrapWithListeners ¶
func (t TestKVStore) CacheWrapWithListeners(storeKey types.StoreKey, listeners []types.WriteListener) types.CacheWrap
CacheWrapWithListeners is not implemented
func (TestKVStore) CacheWrapWithTrace ¶
func (t TestKVStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) sdk.CacheWrap
CacheWrapWithTrace is not implemented
func (TestKVStore) Delete ¶
func (t TestKVStore) Delete(key []byte)
Delete deletes a key if it exists
func (TestKVStore) Get ¶
func (t TestKVStore) Get(key []byte) []byte
Get returns the value of the given key, nil if it does not exist
func (TestKVStore) GetStoreType ¶
func (t TestKVStore) GetStoreType() sdk.StoreType
GetStoreType is not implemented
func (TestKVStore) Has ¶
func (t TestKVStore) Has(key []byte) bool
Has checks if an entry for the given key exists
func (TestKVStore) Iterator ¶
func (t TestKVStore) Iterator(start, end []byte) sdk.Iterator
Iterator returns an interator over the given key domain
func (TestKVStore) ReverseIterator ¶
func (t TestKVStore) ReverseIterator(start, end []byte) sdk.Iterator
ReverseIterator returns an iterator that iterates over all keys in the given domain in reverse order
func (TestKVStore) Set ¶
func (t TestKVStore) Set(key, value []byte)
Set stores the given key value pair
type Tofnd ¶
type Tofnd struct {
// contains filtered or unexported fields
}
Tofnd is a thread-safe fake that emulates the external tofnd process