neoneo-go/pkg/network/payload/inventory_test.go

30 lines
682 B
Go
Raw Normal View History

2018-01-30 10:56:36 +00:00
package payload
import (
"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"
2018-01-30 10:56:36 +00:00
)
func TestInventoryEncodeDecode(t *testing.T) {
hashes := []Uint256{
hash.Sha256([]byte("a")),
hash.Sha256([]byte("b")),
2018-01-30 10:56:36 +00:00
}
inv := NewInventory(BlockType, hashes)
testserdes.EncodeDecodeBinary(t, inv, new(Inventory))
2018-01-30 10:56:36 +00:00
}
func TestEmptyInv(t *testing.T) {
msgInv := NewInventory(TXType, []Uint256{})
data, err := testserdes.EncodeBinary(msgInv)
assert.Nil(t, err)
assert.Equal(t, []byte{byte(TXType), 0}, data)
assert.Equal(t, 0, len(msgInv.Hashes))
}