mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-29 23:15:40 +00:00
4b1c188cf0
* 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
29 lines
462 B
Go
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()
|
|
}
|