testing

package
v0.23.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DivulgeAddresses

func DivulgeAddresses(a, b network.Network)

DivulgeAddresses adds swarm a's addresses to swarm b's peerstore.

func GenSwarm

func GenSwarm(t *testing.T, opts ...Option) *swarm.Swarm

GenSwarm generates a new test swarm.

func GenUpgrader

func GenUpgrader(t *testing.T, n *swarm.Swarm, opts ...tptu.Option) transport.Upgrader

GenUpgrader creates a new connection upgrader for use with this swarm.

Types

type MockConnectionGater

type MockConnectionGater struct {
	Dial     func(p peer.ID, addr ma.Multiaddr) bool
	PeerDial func(p peer.ID) bool
	Accept   func(c network.ConnMultiaddrs) bool
	Secured  func(network.Direction, peer.ID, network.ConnMultiaddrs) bool
	Upgraded func(c network.Conn) (bool, control.DisconnectReason)
}

MockConnectionGater is a mock connection gater to be used by the tests.

func DefaultMockConnectionGater

func DefaultMockConnectionGater() *MockConnectionGater

func (*MockConnectionGater) InterceptAccept

func (m *MockConnectionGater) InterceptAccept(c network.ConnMultiaddrs) (allow bool)

func (*MockConnectionGater) InterceptAddrDial

func (m *MockConnectionGater) InterceptAddrDial(p peer.ID, addr ma.Multiaddr) (allow bool)

func (*MockConnectionGater) InterceptPeerDial

func (m *MockConnectionGater) InterceptPeerDial(p peer.ID) (allow bool)

func (*MockConnectionGater) InterceptSecured

func (m *MockConnectionGater) InterceptSecured(d network.Direction, p peer.ID, c network.ConnMultiaddrs) (allow bool)

func (*MockConnectionGater) InterceptUpgraded

func (m *MockConnectionGater) InterceptUpgraded(tc network.Conn) (allow bool, reason control.DisconnectReason)

type Option

type Option func(*testing.T, *config)

Option is an option that can be passed when constructing a test swarm.

var OptDialOnly Option = func(_ *testing.T, c *config) {
	c.dialOnly = true
}

OptDialOnly prevents the test swarm from listening.

var OptDisableQUIC Option = func(_ *testing.T, c *config) {
	c.disableQUIC = true
}

OptDisableQUIC disables QUIC.

var OptDisableReuseport Option = func(_ *testing.T, c *config) {
	c.disableReuseport = true
}

OptDisableReuseport disables reuseport in this test swarm.

var OptDisableTCP Option = func(_ *testing.T, c *config) {
	c.disableTCP = true
}

OptDisableTCP disables TCP.

func OptConnGater

func OptConnGater(cg connmgr.ConnectionGater) Option

OptConnGater configures the given connection gater on the test

func OptPeerPrivateKey

func OptPeerPrivateKey(sk crypto.PrivKey) Option

OptPeerPrivateKey configures the peer private key which is then used to derive the public key and peer ID.

func WithClock

func WithClock(clock clock) Option

WithClock sets the clock to use for this swarm

func WithSwarmOpts

func WithSwarmOpts(swarmOpts ...swarm.Option) Option

Jump to

Keyboard shortcuts

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