From 650a1d4bcc13cdce6f7e66e7c9d2d0f89f271094 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 29 Aug 2019 17:42:13 +0300 Subject: [PATCH] payload: expand version test with explicit data checks --- pkg/network/payload/version_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/network/payload/version_test.go b/pkg/network/payload/version_test.go index 53ccb4c47..c67e8357b 100644 --- a/pkg/network/payload/version_test.go +++ b/pkg/network/payload/version_test.go @@ -8,7 +8,13 @@ import ( ) 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) err := version.EncodeBinary(buf) @@ -18,5 +24,10 @@ func TestVersionEncodeDecode(t *testing.T) { 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) }