mirror of https://github.com/poanetwork/gecko.git
Added GetVersion test
This commit is contained in:
parent
83c060a098
commit
fb142d1df5
|
@ -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())
|
||||
}
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue