Added GetVersion test

This commit is contained in:
StephenButtolph 2020-05-20 15:46:17 -04:00
parent 83c060a098
commit fb142d1df5
2 changed files with 27 additions and 2 deletions

26
network/builder_test.go Normal file
View File

@ -0,0 +1,26 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package network
import (
"testing"
"github.com/stretchr/testify/assert"
)
var (
TestBuilder Builder
)
func TestBuildGetVersion(t *testing.T) {
msg, err := TestBuilder.GetVersion()
assert.NoError(t, err)
assert.NotNil(t, msg)
assert.Equal(t, GetVersion, msg.Op())
parsedMsg, err := TestBuilder.Parse(msg.Bytes())
assert.NoError(t, err)
assert.NotNil(t, parsedMsg)
assert.Equal(t, GetVersion, parsedMsg.Op())
}

View File

@ -30,7 +30,6 @@ type peer struct {
once sync.Once
b Builder
c Codec
}
func (p *peer) Start() {
@ -110,7 +109,7 @@ func (p *peer) ReadMessages() {
p.id,
formatting.DumpBytes{Bytes: msgBytes})
msg, err := p.c.Parse(msgBytes)
msg, err := p.b.Parse(msgBytes)
if err != nil {
p.net.log.Debug("failed to parse new message from %s:\n%s\n%s",
p.id,