Skip to content

Commit

Permalink
fix: decrease tests noise, update kbucket and fix fixRTIUfNeeded
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumemichel authored and Jorropo committed Jun 15, 2023
1 parent cbe39cd commit 2eee853
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
5 changes: 4 additions & 1 deletion dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,10 @@ func (dht *IpfsDHT) rtPeerLoop() {
// peer not added.
continue
}
if !newlyAdded {
if newlyAdded {
// peer was added to the RT, it can now be fixed if needed.
dht.fixRTIfNeeded()
} else {
// the peer is already in our RT, but we just successfully queried it and so let's give it a
// bump on the query time so we don't ping it too soon for a liveliness check.
dht.routingTable.UpdateLastSuccessfulOutboundQueryAt(p, time.Now())
Expand Down
6 changes: 1 addition & 5 deletions dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ func TestValueGetSet(t *testing.T) {
defer dhts[i].host.Close()
}

t.Log("before connect")
connect(t, ctx, dhts[0], dhts[1])

t.Log("adding value on: ", dhts[0].self)
Expand All @@ -290,13 +289,11 @@ func TestValueGetSet(t *testing.T) {
if err != nil {
t.Fatal(err)
}
t.Log("after get value")

if string(val) != "world" {
t.Fatalf("Expected 'world' got '%s'", string(val))
}

t.Log("late connect")
connect(t, ctx, dhts[2], dhts[0])
connect(t, ctx, dhts[2], dhts[1])

Expand All @@ -319,7 +316,6 @@ func TestValueGetSet(t *testing.T) {
t.Fatalf("Expected 'world' got '%s'", string(val))
}

t.Log("very late connect")
for _, d := range dhts[:3] {
connect(t, ctx, dhts[3], d)
}
Expand Down Expand Up @@ -632,7 +628,7 @@ func checkForWellFormedTablesOnce(t *testing.T, dhts []*IpfsDHT, minPeers, avgPe
rtlen := dht.routingTable.Size()
totalPeers += rtlen
if minPeers > 0 && rtlen < minPeers {
t.Logf("routing table for %s only has %d peers (should have >%d)", dht.self, rtlen, minPeers)
//t.Logf("routing table for %s only has %d peers (should have >%d)", dht.self, rtlen, minPeers)
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/ipfs/go-detect-race v0.0.1
github.com/ipfs/go-log v1.0.5
github.com/libp2p/go-libp2p v0.27.6
github.com/libp2p/go-libp2p-kbucket v0.6.3-0.20230615004129-e99cd472ed1e
github.com/libp2p/go-libp2p-kbucket v0.6.3
github.com/libp2p/go-libp2p-record v0.2.0
github.com/libp2p/go-libp2p-routing-helpers v0.7.0
github.com/libp2p/go-libp2p-testing v0.12.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ github.com/libp2p/go-libp2p-asn-util v0.3.0/go.mod h1:B1mcOrKUE35Xq/ASTmQ4tN3LNz
github.com/libp2p/go-libp2p-core v0.2.4/go.mod h1:STh4fdfa5vDYr0/SzYYeqnt+E6KfEV5VxfIrm0bcI0g=
github.com/libp2p/go-libp2p-core v0.3.0/go.mod h1:ACp3DmS3/N64c2jDzcV429ukDpicbL6+TrrxANBjPGw=
github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio=
github.com/libp2p/go-libp2p-kbucket v0.6.3-0.20230615004129-e99cd472ed1e h1:E5ZSk+DxxsXoszjKZYtZBJoQ6LnwGCjq4zVIINZaaT4=
github.com/libp2p/go-libp2p-kbucket v0.6.3-0.20230615004129-e99cd472ed1e/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0=
github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0=
github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0=
github.com/libp2p/go-libp2p-peerstore v0.1.4/go.mod h1:+4BDbDiiKf4PzpANZDAT+knVdLxvqh7hXOujessqdzs=
github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0=
github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk=
Expand Down
1 change: 0 additions & 1 deletion subscriber_notifee.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func handlePeerChangeEvent(dht *IpfsDHT, p peer.ID) {
return
} else if valid {
dht.peerFound(p)
dht.fixRTIfNeeded()
} else {
dht.peerStoppedDHT(p)
}
Expand Down

0 comments on commit 2eee853

Please sign in to comment.