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