Commit b797ed11 authored by Aarsh Shah's avatar Aarsh Shah

added a test for the failure scenario

parent ba93cb36
......@@ -79,7 +79,7 @@ func (rt *RoutingTable) GenRandPeerID(bucketID int) (peer.ID, error) {
}
// should give up after a fixed number of attempts so we don't take up too much time/cpu
for i := 0; i < 200; i++ {
for i := 0; i < 1000; i++ {
peerID, err := randPeerID()
if err != nil {
log.Debugf("failed to generate random peerID in bucket %d, error is %+v", bucketID, err)
......
......@@ -81,6 +81,12 @@ func TestGenRandPeerID(t *testing.T) {
}
}
// test error case
peerID, err := rt.GenRandPeerID(-1)
if err != ErrGenRandPeerIDFailed || len(peerID) != 0 {
t.Fatalf("should have got err ErrGenRandPeerIDFailed for bucketID -1")
}
}
func TestTableCallbacks(t *testing.T) {
......
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