test

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 13 Imported by: 22 modules, 21 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

This section is empty.

Functions

func AssertAddressesEqual

func AssertAddressesEqual(t *testing.T, exp, act []ma.Multiaddr)

func AssertNilError

func AssertNilError(t *testing.T, err error)

func ExpectError

func ExpectError(t *testing.T, err error, msg string)

func GenerateTestAddrs

func GenerateTestAddrs(n int) []ma.Multiaddr

func RandPeerID

func RandPeerID() (peer.ID, error)

func RandPeerIDFatal

func RandPeerIDFatal(t testing.TB) peer.ID

func RandTestKeyPair

func RandTestKeyPair(typ, bits int) (ci.PrivKey, ci.PubKey, error)

func SeededTestKeyPair

func SeededTestKeyPair(typ, bits int, seed int64) (ci.PrivKey, ci.PubKey, error)

Types

type MockClock added in v0.26.4

type MockClock struct {
	// contains filtered or unexported fields
}

func NewMockClock added in v0.26.4

func NewMockClock() *MockClock

func (*MockClock) AdvanceBy added in v0.26.4

func (c *MockClock) AdvanceBy(dur time.Duration)

func (*MockClock) InstantTimer added in v0.26.4

func (c *MockClock) InstantTimer(when time.Time) *mockInstantTimer

InstantTimer implements a timer that triggers at a fixed instant in time as opposed to after a fixed duration from the moment of creation/reset.

In test environments, when using a Timer which fires after a duration, there is a race between the goroutine moving time forward using `clock.Advanceby` and the goroutine resetting the timer by doing `timer.Reset(desiredInstant.Sub(time.Now()))`. The value of `desiredInstance.sub(time.Now())` is different depending on whether `clock.AdvanceBy` finishes before or after the timer reset.

func (*MockClock) Now added in v0.26.4

func (c *MockClock) Now() time.Time

func (*MockClock) Since added in v0.26.4

func (c *MockClock) Since(t time.Time) time.Duration

Since implements autorelay.ClockWithInstantTimer

Jump to

Keyboard shortcuts

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