Skip to content

Commit

Permalink
Merge 034f02c into c51d2fe
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilthoniel committed Nov 29, 2018
2 parents c51d2fe + 034f02c commit 5ee8b8c
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 77 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ install:
script:
- make test

matrix:
include:
- name: "64-bit Unit Tests"
- name: "32-bit Unit Tests"
env: GOARCH=386

notifications:
email: false
5 changes: 3 additions & 2 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

type ContextData struct {
I int
I int64
S string
}

Expand All @@ -41,8 +41,9 @@ func TestContextSaveLoad(t *testing.T) {
wg.Add(nbr)
for i := range c {
go func(i int) {
// defer insures the call even on a panic
defer wg.Done()
testLoadSave(t, c[i])
wg.Done()
}(i)
}
wg.Wait()
Expand Down
2 changes: 1 addition & 1 deletion messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type ProtocolMsg struct {
// The actual data as binary blob
MsgSlice []byte
// The size of the data
Size int
Size network.Size
}

// ConfigMsg is sent by the overlay containing a generic slice of bytes to
Expand Down
6 changes: 3 additions & 3 deletions network/big_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestTCPHugeConnections(t *testing.T) {
// the maximum number of connections using the above snippet.
nbrHosts := 10
// 1MB of message size
msgSize := 1024 * 1024 * 1
msgSize := int64(1024 * 1024 * 1)
big := bigMessage{
Msize: msgSize,
Msg: make([]byte, msgSize),
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestTCPHugeConnections(t *testing.T) {
}

type bigMessage struct {
Msize int
Msize int64
Msg []byte
Pcrc int
Pcrc int64
}
6 changes: 3 additions & 3 deletions network/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
)

type TestRegisterS1 struct {
I int
I int64
}
type TestRegisterS2 struct {
I int
I int64
}

func TestRegisterMessage(t *testing.T) {
Expand Down Expand Up @@ -50,7 +50,7 @@ func TestUnmarshalRegister(t *testing.T) {
ty, b, err := Unmarshal(buff, tSuite)
assert.Nil(t, err)
assert.Equal(t, trType, ty)
assert.Equal(t, 10, b.(*TestRegisterS1).I)
assert.Equal(t, int64(10), b.(*TestRegisterS1).I)

var randType [16]byte
rand.Read(randType[:])
Expand Down
2 changes: 1 addition & 1 deletion network/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (lc *LocalConn) Receive() (*Envelope, error) {
return &Envelope{
MsgType: id,
Msg: body,
Size: len(buff),
Size: Size(len(buff)),
}, err
}

Expand Down
12 changes: 6 additions & 6 deletions network/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func testConnListener(ctx *LocalManager, done chan error, listenA, connA *Server
// make the listener send and receive a struct that only they can know (this
// listener + conn
handshake := func(c Conn, sending, receiving Address) error {
sentLen, err := c.Send(&AddressTest{sending, secret})
sentLen, err := c.Send(&AddressTest{sending, int64(secret)})
if err != nil {
return err
}
Expand All @@ -165,7 +165,7 @@ func testConnListener(ctx *LocalManager, done chan error, listenA, connA *Server
if at.Addr != receiving {
return fmt.Errorf("Receiveid wrong address")
}
if at.Val != secret {
if at.Val != int64(secret) {
return fmt.Errorf("Received wrong secret")
}
return nil
Expand Down Expand Up @@ -244,7 +244,7 @@ func testLocalConn(t *testing.T, a1, a2 Address) {
incomingConn <- true
nm, err := c.Receive()
assert.Nil(t, err)
assert.Equal(t, 3, nm.Msg.(*SimpleMessage).I)
assert.Equal(t, int64(3), nm.Msg.(*SimpleMessage).I)
// acknoledge the message
incomingConn <- true
sentLen, err := c.Send(&SimpleMessage{3})
Expand Down Expand Up @@ -278,7 +278,7 @@ func testLocalConn(t *testing.T, a1, a2 Address) {
// receive stg and send ack
nm, err := outgoing.Receive()
assert.Nil(t, err)
assert.Equal(t, 3, nm.Msg.(*SimpleMessage).I)
assert.Equal(t, int64(3), nm.Msg.(*SimpleMessage).I)
outgoingConn <- true

<-incomingConn
Expand Down Expand Up @@ -327,7 +327,7 @@ func TestLocalManyConn(t *testing.T) {
assert.NotZero(t, sentLen)
nm, err := c.Receive()
assert.Nil(t, err)
assert.Equal(t, 3, nm.Msg.(*SimpleMessage).I)
assert.Equal(t, int64(3), nm.Msg.(*SimpleMessage).I)
assert.Nil(t, c.Close())
wg.Done()
}(i)
Expand Down Expand Up @@ -361,7 +361,7 @@ func NewTestLocalHost(port int) (*LocalHost, error) {

type AddressTest struct {
Addr Address
Val int
Val int64
}

var AddressTestType = RegisterMessage(&AddressTest{})
8 changes: 4 additions & 4 deletions network/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestRouterErrorHandling(t *testing.T) {
require.Nil(t, err)
require.NotZero(t, sentLen)
decoded := <-proc.relay
require.Equal(t, 3, decoded.I)
require.Equal(t, int64(3), decoded.I)
sentLen, err = h2.Send(h1.ServerIdentity, msgSimple)
require.Nil(t, err)
require.NotZero(t, sentLen)
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestRouterSendToSelf(t *testing.T) {
require.Nil(t, err)
require.NotZero(t, sentLen)
decoded := <-proc.relay
require.Equal(t, 3, decoded.I)
require.Equal(t, int64(3), decoded.I)

// Ensure no connections were open (since sending to ourself)
r.Lock()
Expand Down Expand Up @@ -279,7 +279,7 @@ func TestRouterMessaging(t *testing.T) {
require.NotZero(t, sentLen)

decoded := <-proc.relay
require.Equal(t, 3, decoded.I)
require.Equal(t, int64(3), decoded.I)

// make sure the connection is registered in host1 (because it's launched in
// a go routine). Since we try to avoid random timeout, let's send a msg
Expand All @@ -289,7 +289,7 @@ func TestRouterMessaging(t *testing.T) {
require.NotZero(t, sentLen)

decoded = <-proc.relay
require.Equal(t, 3, decoded.I)
require.Equal(t, int64(3), decoded.I)

written := h1.Tx()
read := h2.Rx()
Expand Down
2 changes: 1 addition & 1 deletion network/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Envelope struct {
// A *pointer* to the underlying message
Msg Message
// The length of the message in bytes
Size int
Size Size
// which constructors are used
Constructors protobuf.Constructors
}
Expand Down
2 changes: 1 addition & 1 deletion network/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *TCPConn) Receive() (env *Envelope, e error) {
return &Envelope{
MsgType: id,
Msg: body,
Size: len(buff),
Size: Size(len(buff)),
}, err
}

Expand Down
4 changes: 2 additions & 2 deletions network/tcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ func NewTestServerIdentity(address Address) *ServerIdentity {

// SimpleMessage is just used to transfer one integer
type SimpleMessage struct {
I int
I int64
}

var SimpleMessageType MessageTypeID
Expand All @@ -661,7 +661,7 @@ func (smp *simpleMessageProc) Process(e *Envelope) {

type statusMessage struct {
Ok bool
Val int
Val int64
}

var statusMsgID = RegisterMessage(statusMessage{})
Expand Down
4 changes: 2 additions & 2 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func TestTreeNodeFlags(t *testing.T) {

// Protocol/service Channels test code:
type NodeTestMsg struct {
I int
I int64
}

var Incoming chan struct {
Expand All @@ -256,7 +256,7 @@ var Incoming chan struct {
}

type NodeTestAggMsg struct {
I int
I int64
}

type ProtocolChannels struct {
Expand Down
11 changes: 5 additions & 6 deletions processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package onet

import (
"errors"
"testing"

"reflect"
"testing"

"github.com/dedis/onet/log"
"github.com/dedis/onet/network"
Expand Down Expand Up @@ -154,7 +153,7 @@ func TestServiceProcessor_ProcessClientRequest_Streaming(t *testing.T) {
h := func(m *testMsg) (chan network.Message, chan bool, error) {
outChan := make(chan network.Message)
go func() {
for i := 0; i < m.I; i++ {
for i := 0; i < int(m.I); i++ {
outChan <- m
}
close(outChan)
Expand All @@ -164,7 +163,7 @@ func TestServiceProcessor_ProcessClientRequest_Streaming(t *testing.T) {
require.Nil(t, p.RegisterStreamingHandler(h))

n := 5
buf, err := protobuf.Encode(&testMsg{n})
buf, err := protobuf.Encode(&testMsg{int64(n)})
require.NoError(t, err)
rep, tun, err := p.ProcessClientRequest(nil, "testMsg", buf)
require.Nil(t, rep)
Expand All @@ -178,7 +177,7 @@ func TestServiceProcessor_ProcessClientRequest_Streaming(t *testing.T) {
buf := <-tun.out
val := &testMsg{}
require.Nil(t, protobuf.Decode(buf, val))
require.Equal(t, val.I, n)
require.Equal(t, val.I, int64(n))
}
}
}
Expand All @@ -203,7 +202,7 @@ func TestProcessor_ProcessClientRequest(t *testing.T) {
}

type testMsg struct {
I int
I int64
}

type testMsg2 testMsg
Expand Down
2 changes: 1 addition & 1 deletion protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (p *SimpleProtocol) ReturnError(msg MsgSimpleMessage) error {
}

type SimpleMessage struct {
I int
I int64
}

type MsgSimpleMessage struct {
Expand Down
29 changes: 14 additions & 15 deletions service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"bytes"
"errors"
"net/http"
"sync"
"testing"
"time"

"sync"

"github.com/dedis/onet/log"
"github.com/dedis/onet/network"
"github.com/dedis/protobuf"
Expand Down Expand Up @@ -268,7 +267,7 @@ func TestServiceBackForthProtocol(t *testing.T) {
sr := &SimpleResponse{}
err = client.SendProtobuf(servers[0].ServerIdentity, r, sr)
log.ErrFatal(err)
require.Equal(t, sr.Val, 10)
require.Equal(t, sr.Val, int64(10))
}

func TestPanicNewProto(t *testing.T) {
Expand Down Expand Up @@ -383,17 +382,17 @@ func TestServiceGenericConfig(t *testing.T) {
// BackForthProtocolForth & Back are messages that go down and up the tree.
// => BackForthProtocol protocol / message
type SimpleMessageForth struct {
Val int
Val int64
}

type SimpleMessageBack struct {
Val int
Val int64
}

type BackForthProtocol struct {
*TreeNodeInstance
Val int
counter int
Val int64
counter int64
forthChan chan struct {
*TreeNode
SimpleMessageForth
Expand All @@ -408,7 +407,7 @@ type BackForthProtocol struct {

func newBackForthProtocolRoot(tn *TreeNodeInstance, val int, handler func(int)) (ProtocolInstance, error) {
s, err := newBackForthProtocol(tn)
s.Val = val
s.Val = int64(val)
s.handler = handler
return s, err
}
Expand Down Expand Up @@ -469,9 +468,9 @@ func (sp *BackForthProtocol) dispatch() error {
msg := m.SimpleMessageBack
// call the handler if we are the root
sp.counter++
if sp.counter == len(sp.Children()) {
if int(sp.counter) == len(sp.Children()) {
if sp.IsRoot() {
sp.handler(msg.Val)
sp.handler(int(msg.Val))
} else {
sp.SendTo(sp.Parent(), &msg)
}
Expand All @@ -488,11 +487,11 @@ func (sp *BackForthProtocol) dispatch() error {
// Client API request / response emulation
type SimpleRequest struct {
ServerIdentities *Roster
Val int
Val int64
}

type SimpleResponse struct {
Val int
Val int64
}

var SimpleResponseType = network.RegisterMessage(SimpleResponse{})
Expand All @@ -512,7 +511,7 @@ func (s *simpleService) ProcessClientRequest(req *http.Request, path string, buf
tree := msg.ServerIdentities.GenerateBinaryTree()
tni := s.ctx.NewTreeNodeInstance(tree, tree.Root, backForthServiceName)
ret := make(chan int)
proto, err := newBackForthProtocolRoot(tni, msg.Val, func(n int) {
proto, err := newBackForthProtocolRoot(tni, int(msg.Val), func(n int) {
ret <- n
})
if err != nil {
Expand All @@ -526,7 +525,7 @@ func (s *simpleService) ProcessClientRequest(req *http.Request, path string, buf
proto.(*BackForthProtocol).Done()
close(ret)
}
resp, err := protobuf.Encode(&SimpleResponse{<-ret})
resp, err := protobuf.Encode(&SimpleResponse{int64(<-ret)})
return resp, nil, err
}

Expand Down Expand Up @@ -558,7 +557,7 @@ type DummyConfig struct {
}

type DummyMsg struct {
A int
A int64
}

var dummyMsgType network.MessageTypeID
Expand Down

0 comments on commit 5ee8b8c

Please sign in to comment.