-
Notifications
You must be signed in to change notification settings - Fork 26
/
node_test.go
57 lines (44 loc) · 1.24 KB
/
node_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
package graviton
import (
"errors"
"testing"
)
// used to test certain code paths, which though can be avoid now but may arise when code is maintained, developed, rewritten over a period of time
type dummynode struct {
dirty bool
}
func (d *dummynode) Hash(store *Store) ([]byte, error) {
var h [HASHSIZE_BYTES]byte
return h[:], nil
}
func (d *dummynode) isDirty() bool {
return d.dirty
}
func (d *dummynode) load_partial(store *Store) error {
return nil
}
func (d *dummynode) Position() (uint32, uint32) {
return 0, 0
}
func (d *dummynode) Put(store *Store, keyhash [HASHSIZE]byte, value []byte) error {
return errors.New("not implemented")
}
func (d *dummynode) Get(store *Store, keyhash [HASHSIZE]byte) ([]byte, error) {
return nil, errors.New("not implemented")
}
func (d *dummynode) Delete(store *Store, keyhash [HASHSIZE]byte) (bool, bool, error) {
return false, false, errors.New("not implemented")
}
func (d *dummynode) Prove(store *Store, keyhash [HASHSIZE]byte, proof *Proof) error {
return errors.New("not implemented")
}
func TestUnknownNodePanic(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("The code did not panic")
}
}()
var d dummynode
// The following is the code under test
getNodeType(&d)
}