aboutsummaryrefslogtreecommitdiff
path: root/types
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-02-23 12:59:17 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-02-23 12:59:17 +0100
commitc9b4b43654f0ff26207cc63449f13298cd3c56e8 (patch)
tree1f96d1a06a1fb5e48cf7afb24cd40fc935e91e64 /types
parent15102a44b646f300ac8b35ce18fe3d1fded7ba1d (diff)
added get-entries request type
Diffstat (limited to 'types')
-rw-r--r--types/serialize.go6
-rw-r--r--types/serialize_test.go14
2 files changed, 20 insertions, 0 deletions
diff --git a/types/serialize.go b/types/serialize.go
index af0a1ed..fd93336 100644
--- a/types/serialize.go
+++ b/types/serialize.go
@@ -22,6 +22,12 @@ type GetConsistencyProofV1 struct {
Second uint64
}
+// GetEntriesV1 is a serializable get-entries request
+type GetEntriesV1 struct {
+ Start uint64
+ End uint64
+}
+
// Marshal marshals a TLS-encodable structure
func Marshal(item interface{}) ([]byte, error) {
serialized, err := tls.Marshal(item)
diff --git a/types/serialize_test.go b/types/serialize_test.go
index ed51c2c..a06effe 100644
--- a/types/serialize_test.go
+++ b/types/serialize_test.go
@@ -92,6 +92,9 @@ func TestMarshalUnmarshal(t *testing.T) {
case GetConsistencyProofV1:
var item GetConsistencyProofV1
err = Unmarshal(b, &item)
+ case GetEntriesV1:
+ var item GetEntriesV1
+ err = Unmarshal(b, &item)
default:
t.Errorf("unhandled type in test %q", table.description)
}
@@ -513,6 +516,17 @@ func test_cases_requests(t *testing.T) []testCaseSerialize {
[]byte{0x00, 0x00, 0x00, 0x00, 0x1, 0x2, 0x3, 0x4}, // second
}, nil),
},
+ {
+ description: "valid: GetEntriesV1",
+ item: GetEntriesV1{
+ Start: 0,
+ End: 16909060,
+ },
+ wantBytes: bytes.Join([][]byte{
+ make([]byte, 8), // start
+ []byte{0x00, 0x00, 0x00, 0x00, 0x1, 0x2, 0x3, 0x4}, // end
+ }, nil),
+ },
}
}