mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-02 09:45:50 +00:00
db9e37b3bb
pkg/core/transaction/attribute.go:67:14: should omit type uint8 from declaration of var urllen; it will be inferred from the right-hand side pkg/crypto/keys/publickey.go:184:8: should omit type []byte from declaration of var b; it will be inferred from the right-hand side pkg/network/payload/version_test.go:15:12: should omit type bool from declaration of var relay; it will be inferred from the right-hand side Refs. #213.
33 lines
827 B
Go
33 lines
827 B
Go
package payload
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestVersionEncodeDecode(t *testing.T) {
|
|
var port uint16 = 3000
|
|
var id uint32 = 13337
|
|
useragent := "/NEO:0.0.1/"
|
|
var height uint32 = 100500
|
|
var relay = true
|
|
|
|
version := NewVersion(id, port, useragent, height, relay)
|
|
|
|
buf := new(bytes.Buffer)
|
|
err := version.EncodeBinary(buf)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, int(version.Size()), buf.Len())
|
|
|
|
versionDecoded := &Version{}
|
|
err = versionDecoded.DecodeBinary(buf)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, versionDecoded.Nonce, id)
|
|
assert.Equal(t, versionDecoded.Port, port)
|
|
assert.Equal(t, versionDecoded.UserAgent, []byte(useragent))
|
|
assert.Equal(t, versionDecoded.StartHeight, height)
|
|
assert.Equal(t, versionDecoded.Relay, relay)
|
|
assert.Equal(t, version, versionDecoded)
|
|
}
|