forked from algorand/go-algorand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsgp_gen_test.go
73 lines (63 loc) · 1.52 KB
/
msgp_gen_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// +build !skip_msgp_testing
package rpcs
// Code generated by github.com/algorand/msgp DO NOT EDIT.
import (
"testing"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalEncodedBlockCert(t *testing.T) {
partitiontest.PartitionTest(t)
v := EncodedBlockCert{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
}
left, err = msgp.Skip(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
}
}
func TestRandomizedEncodingEncodedBlockCert(t *testing.T) {
protocol.RunEncodingTest(t, &EncodedBlockCert{})
}
func BenchmarkMarshalMsgEncodedBlockCert(b *testing.B) {
v := EncodedBlockCert{}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
v.MarshalMsg(nil)
}
}
func BenchmarkAppendMsgEncodedBlockCert(b *testing.B) {
v := EncodedBlockCert{}
bts := make([]byte, 0, v.Msgsize())
bts = v.MarshalMsg(bts[0:0])
b.SetBytes(int64(len(bts)))
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
bts = v.MarshalMsg(bts[0:0])
}
}
func BenchmarkUnmarshalEncodedBlockCert(b *testing.B) {
v := EncodedBlockCert{}
bts := v.MarshalMsg(nil)
b.ReportAllocs()
b.SetBytes(int64(len(bts)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := v.UnmarshalMsg(bts)
if err != nil {
b.Fatal(err)
}
}
}