mock

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpDial = "dialOne"
	OpStop = "stopOne"
)

Variables

This section is empty.

Functions

func NewNodeAddress

func NewNodeAddress(seed uint16) string

NewNodeAddress generates a string that is accepted as validator address. For given `seed`, the address will always be the same.

func NewNodeID

func NewNodeID(seed uint16) string

NewNodeID generates new deterministic node ID. For a given `uniqueID`, the node ID is always the same.

func NewProTxHash

func NewProTxHash(seed uint16) []byte

NewProTxHash generates a deterministic proTxHash. For the same `seed`, generated data is always the same.

func NewProTxHashes

func NewProTxHashes(seeds ...uint16) []bytes.HexBytes

NewProTxHashes generates multiple deterministic proTxHash'es using mockProTxHash. Each argument will be passed to mockProTxHash. Each proTxHash will use provided `seed`

func NewQuorumHash

func NewQuorumHash(seed uint16) []byte

NewQuorumHash generates a deterministic quorum hash. For the same `seed`, generated data is always the same.

func NewValidator

func NewValidator(seed uint16) *types.Validator

NewValidator generates a validator with only fields needed for node selection filled. For the same `seed`, mock validator will always have the same data (proTxHash, NodeID)

func NewValidators

func NewValidators(n uint16) []*types.Validator

NewValidators generates a slice containing `n` mock validators. Each element is generated using `mock.NewValidator()`.

func ValidatorsProTxHashes

func ValidatorsProTxHashes(vals []*types.Validator) []bytes.HexBytes

ValidatorsProTxHashes returns slice of proTxHashes for provided list of validators

Types

type DashDialer

type DashDialer struct {
	ConnectedPeers map[types.NodeID]bool
	HistoryChan    chan HistoryEvent
	// contains filtered or unexported fields
}

DashDialer is a mock `p2p.DashDialer`. It sends event about DialPeersAsync() and StopPeerGracefully() calls to HistoryChan and stores them in History

func NewDashDialer

func NewDashDialer() *DashDialer

NewDashDialer creates a new mock p2p.DashDialer that sends notifications on all events to HistoryChan channel.

func (*DashDialer) ConnectAsync

func (sw *DashDialer) ConnectAsync(addr p2p.NodeAddress) error

ConnectAsync implements p2p.DashDialer. It emulates connecting to provided address, adds is as a connected peer and emits history event OpDial.

func (*DashDialer) DisconnectAsync

func (sw *DashDialer) DisconnectAsync(id types.NodeID) error

DisconnectAsync implements p2p.DashDialer. It removes the peer from list of connected peers and emits history event OpStop

func (*DashDialer) IsDialingOrConnected

func (sw *DashDialer) IsDialingOrConnected(id types.NodeID) bool

IsDialingOrConnected implements p2p.DashDialer. It checks if provided peer is connected or dial is in progress.

func (*DashDialer) Resolve

func (sw *DashDialer) Resolve(val types.ValidatorAddress) (p2p.NodeAddress, error)

type HistoryEvent

type HistoryEvent struct {
	Operation string // OpDialMany, OpStopOne
	Params    []string
}

HistoryEvent is a log of dial and stop operations executed by the DashDialer

Jump to

Keyboard shortcuts

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