Skip to content

Commit

Permalink
Fix router RemoveRouteDescriptor test
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Nov 12, 2019
1 parent e8aa791 commit a227415
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions pkg/router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
"testing"
"time"

"github.com/google/uuid"

"github.com/SkycoinProject/dmsg"
cipher "github.com/SkycoinProject/dmsg/cipher"
"github.com/SkycoinProject/skycoin/src/util/logging"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -165,7 +168,7 @@ func TestRouter_Serve(t *testing.T) {
}

// TODO (Darkren): fix tests
/*func TestRouter_Rules(t *testing.T) {
func TestRouter_Rules(t *testing.T) {
pk, sk := cipher.GenerateKeyPair()

env := snettest.NewEnv(t, []snettest.KeyPair{{PK: pk, SK: sk}})
Expand Down Expand Up @@ -255,7 +258,7 @@ func TestRouter_Serve(t *testing.T) {
})

// TEST: Ensure AddRule and DeleteRule requests from a SetupNode does as expected.
t.Run("AddRemoveRule", func(t *testing.T) {
/*t.Run("AddRemoveRule", func(t *testing.T) {
clearRules()
// Add/Remove rules multiple times.
Expand Down Expand Up @@ -441,8 +444,8 @@ func TestRouter_Serve(t *testing.T) {
assert.Equal(t, routing.Port(2), inLoop.Local.Port)
assert.Equal(t, routing.Port(3), inLoop.Remote.Port)
assert.Equal(t, pk, inLoop.Remote.PubKey)
})
}*/
})*/
}

type TestEnv struct {
TpD transport.DiscoveryClient
Expand Down
8 changes: 6 additions & 2 deletions pkg/routing/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,14 @@ type RouteDescriptor [routeDescriptorSize]byte
func NewRouteDescriptor(srcPK, dstPK cipher.PubKey, srcPort, dstPort Port) RouteDescriptor {
var desc RouteDescriptor

desc.setSrcPK(srcPK)
p := copy(desc[:pkSize], srcPK[:])
p = copy(desc[p:p+pkSize], dstPK[:])
binary.BigEndian.PutUint16(desc[p:p+2], uint16(srcPort))
binary.BigEndian.PutUint16(desc[p+2:p+2*2], uint16(dstPort))
/*desc.setSrcPK(srcPK)
desc.setDstPK(dstPK)
desc.setSrcPort(srcPort)
desc.setDstPort(dstPort)
desc.setDstPort(dstPort)*/

return desc
}
Expand Down

0 comments on commit a227415

Please sign in to comment.