neo-go/pkg/network/payload/ping_test.go
Evgenii Stratonikov 9abda40171 testserdes: implement helpers for encode/decode routines
Frequently one needs to check if struct serializes/deserializes
properly. This commit implements helpers for such cases including:
1. JSON
2. io.Serializable interface
2020-03-27 10:27:46 +03:00

19 lines
449 B
Go

package payload
import (
"testing"
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
"github.com/stretchr/testify/assert"
)
func TestEncodeDecodeBinary(t *testing.T) {
payload := NewPing(uint32(1), uint32(2))
assert.NotEqual(t, 0, payload.Timestamp)
decodedPing := &Ping{}
testserdes.EncodeDecodeBinary(t, payload, decodedPing)
assert.Equal(t, uint32(1), decodedPing.LastBlockIndex)
assert.Equal(t, uint32(2), decodedPing.Nonce)
}