test

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Overview

Package test contains implementations of the peer interfaces that are useful for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMsgsSerializationTest added in v0.9.0

func AuthMsgsSerializationTest(t *testing.T, serializerTest func(t *testing.T, msg wire.Msg))

AuthMsgsSerializationTest runs serialization tests on auth message.

func ControlMsgsSerializationTest added in v0.9.0

func ControlMsgsSerializationTest(t *testing.T, serializerTest func(t *testing.T, msg wire.Msg))

ControlMsgsSerializationTest runs serialization tests on control messages.

func GenericBusTest

func GenericBusTest(t *testing.T,
	busAssigner func(wire.Account) (pub wire.Bus, sub wire.Bus),
	numClients, numMsgs int,
)

GenericBusTest tests the general functionality of a bus in the happy case: it tests that messages sent over the bus arrive at the correct destination. The parameter numClients controls how many clients communicate over the bus, and numMsgs controls how many messages each client sends to all other clients. The parameter busAssigner is used to assign a bus to each client, and must perform any necessary work to make clients able to communicate with each other (such as setting up dialers and listeners, in case of networking). It can either return the same bus twice, or separately select a bus to subscribe the client to, and a bus the client should use for publishing messages.

func GenericMarshalerTest added in v0.9.0

func GenericMarshalerTest(t *testing.T, serializers ...binary)

GenericMarshalerTest runs multiple tests to check whether encoding and decoding of serializer values works.

func NewRandomAccount added in v0.10.1

func NewRandomAccount(rng *rand.Rand) wire.Account

NewRandomAccount returns a new random account.

func NewRandomAddress

func NewRandomAddress(rng *rand.Rand) wire.Address

NewRandomAddress returns a new random address.

func NewRandomAddresses

func NewRandomAddresses(rng *rand.Rand, n int) []wire.Address

NewRandomAddresses returns a slice of random peer addresses.

func NewRandomEnvelope

func NewRandomEnvelope(rng *rand.Rand, m wire.Msg) *wire.Envelope

NewRandomEnvelope returns an envelope around message m with random sender and recipient generated using randomness from rng.

func SetNewRandomAccount added in v0.10.1

func SetNewRandomAccount(f NewRandomAccountFunc)

SetNewRandomAccount sets the account randomizer function.

func SetNewRandomAddress added in v0.10.1

func SetNewRandomAddress(f NewRandomAddressFunc)

SetNewRandomAddress sets the address randomizer function.

func TestAddressImplementation added in v0.10.1

func TestAddressImplementation(t *testing.T, newAddress wire.NewAddressFunc, newRandomAddress NewRandomAddressFunc)

TestAddressImplementation runs a test suite designed to test the general functionality of an address implementation.

Types

type NewRandomAccountFunc added in v0.10.1

type NewRandomAccountFunc = func(*rand.Rand) wire.Account

NewRandomAccountFunc is a account randomizer function.

type NewRandomAddressFunc added in v0.10.1

type NewRandomAddressFunc = func(*rand.Rand) wire.Address

NewRandomAddressFunc is a address randomizer function.

type SerializingLocalBus added in v0.7.0

type SerializingLocalBus struct {
	*wire.LocalBus
	// contains filtered or unexported fields
}

SerializingLocalBus is a local bus that also serializes messages for testing.

func NewSerializingLocalBus added in v0.7.0

func NewSerializingLocalBus() *SerializingLocalBus

NewSerializingLocalBus creates a new serializing local bus.

func (*SerializingLocalBus) Publish added in v0.7.0

func (b *SerializingLocalBus) Publish(ctx context.Context, e *wire.Envelope) (err error)

Publish publishes the message on the bus.

Jump to

Keyboard shortcuts

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