testutils

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

README

go-libp2p-testutils

codecov

go-libp2p-testutils provides helpful utility functions useful when needing to write tests for libp2p/ipfs applications.

Features

  • Create libp2p host
  • Create libp2p dht
  • Create private key
  • Create libp2p private network secret
  • Create in-memory peerstore
  • Create in-memory datastore
  • Create a multiaddr
  • Create a zap test logger
  • Create an in-memory keystore

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// EncodedPK is a hex encoded key
	// to be reused across tests
	EncodedPK = "" /* 136-byte string literal not displayed */
)

Functions

func NewDatastore

func NewDatastore(t *testing.T) datastore.Batching

NewDatastore is used to create a new in memory datastore

func NewKeystore

func NewKeystore(t *testing.T) keystore.Keystore

NewKeystore is used to return a new in memory keystore

func NewLibp2pHostAndDHT

func NewLibp2pHostAndDHT(
	ctx context.Context,
	t *testing.T,
	logger *zap.Logger,
	ds datastore.Batching,
	ps peerstore.Peerstore,
	pk crypto.PrivKey,
	addrs []multiaddr.Multiaddr,
	secret []byte) (host.Host, *dht.IpfsDHT)

NewLibp2pHostAndDHT is used to create a new libp2p host and an unbootstrapped dht

func NewLogger

func NewLogger(t *testing.T) *zap.SugaredLogger

NewLogger is used to return a test zap logger

func NewMultiaddr

func NewMultiaddr(t *testing.T) multiaddr.Multiaddr

NewMultiaddr is used to create a new multiaddress

func NewPeerstore

func NewPeerstore(t *testing.T) peerstore.Peerstore

NewPeerstore is ued to generate an in-memory peerstore

func NewPrivateKey

func NewPrivateKey(t *testing.T) crypto.PrivKey

NewPrivateKey is used to create a new private key for testing purposes

func NewSecret

func NewSecret(t *testing.T) []byte

NewSecret is used to generate a secret used to secure private libp2p connections

Types

This section is empty.

Jump to

Keyboard shortcuts

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