From 6f75c5d76060d2c5e91be4e22a0e060399218dbd Mon Sep 17 00:00:00 2001 From: Guilhem Fanton Date: Fri, 8 Mar 2019 17:52:52 +0100 Subject: [PATCH] fix(test): Fix provide inside a goroutine --- core/network/host/routing.go | 4 ---- core/network/test/network_test.go | 5 +---- core/node/network.go | 16 ++++++++++------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/core/network/host/routing.go b/core/network/host/routing.go index e4a22dc5dd..4b2251567a 100644 --- a/core/network/host/routing.go +++ b/core/network/host/routing.go @@ -37,10 +37,6 @@ type BertyRouting struct { tstart time.Time } -func init() { - // log.SetDebugLogging() -} - func NewBertyRouting(ctx context.Context, h host.Host, dhtSvc bool) (*BertyRouting, error) { tracer := tracing.EnterFunc(ctx, h, dhtSvc) defer tracer.Finish() diff --git a/core/network/test/network_test.go b/core/network/test/network_test.go index 17fe95e8f2..685ff07a1d 100644 --- a/core/network/test/network_test.go +++ b/core/network/test/network_test.go @@ -3,7 +3,6 @@ package test import ( "context" "testing" - "time" "berty.tech/core/network" "berty.tech/core/testrunner" @@ -15,9 +14,7 @@ func init() { } func Test(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) - defer cancel() - + ctx := context.Background() Convey("network without options", t, FailureHalts, func() { net, err := network.New(ctx) So(err, ShouldBeNil) diff --git a/core/node/network.go b/core/node/network.go index 5dd0bf103c..a289a0e831 100644 --- a/core/node/network.go +++ b/core/node/network.go @@ -39,12 +39,16 @@ func (n *Node) UseNetworkDriver(ctx context.Context, driver network.Driver) erro n.networkDriver = driver // configure network n.networkDriver.OnEnvelopeHandler(n.HandleEnvelope) - if err := n.networkDriver.Join(ctx, n.UserID()); err != nil { - logger().Error("failed to join user channel", - zap.String("id", n.UserID()), - zap.Error(err), - ) - } + + // @FIXME: dont do that in a goroutine + go func() { + if err := n.networkDriver.Join(ctx, n.UserID()); err != nil { + logger().Error("failed to join user channel", + zap.String("id", n.UserID()), + zap.Error(err), + ) + } + }() // FIXME: subscribe to every owned device IDs // var devices []entity.Device