go-waku/waku/v2/service/common_service_test.go
Prem Chaitanya Prathi 3226def4cf
feat: On Demand Peer Discovery based on shard and service (#834)
* refactor discovery and common service to separate package to remove package inter-dependencies

* relay on-demand discovery ,use proto to enr field mapping

* chore: no need to dial discovered peers as peermanager already does that

* on demand discovery for service peers during peer selection

* identify supported protocols for discovered peers and add to service slots

* fix: tests to use proper static sharding topics

* fix: random selection with default pubsubTopic

---------

Co-authored-by: richΛrd <info@richardramos.me>
2023-11-07 22:43:19 +05:30

29 lines
461 B
Go

package service
import (
"context"
"sync"
"testing"
)
// check if start and stop on common service works in random order
func TestCommonService(t *testing.T) {
s := NewCommonService()
wg := &sync.WaitGroup{}
for i := 0; i < 1000; i++ {
wg.Add(1)
if i%2 == 0 {
go func() {
wg.Done()
_ = s.Start(context.TODO(), func() error { return nil })
}()
} else {
go func() {
wg.Done()
go s.Stop(func() {})
}()
}
}
wg.Wait()
}