Documentation
¶
Index ¶
- func CreateNetworkLogger(t *testing.T, config *FuzzConfig) *testutil.TestLogger
- func CreateNodeLogger(t *testing.T, config *FuzzConfig, nodeID simplex.NodeID) *testutil.TestLogger
- func NewProtocolMetadata(round, seq uint64, prev simplex.Digest) simplex.ProtocolMetadata
- type Block
- type BlockDeserializer
- type FuzzConfig
- type Mempool
- func (m *Mempool) AcceptBlock(b *Block)
- func (m *Mempool) AddPendingTXs(txs ...*TX)
- func (m *Mempool) BuildBlock(ctx context.Context, md simplex.ProtocolMetadata, bl simplex.Blacklist) (simplex.VerifiedBlock, bool)
- func (m *Mempool) Clear()
- func (m *Mempool) IsTxAccepted(txID txID) bool
- func (m *Mempool) IsTxPending(txID txID) bool
- func (m *Mempool) NotifyTxsReady()
- func (m *Mempool) VerifyBlock(ctx context.Context, b *Block) error
- func (m *Mempool) WaitForPendingBlock(ctx context.Context)
- type Network
- type Node
- type Storage
- type TX
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNetworkLogger ¶
func CreateNetworkLogger(t *testing.T, config *FuzzConfig) *testutil.TestLogger
CreateNetworkLogger creates a logger for the network that writes to both console and main.log
func CreateNodeLogger ¶
func CreateNodeLogger(t *testing.T, config *FuzzConfig, nodeID simplex.NodeID) *testutil.TestLogger
CreateNodeLogger creates a logger for a node that writes to both console and {nodeID}.log
func NewProtocolMetadata ¶
func NewProtocolMetadata(round, seq uint64, prev simplex.Digest) simplex.ProtocolMetadata
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func (*Block) BlockHeader ¶
func (b *Block) BlockHeader() simplex.BlockHeader
func (*Block) ComputeAndSetDigest ¶
func (b *Block) ComputeAndSetDigest()
type BlockDeserializer ¶
type BlockDeserializer struct {
// contains filtered or unexported fields
}
func (*BlockDeserializer) DeserializeBlock ¶
type FuzzConfig ¶
type FuzzConfig struct {
// The minimum and maximum number of nodes in the network.
MinNodes int // Default is 3.
MaxNodes int // Default is 10.
// The minimum and maximum number of transactions to be issued at a block. Default is between 5 and 20.
MinTxsPerIssue int
MaxTxsPerIssue int
// Number of transactions per block. Default is 15.
TxsPerBlock int
// The number of blocks that must be finalized before ending the fuzz test. Default is 100.
NumFinalizedBlocks int
RandomSeed int64
// Probability that a node will be randomly crashed. Default is .1 (10%).
NodeCrashProbability float64
// Probability that a crashed node will be restarted. Default is .5 (50%).
NodeRecoverProbability float64
// Amount to advance the time by. Default is simplex.DefaultMaxProposalWaitTime / 5.
AdvanceTimeTickAmount time.Duration
// Creates main.log for network logs and {nodeID-short}.log for each node.
// NodeID is represented as a 16-character hex string (first 8 bytes).
// Default directory is "tmp".
// If empty, logging to files is disabled and logs will only be printed to console.
LogDirectory string
}
func DefaultFuzzConfig ¶
func DefaultFuzzConfig() *FuzzConfig
type Mempool ¶
type Mempool struct {
// contains filtered or unexported fields
}
func NewMempool ¶
func NewMempool(l simplex.Logger, config *FuzzConfig) *Mempool
func (*Mempool) AcceptBlock ¶
AcceptBlock accepts the block and updates the mempool state to clean up transactions, remove sibling/uncle blocks, and move any non-conflicting transactions from purged sibling/uncle blocks back to unaccepted
func (*Mempool) AddPendingTXs ¶
func (*Mempool) BuildBlock ¶
func (m *Mempool) BuildBlock(ctx context.Context, md simplex.ProtocolMetadata, bl simplex.Blacklist) (simplex.VerifiedBlock, bool)
func (*Mempool) Clear ¶
func (m *Mempool) Clear()
Clear resets the mempool state to simulate a node restart. We do not remove accepted & unaccepted transactions/blocks from the mempool(since we don't have tx gossip) but we do clear verified blocks since we are expected to re-verify after a restart.
func (*Mempool) IsTxAccepted ¶
IsTxAccepted returns true if the transaction has been accepted
func (*Mempool) IsTxPending ¶
IsTxPending returns true if the transaction is still pending (unaccepted)
func (*Mempool) NotifyTxsReady ¶
func (m *Mempool) NotifyTxsReady()
NotifyTxsReady signals that there are pending transactions in the mempool.
func (*Mempool) VerifyBlock ¶
VerifyBlock verifies the block and its transactions. Errors if any tx is invalid or if there are duplicate txs in the block.
func (*Mempool) WaitForPendingBlock ¶
type Network ¶
type Network struct {
*testutil.BasicInMemoryNetwork
// contains filtered or unexported fields
}
func NewNetwork ¶
func NewNetwork(config *FuzzConfig, t *testing.T) *Network
func (*Network) PrintStatus ¶
func (n *Network) PrintStatus()
func (*Network) SetInfoLog ¶
func (n *Network) SetInfoLog()
func (*Network) StartInstances ¶
func (n *Network) StartInstances()
type Node ¶
func NewNode ¶
func NewNode(t *testing.T, nodeID simplex.NodeID, net *testutil.BasicInMemoryNetwork, config *FuzzConfig, nodeConfig randomNodeConfig) *Node
type Storage ¶
type Storage struct {
*testutil.InMemStorage
// contains filtered or unexported fields
}
func NewStorage ¶
func (*Storage) Index ¶
func (s *Storage) Index(ctx context.Context, block simplex.VerifiedBlock, certificate simplex.Finalization) error
type TX ¶
type TX struct {
ID txID
// contains filtered or unexported fields
}
func CreateNewTX ¶
func CreateNewTX() *TX
func TxFromBytes ¶
func (*TX) SetShouldFailVerification ¶
func (t *TX) SetShouldFailVerification()