func releaseWaiters(group *sync.WaitGroup) {
	group.Done()
}
we use releaseWaiters to release a waitgroup and not panic if we don't use it
package gossip
import (
	"errors"
	"sync"
	"testing"
	"time"
	"github.com/libonomy/libonomy-p2p/log"
	"github.com/libonomy/libonomy-p2p/p2p/config"
	"github.com/libonomy/libonomy-p2p/p2p/p2pcrypto"
	"github.com/libonomy/libonomy-p2p/p2p/service"
	"github.com/libonomy/libonomy-p2p/priorityq"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)
type mockBaseNetwork struct {
	msgSentByPeer        map[string]uint32
	directInbox          chan service.DirectMessage
	gossipInbox          chan service.GossipMessage
	connSubs             []chan p2pcrypto.PublicKey
	discSubs             []chan p2pcrypto.PublicKey
	totalMsgCount        int
	processProtocolCount int
	msgMutex             sync.Mutex
	pcountwg             *sync.WaitGroup
	msgwg                *sync.WaitGroup
	lastMsg              []byte
	isMessageValid       bool
}
func newMockBaseNetwork() *mockBaseNetwork {
	return &mockBaseNetwork{
		make(map[string]uint32),
		make(chan service.DirectMessage, 30),
		make(chan service.GossipMessage, 30),
		make([]chan p2pcrypto.PublicKey, 0, 5),
		make([]chan p2pcrypto.PublicKey, 0, 5),
		0,
		0,
		sync.Mutex{},
		&sync.WaitGroup{},
		&sync.WaitGroup{},
		[]byte(nil),
		true,
	}
}
func (mbn *mockBaseNetwork) SendMessage(peerPubkey p2pcrypto.PublicKey, protocol string, payload []byte) error {
	mbn.msgMutex.Lock()
	mbn.lastMsg = payload
	mbn.msgSentByPeer[peerPubkey.String()]++
	mbn.totalMsgCount++
	mbn.msgMutex.Unlock()
	releaseWaiters(mbn.msgwg)
	return nil
}
func passOrDeadlock(t testing.TB, group *sync.WaitGroup) {
	ch := make(chan struct{})
	go func(ch chan struct{}, t testing.TB) {
		timer := time.NewTimer(time.Second * 3)
		for {
			select {
			case <-ch:
				return
			case <-timer.C:
				t.FailNow()  
			}
		}
	}(ch, t)
	group.Wait()
	close(ch)
}