mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-11-15 04:35:17 +00:00
26 lines
397 B
Go
26 lines
397 B
Go
package test
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"testing"
|
|
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
|
|
mh "github.com/multiformats/go-multihash"
|
|
)
|
|
|
|
func RandPeerID() (peer.ID, error) {
|
|
buf := make([]byte, 16)
|
|
rand.Read(buf)
|
|
h, _ := mh.Sum(buf, mh.SHA2_256, -1)
|
|
return peer.ID(h), nil
|
|
}
|
|
|
|
func RandPeerIDFatal(t testing.TB) peer.ID {
|
|
p, err := RandPeerID()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return p
|
|
}
|