Skip to content

Commit

Permalink
make a few tests perform operations in two directions instead of one
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Sep 23, 2014
1 parent 7bc4fbf commit 7228786
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion routing/dht/dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,17 @@ func TestPing(t *testing.T) {
}

//Test that we can ping the node
ctx, _ := context.WithTimeout(context.Background(), 2*time.Millisecond)
ctx, _ := context.WithTimeout(context.Background(), 5*time.Millisecond)
err = dhtA.Ping(ctx, peerB)
if err != nil {
t.Fatal(err)
}

ctx, _ = context.WithTimeout(context.Background(), 5*time.Millisecond)
err = dhtB.Ping(ctx, peerA)
if err != nil {
t.Fatal(err)
}
}

func TestValueGetSet(t *testing.T) {
Expand Down Expand Up @@ -164,6 +170,15 @@ func TestValueGetSet(t *testing.T) {
t.Fatalf("Expected 'world' got '%s'", string(val))
}

ctxT, _ = context.WithTimeout(context.Background(), time.Second*2)
val, err = dhtB.GetValue(ctxT, "hello")
if err != nil {
t.Fatal(err)
}

if string(val) != "world" {
t.Fatalf("Expected 'world' got '%s'", string(val))
}
}

func TestProvides(t *testing.T) {
Expand Down

0 comments on commit 7228786

Please sign in to comment.