Skip to content

Commit

Permalink
Fix integration tests data races and panics
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Jul 15, 2019
1 parent 424bb53 commit 43bae55
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (app *App) Accept() (net.Conn, error) {
laddr := addrs[0]
raddr := addrs[1]

loop := routing.Loop{Local: *laddr, Remote: *raddr}
loop := routing.Loop{Local: routing.Addr{Port: laddr.Port}, Remote: *raddr}
conn, out := net.Pipe()
app.mu.Lock()
app.conns[loop] = conn
Expand All @@ -136,7 +136,7 @@ func (app *App) Dial(raddr *routing.Addr) (net.Conn, error) {
if err != nil {
return nil, err
}
loop := routing.Loop{Local: laddr, Remote: *raddr}
loop := routing.Loop{Local: routing.Addr{Port: laddr.Port}, Remote: *raddr}
conn, out := net.Pipe()
app.mu.Lock()
app.conns[loop] = conn
Expand Down
3 changes: 1 addition & 2 deletions pkg/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,14 @@ func TestAppDial(t *testing.T) {
assert.Equal(t, rpk.Hex()+":3", conn.RemoteAddr().String())
assert.Equal(t, lpk.Hex()+":2", conn.LocalAddr().String())

require.NotNil(t, app.conns[routing.Loop{Local: routing.Addr{PubKey: lpk, Port: 2}, Remote: routing.Addr{PubKey: rpk, Port: 3}}])
require.NotNil(t, app.conns[routing.Loop{Local: routing.Addr{Port: 2}, Remote: routing.Addr{PubKey: rpk, Port: 3}}])
require.NoError(t, conn.Close())

// Justified. Attempt to remove produces: FAIL
time.Sleep(100 * time.Millisecond)

var loop routing.Loop
require.NoError(t, json.Unmarshal(<-dataCh, &loop))
assert.Equal(t, lpk, loop.Local.PubKey)
assert.Equal(t, routing.Port(2), loop.Local.Port)
assert.Equal(t, rpk, loop.Remote.PubKey)
assert.Equal(t, routing.Port(3), loop.Remote.Port)
Expand Down
3 changes: 1 addition & 2 deletions pkg/node/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
"testing"
"time"

"github.com/skycoin/skywire/pkg/routing"

"github.com/skycoin/dmsg/cipher"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/skycoin/skywire/internal/httpauth"
"github.com/skycoin/skywire/pkg/routing"
)

func TestMessagingDiscovery(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import (
"syscall"
"time"

"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/dmsg/noise"
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/pkg/app"
routeFinder "github.com/skycoin/skywire/pkg/route-finder/client"
Expand Down
3 changes: 1 addition & 2 deletions pkg/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"testing"
"time"

"github.com/skycoin/skywire/pkg/routing"

"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/dmsg/disc"
"github.com/skycoin/skycoin/src/util/logging"
Expand All @@ -25,6 +23,7 @@ import (

"github.com/skycoin/skywire/internal/httpauth"
"github.com/skycoin/skywire/pkg/app"
"github.com/skycoin/skywire/pkg/routing"
"github.com/skycoin/skywire/pkg/transport"
"github.com/skycoin/skywire/pkg/transport/dmsg"
"github.com/skycoin/skywire/pkg/util/pathutil"
Expand Down
3 changes: 1 addition & 2 deletions pkg/router/port_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"math"
"sync"

"github.com/skycoin/skywire/pkg/routing"

"github.com/skycoin/skywire/pkg/app"
"github.com/skycoin/skywire/pkg/routing"
)

type portBind struct {
Expand Down
1 change: 0 additions & 1 deletion pkg/routing/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/google/uuid"
"github.com/skycoin/dmsg/cipher"

"github.com/stretchr/testify/assert"
)

Expand Down

0 comments on commit 43bae55

Please sign in to comment.