mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 22:49:13 +08:00

I think it's time to move a lot of the peer-to-peer networking but-not-ipfs-specific things into its own package: p2p. This could in the future be split off into its own library. The first thing to go is the peer.
26 lines
487 B
Go
26 lines
487 B
Go
package core
|
|
|
|
import (
|
|
"testing"
|
|
|
|
peer "github.com/jbenet/go-ipfs/p2p/peer"
|
|
testutil "github.com/jbenet/go-ipfs/util/testutil"
|
|
)
|
|
|
|
func TestSubsetWhenMaxIsGreaterThanLengthOfSlice(t *testing.T) {
|
|
var ps []peer.PeerInfo
|
|
sizeofSlice := 100
|
|
for i := 0; i < sizeofSlice; i++ {
|
|
pid, err := testutil.RandPeerID()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
ps = append(ps, peer.PeerInfo{ID: pid})
|
|
}
|
|
out := randomSubsetOfPeers(ps, 2*sizeofSlice)
|
|
if len(out) != len(ps) {
|
|
t.Fail()
|
|
}
|
|
}
|