payload: expand version test with explicit data checks
This commit is contained in:
parent
2e3172f8a5
commit
650a1d4bcc
1 changed files with 12 additions and 1 deletions
|
@ -8,7 +8,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestVersionEncodeDecode(t *testing.T) {
|
func TestVersionEncodeDecode(t *testing.T) {
|
||||||
version := NewVersion(13337, 3000, "/NEO:0.0.1/", 0, true)
|
var port uint16 = 3000
|
||||||
|
var id uint32 = 13337
|
||||||
|
useragent := "/NEO:0.0.1/"
|
||||||
|
var height uint32 = 100500
|
||||||
|
var relay bool = true
|
||||||
|
|
||||||
|
version := NewVersion(id, port, useragent, height, relay)
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
err := version.EncodeBinary(buf)
|
err := version.EncodeBinary(buf)
|
||||||
|
@ -18,5 +24,10 @@ func TestVersionEncodeDecode(t *testing.T) {
|
||||||
versionDecoded := &Version{}
|
versionDecoded := &Version{}
|
||||||
err = versionDecoded.DecodeBinary(buf)
|
err = versionDecoded.DecodeBinary(buf)
|
||||||
assert.Nil(t, err)
|
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)
|
assert.Equal(t, version, versionDecoded)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue