Ver Fonte

:robot: Avoid races in tests

Ettore Di Giacinto há 3 anos atrás
pai
commit
5e34cd15a3
1 ficheiros alterados com 8 adições e 6 exclusões
  1. 8 6
      pkg/services/services_test.go

+ 8 - 6
pkg/services/services_test.go

@@ -60,11 +60,6 @@ var _ = Describe("Expose services", func() {
 	l := node.Logger(logg)
 	l := node.Logger(logg)
 	serviceUUID := "test"
 	serviceUUID := "test"
 
 
-	e2, _ := node.New(
-		node.WithNetworkService(ConnectNetworkService(5*time.Second, serviceUUID, "127.0.0.1:9999")),
-		node.WithDiscoveryInterval(10*time.Second),
-		node.FromBase64(true, true, token), node.WithStore(&blockchain.MemoryStore{}), l)
-
 	Context("Service sharing", func() {
 	Context("Service sharing", func() {
 		It("expose services and can connect to them", func() {
 		It("expose services and can connect to them", func() {
 			ctx, cancel := context.WithCancel(context.Background())
 			ctx, cancel := context.WithCancel(context.Background())
@@ -79,7 +74,14 @@ var _ = Describe("Expose services", func() {
 
 
 			e.Start(ctx)
 			e.Start(ctx)
 
 
-			go e2.Start(ctx)
+			go func() {
+				e2, _ := node.New(
+					node.WithNetworkService(ConnectNetworkService(5*time.Second, serviceUUID, "127.0.0.1:9999")),
+					node.WithDiscoveryInterval(10*time.Second),
+					node.FromBase64(true, true, token), node.WithStore(&blockchain.MemoryStore{}), l)
+
+				e2.Start(ctx)
+			}()
 
 
 			Eventually(func() string {
 			Eventually(func() string {
 				return get("http://127.0.0.1:9999")
 				return get("http://127.0.0.1:9999")