mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-04-24 14:22:13 +00:00
fixed tests
This commit is contained in:
parent
bbe64f67cf
commit
1eb70081cb
23
dht_test.go
23
dht_test.go
@ -774,19 +774,17 @@ func TestRefresh(t *testing.T) {
|
||||
ctxT, cancelT := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancelT()
|
||||
|
||||
go func() {
|
||||
for ctxT.Err() == nil {
|
||||
bootstrap(t, ctxT, dhts)
|
||||
for ctxT.Err() == nil {
|
||||
bootstrap(t, ctxT, dhts)
|
||||
|
||||
// wait a bit.
|
||||
select {
|
||||
case <-time.After(50 * time.Millisecond):
|
||||
continue // being explicit
|
||||
case <-ctxT.Done():
|
||||
return
|
||||
}
|
||||
// wait a bit.
|
||||
select {
|
||||
case <-time.After(50 * time.Millisecond):
|
||||
continue // being explicit
|
||||
case <-ctxT.Done():
|
||||
return
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
waitForWellFormedTables(t, dhts, 7, 10, 10*time.Second)
|
||||
cancelT()
|
||||
@ -1415,6 +1413,9 @@ func testFindPeerQuery(t *testing.T,
|
||||
connectNoSync(t, ctx, guy, others[i])
|
||||
}
|
||||
|
||||
// give some time for things to settle down
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
for _, d := range dhts {
|
||||
if err := <-d.RefreshRoutingTable(); err != nil {
|
||||
t.Fatal(err)
|
||||
|
12
ext_test.go
12
ext_test.go
@ -9,21 +9,23 @@ import (
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/libp2p/go-libp2p-core/peerstore"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
"github.com/libp2p/go-libp2p-core/routing"
|
||||
|
||||
pb "github.com/libp2p/go-libp2p-kad-dht/pb"
|
||||
record "github.com/libp2p/go-libp2p-record"
|
||||
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
|
||||
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||
|
||||
ggio "github.com/gogo/protobuf/io"
|
||||
u "github.com/ipfs/go-ipfs-util"
|
||||
pb "github.com/libp2p/go-libp2p-kad-dht/pb"
|
||||
record "github.com/libp2p/go-libp2p-record"
|
||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// Test that one hung request to a peer doesn't prevent another request
|
||||
// using that same peer from obeying its context.
|
||||
func TestHungRequest(t *testing.T) {
|
||||
t.Skip("extremely flaky")
|
||||
ctx := context.Background()
|
||||
mn, err := mocknet.FullMeshConnected(ctx, 2)
|
||||
if err != nil {
|
||||
@ -41,6 +43,8 @@ func TestHungRequest(t *testing.T) {
|
||||
defer s.Reset()
|
||||
<-ctx.Done()
|
||||
})
|
||||
|
||||
require.NoError(t, hosts[0].Peerstore().AddProtocols(hosts[1].ID(), protocol.ConvertToStrings(d.protocols)...))
|
||||
d.peerFound(ctx, hosts[1].ID())
|
||||
|
||||
ctx1, cancel1 := context.WithTimeout(ctx, 1*time.Second)
|
||||
|
Loading…
x
Reference in New Issue
Block a user