kubo/core/bootstrap/bootstrap_test.go
Lucas Molas 63561f3baf
feat(bootstrap): save connected peers as backup bootstrap peers (#8856)
* feat(bootstrap): save connected peers as backup temporary bootstrap ones
* fix: do not add duplicated oldSavedPeers, not using tags, reuse
randomizeList
* test: add regression test
* chore: add changelog

---------

Co-authored-by: Henrique Dias <hacdias@gmail.com>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
2023-05-25 14:39:49 +02:00

26 lines
434 B
Go

package bootstrap
import (
"testing"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/test"
)
func TestRandomizeAddressList(t *testing.T) {
var ps []peer.AddrInfo
sizeofSlice := 10
for i := 0; i < sizeofSlice; i++ {
pid, err := test.RandPeerID()
if err != nil {
t.Fatal(err)
}
ps = append(ps, peer.AddrInfo{ID: pid})
}
out := randomizeList(ps)
if len(out) != len(ps) {
t.Fail()
}
}