Categorygithub.com/RTradeLtd/go-libp2p-testutils
modulepackage
1.0.0
Repository: https://github.com/rtradeltd/go-libp2p-testutils.git
Documentation: pkg.go.dev

# 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

# Functions

NewDatastore is used to create a new in memory datastore.
NewKeystore is used to return a new in memory keystore.
NewLibp2pHostAndDHT is used to create a new libp2p host and an unbootstrapped dht.
NewLogger is used to return a test zap logger.
NewMultiaddr is used to create a new multiaddress.
NewPeerstore is ued to generate an in-memory peerstore.
NewPrivateKey is used to create a new private key for testing purposes.
NewSecret is used to generate a secret used to secure private libp2p connections.

# Variables

EncodedPK is a hex encoded key to be reused across tests.