mirror of https://github.com/status-im/go-waku.git
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()
|
|
}
|