2018-02-01 09:25:34 +00:00
|
|
|
package payload
|
|
|
|
|
2018-02-07 14:16:50 +00:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
2020-03-26 14:43:24 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2018-02-07 14:16:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetBlockEncodeDecode(t *testing.T) {
|
|
|
|
start := []util.Uint256{
|
2019-08-23 15:50:45 +00:00
|
|
|
hash.Sha256([]byte("a")),
|
|
|
|
hash.Sha256([]byte("b")),
|
|
|
|
hash.Sha256([]byte("c")),
|
|
|
|
hash.Sha256([]byte("d")),
|
2018-02-07 14:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
p := NewGetBlocks(start, util.Uint256{})
|
2020-03-26 14:43:24 +00:00
|
|
|
testserdes.EncodeDecodeBinary(t, p, new(GetBlocks))
|
2018-02-07 14:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetBlockEncodeDecodeWithHashStop(t *testing.T) {
|
|
|
|
var (
|
|
|
|
start = []util.Uint256{
|
2019-08-23 15:50:45 +00:00
|
|
|
hash.Sha256([]byte("a")),
|
|
|
|
hash.Sha256([]byte("b")),
|
|
|
|
hash.Sha256([]byte("c")),
|
|
|
|
hash.Sha256([]byte("d")),
|
2018-02-07 14:16:50 +00:00
|
|
|
}
|
2019-08-23 15:50:45 +00:00
|
|
|
stop = hash.Sha256([]byte("e"))
|
2018-02-07 14:16:50 +00:00
|
|
|
)
|
|
|
|
p := NewGetBlocks(start, stop)
|
2020-03-26 14:43:24 +00:00
|
|
|
testserdes.EncodeDecodeBinary(t, p, new(GetBlocks))
|
2018-02-07 14:16:50 +00:00
|
|
|
}
|