Skip to content

Commit

Permalink
check and perform GC for testing when connections are deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
murali-reddy committed Oct 9, 2019
1 parent 4727318 commit 786d6fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 1 addition & 3 deletions gossip_test.go
Expand Up @@ -6,7 +6,6 @@ import (
"log"
"sync"
"testing"
"time"

"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -67,8 +66,6 @@ func sendPendingGossip(routers ...*Router) {
sentSomething = router.sendPendingGossip() || sentSomething
}
}
// Allow topology to propagate
time.Sleep(1 * time.Second)
}

func addTestGossipConnection(r1, r2 *Router) {
Expand Down Expand Up @@ -159,6 +156,7 @@ func TestGossipTopology(t *testing.T) {
// Drop the connection from 1 to 3
r1.DeleteTestGossipConnection(r3)
sendPendingGossip(r1, r2, r3)
forcePendingGC(r1, r2, r3)
checkTopology(t, r1, r1.tp(r2), r2.tp(r1))
checkTopology(t, r2, r1.tp(r2), r2.tp(r1))
// r3 still thinks r1 has a connection to it
Expand Down
13 changes: 13 additions & 0 deletions peer_test.go
Expand Up @@ -13,3 +13,16 @@ func TestPeerRoutes(t *testing.T) {
func TestPeerForEachConnectedPeer(t *testing.T) {
t.Skip("TODO")
}

func forcePendingGC(routers ...*Router) {
for _, router := range routers {
router.Peers.Lock()
if router.Peers.pendingGC {
var pending peersPendingNotifications
router.Peers.garbageCollect(&pending)
router.Peers.unlockAndNotify(&pending)
} else {
router.Peers.Unlock()
}
}
}

0 comments on commit 786d6fb

Please sign in to comment.