network/payload: add missing tests for InventoryType
This commit is contained in:
parent
19a8ccbdb8
commit
fc6cb2aa7b
1 changed files with 16 additions and 0 deletions
|
@ -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"))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue