Skip to content

Commit

Permalink
fix(test): Fix provide inside a goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
gfanton committed Mar 8, 2019
1 parent a0f2b93 commit 6f75c5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 0 additions & 4 deletions core/network/host/routing.go
Expand Up @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions core/network/test/network_test.go
Expand Up @@ -3,7 +3,6 @@ package test
import (
"context"
"testing"
"time"

"berty.tech/core/network"
"berty.tech/core/testrunner"
Expand All @@ -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)
Expand Down
16 changes: 10 additions & 6 deletions core/node/network.go
Expand Up @@ -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
Expand Down

0 comments on commit 6f75c5d

Please sign in to comment.