package test
import "github.com/libp2p/go-libp2p/core/test"
Index ¶
- func AssertAddressesEqual(t *testing.T, exp, act []ma.Multiaddr)
- func AssertNilError(t *testing.T, err error)
- func ExpectError(t *testing.T, err error, msg string)
- func GenerateTestAddrs(n int) []ma.Multiaddr
- func RandPeerID() (peer.ID, error)
- func RandPeerIDFatal(t testing.TB) peer.ID
- func RandTestKeyPair(typ, bits int) (ci.PrivKey, ci.PubKey, error)
- func SeededTestKeyPair(typ, bits int, seed int64) (ci.PrivKey, ci.PubKey, error)
- type MockClock
Functions ¶
func AssertAddressesEqual ¶
func AssertNilError ¶
func ExpectError ¶
func GenerateTestAddrs ¶
func RandPeerID ¶
func RandPeerIDFatal ¶
func RandTestKeyPair ¶
func SeededTestKeyPair ¶
Types ¶
type MockClock ¶
type MockClock struct {
// contains filtered or unexported fields
}
func NewMockClock ¶
func NewMockClock() *MockClock
func (*MockClock) AdvanceBy ¶
func (*MockClock) InstantTimer ¶
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 ¶
func (*MockClock) Since ¶
Since implements autorelay.ClockWithInstantTimer
Source Files ¶
addrs.go crypto.go errors.go mockclock.go peer.go
- Version
- v0.42.0 (latest)
- Published
- Jun 18, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 1 week ago –
Tools for package owners.