9
9
dht "github.com/libp2p/go-libp2p-kad-dht"
10
10
"github.com/libp2p/go-libp2p-kad-dht/internal"
11
11
test "github.com/libp2p/go-libp2p-kad-dht/internal/testing"
12
+ kb "github.com/libp2p/go-libp2p-kbucket"
12
13
record "github.com/libp2p/go-libp2p-record"
13
14
"github.com/libp2p/go-libp2p/core/host"
14
15
"github.com/libp2p/go-libp2p/core/peer"
@@ -119,7 +120,7 @@ func connect(ctx context.Context, t *testing.T, a, b *dht.IpfsDHT) {
119
120
if len (baddr ) == 0 {
120
121
t .Fatal ("no addresses for connection." )
121
122
}
122
- a .Host ().Peerstore ().AddAddrs (bid , baddr , peerstore .TempAddrTTL )
123
+ a .Host ().Peerstore ().AddAddrs (bid , baddr , peerstore .AddressTTL )
123
124
if err := a .Host ().Connect (ctx , peer.AddrInfo {ID : bid }); err != nil {
124
125
t .Fatal (err )
125
126
}
@@ -179,6 +180,7 @@ func setupTier(ctx context.Context, t *testing.T) (*DHT, *dht.IpfsDHT, *dht.Ipfs
179
180
}
180
181
hlprs [1 ].allow = lan .PeerID ()
181
182
connect (ctx , t , d .LAN , lan )
183
+ connect (ctx , t , lan , d .LAN )
182
184
183
185
return d , wan , lan
184
186
}
@@ -285,7 +287,13 @@ func TestSearchValue(t *testing.T) {
285
287
d .WAN .Validator .(record.NamespacedValidator )["v" ] = test.TestValidator {}
286
288
d .LAN .Validator .(record.NamespacedValidator )["v" ] = test.TestValidator {}
287
289
288
- _ = wan .PutValue (ctx , "/v/hello" , []byte ("valid" ))
290
+ err := wan .PutValue (ctx , "/v/hello" , []byte ("valid" ))
291
+ // it is expected that we get an ErrLookupFailure here, because wan doesn't
292
+ // have any peers in its routing table (d.WAN is a client). this operation
293
+ // still puts the record in wan local datastore, which is what we want.
294
+ if err != kb .ErrLookupFailure {
295
+ t .Error ("error putting value to wan DHT:" , err )
296
+ }
289
297
290
298
valCh , err := d .SearchValue (ctx , "/v/hello" , dht .Quorum (0 ))
291
299
if err != nil {
@@ -312,7 +320,7 @@ func TestSearchValue(t *testing.T) {
312
320
313
321
err = lan .PutValue (ctx , "/v/hello" , []byte ("newer" ))
314
322
if err != nil {
315
- t .Error (err )
323
+ t .Error ("error putting value to lan DHT:" , err )
316
324
}
317
325
318
326
valCh , err = d .SearchValue (ctx , "/v/hello" , dht .Quorum (0 ))
0 commit comments