testutils

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LineNetworkConfig = newNetworkConfigFn(func(adjacentNodes AdjacentNodes) {
	n := len(adjacentNodes)
	for i := 0; i+1 < n; i++ {
		adjacentNodes.Connect(i, i+1)
	}
})
View Source
var SmallWorldNetworkConfig = newNetworkConfigFn(func(adjacentNodes AdjacentNodes) {
	const (
		rateOfNeighborConnections = 0.2
		rateOfRandomConnections   = 0.2
	)

	n := len(adjacentNodes)
	for i := range n {

		adjacentNodes.ConnectRandomDirection(i, (i+1)%n)

		for distance := 2; distance < 4; distance++ {
			if rand.Float64() < rateOfNeighborConnections {
				adjacentNodes.ConnectRandomDirection(i, (i+distance)%n)
			}
		}

		if rand.Float64() < rateOfRandomConnections {
			adjacentNodes.ConnectRandomDirection(i, rand.Intn(n))
		}
	}
})

Functions

This section is empty.

Types

type AdjacentNodes

type AdjacentNodes []map[int]struct{}

AdjacentNodes is a slice of N sets, each representing the nodes adjacent to the node at the index.

func NewAdjacentNodes

func NewAdjacentNodes(n int) AdjacentNodes

NewAdjacentNodes creates a new AdjacentNodes with N nodes with initially no connections.

func (AdjacentNodes) Connect

func (a AdjacentNodes) Connect(from, to int)

func (AdjacentNodes) ConnectRandomDirection

func (a AdjacentNodes) ConnectRandomDirection(from, to int) bool

func (AdjacentNodes) Validate added in v0.15.20

func (a AdjacentNodes) Validate() bool

type NetworkConfigFn

type NetworkConfigFn func(int) AdjacentNodes

NetworkConfigFn is a function that returns an AdjacentNodes for a given number of nodes.

type Node

type Node struct {
	Host              host.Host
	GetBootstrapPeers func() []peer.AddrInfo
}

type Nodes

type Nodes []Node

func BuildNetworks

func BuildNetworks(
	t *testing.T,
	adjacentNodes AdjacentNodes,
) Nodes

func (Nodes) JoinTopic

func (n Nodes) JoinTopic(
	t *testing.T,
	network *networks.Network,
	protocolID starknetp2p.Protocol,
	topicName string,
) []*libp2p.Topic

Jump to

Keyboard shortcuts

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