forked from CovenantSQL/CovenantSQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaseaccount_gen_test.go
More file actions
47 lines (42 loc) · 882 Bytes
/
Copy pathbaseaccount_gen_test.go
File metadata and controls
47 lines (42 loc) · 882 Bytes
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
package types
// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
import (
"bytes"
"crypto/rand"
"encoding/binary"
"testing"
)
func TestMarshalHashBaseAccount(t *testing.T) {
v := BaseAccount{}
binary.Read(rand.Reader, binary.BigEndian, &v)
bts1, err := v.MarshalHash()
if err != nil {
t.Fatal(err)
}
bts2, err := v.MarshalHash()
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(bts1, bts2) {
t.Fatal("hash not stable")
}
}
func BenchmarkMarshalHashBaseAccount(b *testing.B) {
v := BaseAccount{}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
v.MarshalHash()
}
}
func BenchmarkAppendMsgBaseAccount(b *testing.B) {
v := BaseAccount{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalHash()
b.SetBytes(int64(len(bts)))
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
bts, _ = v.MarshalHash()
}
}