From e6bc0772ed4d34074652e6e397dd87363046321c Mon Sep 17 00:00:00 2001 From: Siraj Ravel Date: Sun, 14 Sep 2014 20:59:09 -0700 Subject: [PATCH 1/2] Test for getLocal method in DHT --- routing/dht/dht_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/routing/dht/dht_test.go b/routing/dht/dht_test.go index 3b8f7f7d117..68812669c85 100644 --- a/routing/dht/dht_test.go +++ b/routing/dht/dht_test.go @@ -179,6 +179,7 @@ func TestValueGetSet(t *testing.T) { if string(val) != "world" { t.Fatalf("Expected 'world' got '%s'", string(val)) } + } func TestProvides(t *testing.T) { @@ -206,6 +207,11 @@ func TestProvides(t *testing.T) { t.Fatal(err) } + _, err = dhts[3].getLocal(u.Key("hello")) + if err != nil { + t.Fatal(err) + } + err = dhts[3].Provide(u.Key("hello")) if err != nil { t.Fatal(err) From 0b5447a60a55220cc0b3a6c776924aa4c4fd41e7 Mon Sep 17 00:00:00 2001 From: Siraj Ravel Date: Sun, 14 Sep 2014 21:44:19 -0700 Subject: [PATCH 2/2] checking returned value --- routing/dht/dht_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/routing/dht/dht_test.go b/routing/dht/dht_test.go index 68812669c85..f5323086448 100644 --- a/routing/dht/dht_test.go +++ b/routing/dht/dht_test.go @@ -11,6 +11,7 @@ import ( swarm "github.com/jbenet/go-ipfs/swarm" u "github.com/jbenet/go-ipfs/util" + "bytes" "fmt" "time" ) @@ -207,8 +208,8 @@ func TestProvides(t *testing.T) { t.Fatal(err) } - _, err = dhts[3].getLocal(u.Key("hello")) - if err != nil { + bits, err := dhts[3].getLocal(u.Key("hello")) + if err != nil && bytes.Equal(bits, []byte("world")) { t.Fatal(err) }