@@ -12,7 +12,9 @@ import (
1212 "github.com/libp2p/go-libp2p-core/network"
1313 "github.com/libp2p/go-libp2p-core/peer"
1414 dht "github.com/libp2p/go-libp2p-kad-dht"
15+ test "github.com/libp2p/go-libp2p-kad-dht/internal/testing"
1516 peerstore "github.com/libp2p/go-libp2p-peerstore"
17+ record "github.com/libp2p/go-libp2p-record"
1618 swarmt "github.com/libp2p/go-libp2p-swarm/testing"
1719 bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
1820)
@@ -108,11 +110,9 @@ func connect(ctx context.Context, t *testing.T, a, b *dht.IpfsDHT) {
108110 t .Fatal ("no addresses for connection." )
109111 }
110112 a .Host ().Peerstore ().AddAddrs (bid , baddr , peerstore .TempAddrTTL )
111- fmt .Fprintf (os .Stderr , "gonna connect.\n " )
112113 if err := a .Host ().Connect (ctx , peer.AddrInfo {ID : bid }); err != nil {
113114 t .Fatal (err )
114115 }
115- fmt .Fprintf (os .Stderr , "gonn wait\n " )
116116 wait (ctx , t , a , b )
117117}
118118
@@ -231,15 +231,15 @@ func TestValueGetSet(t *testing.T) {
231231 defer wan .Close ()
232232 defer lan .Close ()
233233
234- err := d .PutValue (ctx , "/v/hello" , []byte ("world " ))
234+ err := d .PutValue (ctx , "/v/hello" , []byte ("valid " ))
235235 if err != nil {
236236 t .Fatal (err )
237237 }
238238 val , err := wan .GetValue (ctx , "/v/hello" )
239239 if err != nil {
240240 t .Fatal (err )
241241 }
242- if string (val ) != "world " {
242+ if string (val ) != "valid " {
243243 t .Fatal ("failed to get expected string." )
244244 }
245245
@@ -258,7 +258,10 @@ func TestSearchValue(t *testing.T) {
258258 defer wan .Close ()
259259 defer lan .Close ()
260260
261- err := wan .PutValue (ctx , "/v/hello" , []byte ("world" ), )
261+ d .WAN .Validator .(record.NamespacedValidator )["v" ] = test.TestValidator {}
262+ d .LAN .Validator .(record.NamespacedValidator )["v" ] = test.TestValidator {}
263+
264+ err := wan .PutValue (ctx , "/v/hello" , []byte ("valid" ))
262265
263266 valCh , err := d .SearchValue (ctx , "/v/hello" , dht .Quorum (0 ))
264267 if err != nil {
@@ -267,8 +270,8 @@ func TestSearchValue(t *testing.T) {
267270
268271 select {
269272 case v := <- valCh :
270- if string (v ) != "world " {
271- t .Errorf ("expected 'world ', got '%s'" , string (v ))
273+ if string (v ) != "valid " {
274+ t .Errorf ("expected 'valid ', got '%s'" , string (v ))
272275 }
273276 case <- ctx .Done ():
274277 t .Fatal (ctx .Err ())
@@ -280,10 +283,13 @@ func TestSearchValue(t *testing.T) {
280283 }
281284
282285 select {
283- case v := <- valCh :
286+ case v , ok := <- valCh :
284287 if string (v ) != "newer" {
285288 t .Errorf ("expected 'newer', got '%s'" , string (v ))
286289 }
290+ if ! ok {
291+ t .Errorf ("chan closed early" )
292+ }
287293 case <- ctx .Done ():
288294 t .Fatal (ctx .Err ())
289295 }
0 commit comments