From 1aff8360043e512f40ae96834ebcd0c141019723 Mon Sep 17 00:00:00 2001 From: Fabio Barone Date: Wed, 6 Mar 2019 11:04:58 -0500 Subject: [PATCH] swarm/network/stream: only count first iteration of subscriptions --- swarm/network/stream/streamer_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/swarm/network/stream/streamer_test.go b/swarm/network/stream/streamer_test.go index b9f5a29ac0..a82f888edb 100644 --- a/swarm/network/stream/streamer_test.go +++ b/swarm/network/stream/streamer_test.go @@ -1189,7 +1189,7 @@ func TestGetSubscriptionsRPC(t *testing.T) { // arbitrarily set to 4 nodeCount := 4 // set the syncUpdateDelay for sync registrations to start - syncUpdateDelay := 800 * time.Millisecond + syncUpdateDelay := 200 * time.Millisecond // run with more nodes if `longrunning` flag is set if *longrunning { nodeCount = 64 @@ -1207,7 +1207,12 @@ func TestGetSubscriptionsRPC(t *testing.T) { // we use this subscriptionFunc for this test: just increases count and calls the actual subscription subscriptionFunc = func(r *Registry, p *network.Peer, bin uint8, subs map[enode.ID]map[Stream]struct{}) bool { - expectedMsgCount.inc() + // syncing starts after syncUpdateDelay and loops after that Duration; we only want to count at the first iteration + // in the first iteration, subs will be empty (no existing subscriptions), thus we can use this check + // this avoids flakyness + if len(subs) == 0 { + expectedMsgCount.inc() + } doRequestSubscription(r, p, bin, subs) return true }