Documentation
¶
Overview ¶
Package pastrytest provides various helpers for testing Pastry networks.
Index ¶
- func DistinctIdentifiers(minSize, maxSize int) *rapid.Generator[[]pastry.Identifier]
- func MessageOfType[M pastry.Message](callback func(dest pastry.Node, msg M)) func(SentMessage)
- func RandomIdentifier() *rapid.Generator[pastry.Identifier]
- func RandomProximity() *rapid.Generator[pastry.Proximity]
- func RoutedMessageOfType[M pastry.Message](...) func(SentMessage)
- type SentMessage
- type SentMessages
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DistinctIdentifiers ¶
func DistinctIdentifiers(minSize, maxSize int) *rapid.Generator[[]pastry.Identifier]
DistinctIdentifiers returns a property test generator that produces a list of identifiers that are guaranteed to be unique.
func MessageOfType ¶
func MessageOfType[M pastry.Message](callback func(dest pastry.Node, msg M)) func(SentMessage)
MessageOfType is a shim that allows you to pass a callback to SentMessages.ForEach that is only invoked for sent messages of a particular type.
func RandomIdentifier ¶
func RandomIdentifier() *rapid.Generator[pastry.Identifier]
RandomIdentifier returns a property test generator that returns a single random Identifier.
func RandomProximity ¶
RandomProximity returns a property test generator that returns a single random Proximity.
func RoutedMessageOfType ¶
func RoutedMessageOfType[M pastry.Message](callback func(nextHop pastry.Node, source pastry.Identifier, target pastry.Identifier, msg M)) func(SentMessage)
RoutedMessageOfType is a shim that allows you to pass a callback to SentMessages.ForEach that is only invoked for routed messages of a particular type.
Types ¶
type SentMessage ¶
SentMessages is a record of one of the outgoing messages sent by a node in a test universe.
type SentMessages ¶
type SentMessages struct {
// contains filtered or unexported fields
}
SentMessages is a record of all of the outgoing messages sent by a node in a test universe.
func NewSentMessages ¶
func NewSentMessages(router *pastry.Router) *SentMessages
func (*SentMessages) Add ¶
func (sms *SentMessages) Add(sm SentMessage)
Add records a new sent message.
func (*SentMessages) ForEach ¶
func (sms *SentMessages) ForEach(callback func(sm SentMessage))
ForEach executes a callback against each sent message. This is typically used in test cases to check assertions against the message content. You can use MessageOfType and RoutedMessageOfType to create callbacks that will only be applied to sent (routed) messages of a particular type.
func (*SentMessages) Len ¶
func (sms *SentMessages) Len() int
Len returns the number of messages that were sent by this node.