Commit b7660f5f authored by Brian Tiger Chow's avatar Brian Tiger Chow

test(bitswap:testnet) shuffle the providers

to avoid letting client rely on order for correctness
parent e040a00a
......@@ -2,6 +2,7 @@ package bitswap
import (
"errors"
"math/rand"
"sync"
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
......@@ -58,6 +59,12 @@ func (rs *hashTable) Providers(k u.Key) []*peer.Peer {
for _, peer := range peerset {
ret = append(ret, peer)
}
for i := range ret {
j := rand.Intn(i + 1)
ret[i], ret[j] = ret[j], ret[i]
}
return ret
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment