Skip to content

Commit

Permalink
network/payload: add missing tests for InventoryType
Browse files Browse the repository at this point in the history
  • Loading branch information
fyrchik committed Dec 4, 2020
1 parent 19a8ccb commit fc6cb2a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/network/payload/inventory_test.go
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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"))
}

0 comments on commit fc6cb2a

Please sign in to comment.