提交 72287869 作者: Jeromy

make a few tests perform operations in two directions instead of one

上级 7bc4fbfa
...@@ -115,11 +115,17 @@ func TestPing(t *testing.T) { ...@@ -115,11 +115,17 @@ func TestPing(t *testing.T) {
} }
//Test that we can ping the node //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) err = dhtA.Ping(ctx, peerB)
if err != nil { if err != nil {
t.Fatal(err) 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) { func TestValueGetSet(t *testing.T) {
...@@ -164,6 +170,15 @@ func TestValueGetSet(t *testing.T) { ...@@ -164,6 +170,15 @@ func TestValueGetSet(t *testing.T) {
t.Fatalf("Expected 'world' got '%s'", string(val)) 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) { func TestProvides(t *testing.T) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论