mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
* 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>
26 lines
434 B
Go
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()
|
|
}
|
|
}
|