Documentation
¶
Overview ¶
Package ntu provides helpers for exercising network protocols in-memory without real transports.
See README.md for details.
Index ¶
- func CBORRoundTrip[T any](tb testing.TB, v T) T
- func MakeRandomQuorum(tb testing.TB, prng io.Reader, n int) network.Quorum
- func MakeRandomSessionID(tb testing.TB, prng io.Reader) network.SID
- func MapBroadcastO2I[P interface{ ... }, BcastT network.Message](tb testing.TB, participants []P, broadcastOutputs map[sharing.ID]BcastT) (broadcastInputs map[sharing.ID]network.RoundMessages[BcastT])
- func MapO2I[P TestParticipant, BcastT, UnicastT network.Message](tb testing.TB, participants []P, broadcastOutputs map[sharing.ID]BcastT, ...) (broadcastInputs map[sharing.ID]network.RoundMessages[BcastT], ...)
- func MapUnicastO2I[P interface{ ... }, UnicastT network.Message](tb testing.TB, participants []P, ...) (p2pInputs map[sharing.ID]network.RoundMessages[UnicastT])
- func TestExecuteRunners[O any](tb testing.TB, runners map[sharing.ID]network.Runner[O]) map[sharing.ID]O
- type MockCoordinator
- type TestParticipant
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CBORRoundTrip ¶
CBORRoundTrip serialises and deserialises a value, asserting round-trip fidelity.
func MakeRandomQuorum ¶
MakeRandomQuorum samples a random quorum of distinct non-zero sharing IDs.
func MakeRandomSessionID ¶
MakeRandomSessionID reads 32 random bytes into an SID.
func MapBroadcastO2I ¶
func MapBroadcastO2I[
P interface {
SharingID() sharing.ID
}, BcastT network.Message,
](
tb testing.TB,
participants []P,
broadcastOutputs map[sharing.ID]BcastT,
) (
broadcastInputs map[sharing.ID]network.RoundMessages[BcastT],
)
MapBroadcastO2I maps the broadcasts of all participants in a round of a protocol to the inputs of the next round with serialising and deserializing them throughout the process.
func MapO2I ¶
func MapO2I[ P TestParticipant, BcastT, UnicastT network.Message, ]( tb testing.TB, participants []P, broadcastOutputs map[sharing.ID]BcastT, UnicastOutputs map[sharing.ID]network.RoundMessages[UnicastT], ) ( broadcastInputs map[sharing.ID]network.RoundMessages[BcastT], UnicastInputs map[sharing.ID]network.RoundMessages[UnicastT], )
MapO2I maps the outputs of all participants in a round of a protocol to the inputs of the next round with serialising and deserializing them throughout the process.
func MapUnicastO2I ¶
func MapUnicastO2I[
P interface {
SharingID() sharing.ID
}, UnicastT network.Message,
](
tb testing.TB,
participants []P,
p2pOutputs map[sharing.ID]network.RoundMessages[UnicastT],
) (
p2pInputs map[sharing.ID]network.RoundMessages[UnicastT],
)
MapUnicastO2I maps the P2P messages of all participants in a round of a protocol to the inputs of the next round with serialising and deserializing them throughout the process.
Types ¶
type MockCoordinator ¶
type MockCoordinator struct {
// contains filtered or unexported fields
}
MockCoordinator simulates a reliable message hub using buffered channels.
func NewMockCoordinator ¶
func NewMockCoordinator(quorum ...sharing.ID) *MockCoordinator
NewMockCoordinator allocates buffered in-memory channels for each party in the quorum.
func (*MockCoordinator) DeliveryFor ¶
func (c *MockCoordinator) DeliveryFor(sharingID sharing.ID) network.Delivery
DeliveryFor returns a Delivery implementation bound to the given party.
type TestParticipant ¶
TestParticipant is the minimal interface needed to route messages in helpers.