use fewer peers in connmgr test

This commit is contained in:
Yusef Napora 2020-05-15 15:53:51 -04:00 committed by vyzo
parent 2f9a678f2e
commit 2f4028acb2

View File

@ -19,6 +19,7 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) {
defer cancel() defer cancel()
oldGossipSubD := GossipSubD oldGossipSubD := GossipSubD
oldGossipSubDlo := GossipSubDlo
oldGossipSubDHi := GossipSubDhi oldGossipSubDHi := GossipSubDhi
oldGossipSubConnTagDecayInterval := GossipSubConnTagDecayInterval oldGossipSubConnTagDecayInterval := GossipSubConnTagDecayInterval
oldGossipSubConnTagMessageDeliveryCap := GossipSubConnTagMessageDeliveryCap oldGossipSubConnTagMessageDeliveryCap := GossipSubConnTagMessageDeliveryCap
@ -26,8 +27,9 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) {
oldSilencePeriod := connmgr.SilencePeriod oldSilencePeriod := connmgr.SilencePeriod
// set the gossipsub D parameters low, so that we have some peers outside the mesh // set the gossipsub D parameters low, so that we have some peers outside the mesh
GossipSubDlo = 4
GossipSubD = 4 GossipSubD = 4
GossipSubDhi = 5 GossipSubDhi = 4
// also set the tag decay interval so we don't have to wait forever for tests // also set the tag decay interval so we don't have to wait forever for tests
GossipSubConnTagDecayInterval = time.Second GossipSubConnTagDecayInterval = time.Second
@ -39,6 +41,7 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) {
// reset globals after test // reset globals after test
defer func() { defer func() {
GossipSubD = oldGossipSubD GossipSubD = oldGossipSubD
GossipSubDlo = oldGossipSubDlo
GossipSubDhi = oldGossipSubDHi GossipSubDhi = oldGossipSubDHi
GossipSubConnTagDecayInterval = oldGossipSubConnTagDecayInterval GossipSubConnTagDecayInterval = oldGossipSubConnTagDecayInterval
GossipSubConnTagMessageDeliveryCap = oldGossipSubConnTagMessageDeliveryCap GossipSubConnTagMessageDeliveryCap = oldGossipSubConnTagMessageDeliveryCap
@ -51,9 +54,9 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) {
Clock: decayClock, Clock: decayClock,
} }
nHonest := 20 nHonest := 10
nSquatter := 60 nSquatter := 30
connLimit := 30 connLimit := 15
connmgrs := make([]*connmgr.BasicConnMgr, nHonest) connmgrs := make([]*connmgr.BasicConnMgr, nHonest)
honestHosts := make([]host.Host, nHonest) honestHosts := make([]host.Host, nHonest)
@ -108,7 +111,7 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) {
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
// have all the hosts publish enough messages to ensure that they get some delivery credit // have all the hosts publish enough messages to ensure that they get some delivery credit
nMessages := 1000 nMessages := GossipSubConnTagMessageDeliveryCap * 2
for _, ps := range psubs { for _, ps := range psubs {
for i := 0; i < nMessages; i++ { for i := 0; i < nMessages; i++ {
ps.Publish(topic, []byte("hello")) ps.Publish(topic, []byte("hello"))
@ -159,7 +162,7 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) {
nHonestConns++ nHonestConns++
} }
} }
if nDishonestConns > 10 { if nDishonestConns > 5 {
t.Errorf("expected most dishonest conns to be pruned, have %d", nDishonestConns) t.Errorf("expected most dishonest conns to be pruned, have %d", nDishonestConns)
} }
if nHonestConns != nHonest-1 { if nHonestConns != nHonest-1 {