ext_test: bitten by mocknet ordering
mocknet indeterminism screwed this test up. that's twice it's bitten us. let's not let it do it a third time. cc @briantigerchow omg.
Juan Batiz-Benet committed
Jan 5, 2015 at 04:36 UTC
ce367ee76ed585cc216791848c8aeab9fa82f503
1 file changed
+6
-9
routing/dht/ext_test.go
+6
-9
@@ -32,11 +32,10 @@ func TestGetFailures(t *testing.T) {
32
t.Fatal(err)
33
}
34
hosts := mn.Hosts()
35
- peers := mn.Peers()
35
36
tsds := dssync.MutexWrap(ds.NewMapDatastore())
37
d := NewDHT(ctx, hosts[0], tsds)
39
- d.Update(ctx, peers[1])
38
+ d.Update(ctx, hosts[1].ID())
39
40
// u.POut("NotFound Test\n")
41
// Reply with failures to every message
@@ -147,12 +146,11 @@ func TestNotFound(t *testing.T) {
146
t.Fatal(err)
147
}
148
hosts := mn.Hosts()
150
- peers := mn.Peers()
149
tsds := dssync.MutexWrap(ds.NewMapDatastore())
150
d := NewDHT(ctx, hosts[0], tsds)
151
154
- for _, p := range peers {
155
- d.Update(ctx, p)
152
+ for _, p := range hosts {
153
+ d.Update(ctx, p.ID())
154
}
155
156
// Reply with random peers to every message
@@ -175,7 +173,7 @@ func TestNotFound(t *testing.T) {
173
174
ps := []peer.PeerInfo{}
175
for i := 0; i < 7; i++ {
178
- p := peers[rand.Intn(len(peers))]
176
+ p := hosts[rand.Intn(len(hosts))].ID()
177
pi := host.Peerstore().PeerInfo(p)
178
ps = append(ps, pi)
179
}
@@ -220,13 +218,12 @@ func TestLessThanKResponses(t *testing.T) {
218
t.Fatal(err)
219
}
220
hosts := mn.Hosts()
223
- peers := mn.Peers()
221
222
tsds := dssync.MutexWrap(ds.NewMapDatastore())
223
d := NewDHT(ctx, hosts[0], tsds)
224
225
for i := 1; i < 5; i++ {
229
- d.Update(ctx, peers[i])
226
+ d.Update(ctx, hosts[i].ID())
227
}
228
229
// Reply with random peers to every message
@@ -245,7 +242,7 @@ func TestLessThanKResponses(t *testing.T) {
242
243
switch pmes.GetType() {
244
case pb.Message_GET_VALUE:
248
- pi := host.Peerstore().PeerInfo(peers[1])
245
+ pi := host.Peerstore().PeerInfo(hosts[1].ID())
246
resp := &pb.Message{
247
Type: pmes.Type,
248
CloserPeers: pb.PeerInfosToPBPeers(d.host.Network(), []peer.PeerInfo{pi}),