Skip to content

Commit

Permalink
Add some sanity tests for the misdial failure
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Jun 9, 2016
1 parent 7d5ba11 commit a84006a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions routing/dht/dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,24 @@ func setupDHTS(ctx context.Context, n int, t *testing.T) ([]ma.Multiaddr, []peer
dhts := make([]*IpfsDHT, n)
peers := make([]peer.ID, n)

sanityAddrsMap := make(map[string]struct{})
sanityPeersMap := make(map[string]struct{})

for i := 0; i < n; i++ {
dhts[i] = setupDHT(ctx, t)
peers[i] = dhts[i].self
addrs[i] = dhts[i].peerstore.Addrs(dhts[i].self)[0]

if _, lol := sanityAddrsMap[addrs[i].String()]; lol {
t.Fatal("While setting up DHTs address got dumplicated.")
} else {
sanityAddrsMap[addrs[i].String()] = struct{}{}
}
if _, lol := sanityPeersMap[peers[i].String()]; lol {
t.Fatal("While setting up DHTs peerid got dumplicated.")
} else {
sanityPeersMap[peers[i].String()] = struct{}{}
}
}

return addrs, peers, dhts
Expand Down

0 comments on commit a84006a

Please sign in to comment.