go-waku/waku/v2/protocol/common_service_test.go
harsh jain 4b1c188cf0
feat: add common protocol design (#724)
* feat: add common protocol design

* fix: remove redundant vars

* fix: use AppDesign's ctx

* refactor: relay, add AppDesign

* feat: changes for suggestions

* test: commonService start/stop execution

* fix: lint error

* nit: add comments
2023-09-13 12:18:44 +07:00

29 lines
462 B
Go

package protocol
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()
}