Skip to content

Commit

Permalink
fix(routing:dht) add ctx args
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Tiger Chow committed Sep 22, 2014
1 parent d64c5ce commit bc07e2b
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions routing/dht/dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ func TestPing(t *testing.T) {
defer dhtA.network.Close()
defer dhtB.network.Close()

_, err = dhtA.Connect(peerB)
_, err = dhtA.Connect(context.Background(), peerB)
if err != nil {
t.Fatal(err)
}

//Test that we can ping the node
err = dhtA.Ping(peerB, time.Second*2)
ctx, _ := context.WithTimeout(context.Background(), 2*time.Millisecond)
err = dhtA.Ping(ctx, peerB)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -145,7 +146,7 @@ func TestValueGetSet(t *testing.T) {
defer dhtA.network.Close()
defer dhtB.network.Close()

_, err = dhtA.Connect(peerB)
_, err = dhtA.Connect(context.Background(), peerB)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -178,17 +179,17 @@ func TestProvides(t *testing.T) {
}
}()

_, err := dhts[0].Connect(peers[1])
_, err := dhts[0].Connect(context.Background(), peers[1])
if err != nil {
t.Fatal(err)
}

_, err = dhts[1].Connect(peers[2])
_, err = dhts[1].Connect(context.Background(), peers[2])
if err != nil {
t.Fatal(err)
}

_, err = dhts[1].Connect(peers[3])
_, err = dhts[1].Connect(context.Background(), peers[3])
if err != nil {
t.Fatal(err)
}
Expand All @@ -203,7 +204,7 @@ func TestProvides(t *testing.T) {
t.Fatal(err)
}

err = dhts[3].Provide(u.Key("hello"))
err = dhts[3].Provide(context.Background(), u.Key("hello"))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -234,17 +235,17 @@ func TestProvidesAsync(t *testing.T) {
}
}()

_, err := dhts[0].Connect(peers[1])
_, err := dhts[0].Connect(context.Background(), peers[1])
if err != nil {
t.Fatal(err)
}

_, err = dhts[1].Connect(peers[2])
_, err = dhts[1].Connect(context.Background(), peers[2])
if err != nil {
t.Fatal(err)
}

_, err = dhts[1].Connect(peers[3])
_, err = dhts[1].Connect(context.Background(), peers[3])
if err != nil {
t.Fatal(err)
}
Expand All @@ -259,7 +260,7 @@ func TestProvidesAsync(t *testing.T) {
t.Fatal(err)
}

err = dhts[3].Provide(u.Key("hello"))
err = dhts[3].Provide(context.Background(), u.Key("hello"))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -290,17 +291,17 @@ func TestLayeredGet(t *testing.T) {
}
}()

_, err := dhts[0].Connect(peers[1])
_, err := dhts[0].Connect(context.Background(), peers[1])
if err != nil {
t.Fatalf("Failed to connect: %s", err)
}

_, err = dhts[1].Connect(peers[2])
_, err = dhts[1].Connect(context.Background(), peers[2])
if err != nil {
t.Fatal(err)
}

_, err = dhts[1].Connect(peers[3])
_, err = dhts[1].Connect(context.Background(), peers[3])
if err != nil {
t.Fatal(err)
}
Expand All @@ -310,7 +311,7 @@ func TestLayeredGet(t *testing.T) {
t.Fatal(err)
}

err = dhts[3].Provide(u.Key("hello"))
err = dhts[3].Provide(context.Background(), u.Key("hello"))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -342,17 +343,17 @@ func TestFindPeer(t *testing.T) {
}
}()

_, err := dhts[0].Connect(peers[1])
_, err := dhts[0].Connect(context.Background(), peers[1])
if err != nil {
t.Fatal(err)
}

_, err = dhts[1].Connect(peers[2])
_, err = dhts[1].Connect(context.Background(), peers[2])
if err != nil {
t.Fatal(err)
}

_, err = dhts[1].Connect(peers[3])
_, err = dhts[1].Connect(context.Background(), peers[3])
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit bc07e2b

Please sign in to comment.