aboutsummaryrefslogtreecommitdiff
path: root/types/serialize_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'types/serialize_test.go')
-rw-r--r--types/serialize_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/types/serialize_test.go b/types/serialize_test.go
index e835ad2..ed51c2c 100644
--- a/types/serialize_test.go
+++ b/types/serialize_test.go
@@ -33,6 +33,7 @@ func TestMarshalUnmarshal(t *testing.T) {
tests = append(tests, test_cases_sigv1(t)...)
tests = append(tests, test_cases_namespace(t)...)
tests = append(tests, test_cases_ed25519v1(t)...)
+ tests = append(tests, test_cases_requests(t)...)
for _, table := range tests {
b, err := Marshal(table.item)
if got, want := err != nil, table.wantErr; got != want {
@@ -85,6 +86,12 @@ func TestMarshalUnmarshal(t *testing.T) {
case Ed25519V1:
var item Ed25519V1
err = Unmarshal(b, &item)
+ case GetProofByHashV1:
+ var item GetProofByHashV1
+ err = Unmarshal(b, &item)
+ case GetConsistencyProofV1:
+ var item GetConsistencyProofV1
+ err = Unmarshal(b, &item)
default:
t.Errorf("unhandled type in test %q", table.description)
}
@@ -481,6 +488,34 @@ func test_cases_ed25519v1(t *testing.T) []testCaseSerialize {
}
}
+// test_cases_requests returns test cases for proof request types
+func test_cases_requests(t *testing.T) []testCaseSerialize {
+ return []testCaseSerialize{
+ {
+ description: "valid: GetProofByHashV1",
+ item: GetProofByHashV1{
+ Hash: [HashSizeV1]byte{},
+ TreeSize: 16909060,
+ },
+ wantBytes: bytes.Join([][]byte{
+ make([]byte, 32), // hash
+ []byte{0x00, 0x00, 0x00, 0x00, 0x1, 0x2, 0x3, 0x4}, // tree size
+ }, nil),
+ },
+ {
+ description: "valid: GetConsistencyProofV1",
+ item: GetConsistencyProofV1{
+ First: 0,
+ Second: 16909060,
+ },
+ wantBytes: bytes.Join([][]byte{
+ make([]byte, 8), // first
+ []byte{0x00, 0x00, 0x00, 0x00, 0x1, 0x2, 0x3, 0x4}, // second
+ }, nil),
+ },
+ }
+}
+
var (
// StItemList
testStItemList = StItemList{