From fc6cb2aa7be09386e5d3cddb7326161c3012580d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 4 Dec 2020 15:26:14 +0300 Subject: [PATCH] network/payload: add missing tests for `InventoryType` --- pkg/network/payload/inventory_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/network/payload/inventory_test.go b/pkg/network/payload/inventory_test.go index 4a15d74a9..6f359e9dc 100644 --- a/pkg/network/payload/inventory_test.go +++ b/pkg/network/payload/inventory_test.go @@ -1,12 +1,14 @@ package payload import ( + "strings" "testing" "github.com/nspcc-dev/neo-go/internal/testserdes" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" . "github.com/nspcc-dev/neo-go/pkg/util" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestInventoryEncodeDecode(t *testing.T) { @@ -27,3 +29,17 @@ func TestEmptyInv(t *testing.T) { assert.Equal(t, []byte{byte(TXType), 0}, data) assert.Equal(t, 0, len(msgInv.Hashes)) } + +func TestValid(t *testing.T) { + require.True(t, TXType.Valid()) + require.True(t, BlockType.Valid()) + require.True(t, ConsensusType.Valid()) + require.False(t, InventoryType(0xFF).Valid()) +} + +func TestString(t *testing.T) { + require.Equal(t, "TX", TXType.String()) + require.Equal(t, "block", BlockType.String()) + require.Equal(t, "consensus", ConsensusType.String()) + require.True(t, strings.Contains(InventoryType(0xFF).String(), "unknown")) +}