-
Notifications
You must be signed in to change notification settings - Fork 0
/
sstorage_test.go
63 lines (48 loc) · 1.09 KB
/
sstorage_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
package spaxos
import (
"testing"
pb "github.com/dengoswei/spaxos/spaxospb"
// pb "spaxos/spaxospb"
)
func TestNewStorage(t *testing.T) {
printIndicate()
c := NewDefaultConfig()
assert(nil != c)
c.Path = "./test_data"
store, err := NewStorage(c)
assert(nil == err)
assert(nil != store)
defer store.Close()
}
func TestSetAndGetIndex(t *testing.T) {
printIndicate()
c := NewDefaultConfig()
assert(nil != c)
c.Path = "./test_data"
store, err := NewStorage(c)
assert(nil == err)
assert(nil != store)
defer store.Close()
err = store.SetIndex(1, 10)
assert(nil == err)
minIndex, maxIndex, err := store.GetIndex()
assert(nil == err)
assert(uint64(1) == minIndex)
assert(uint64(10) == maxIndex)
}
func TestSetAndGet(t *testing.T) {
printIndicate()
c := NewDefaultConfig()
assert(nil != c)
c.Path = "./test_data"
store, err := NewStorage(c)
assert(nil == err)
assert(nil != store)
defer store.Close()
hs := randHardState()
err = store.Store([]pb.HardState{hs})
assert(nil == err)
newhs, err := store.Get(hs.Index)
assert(nil == err)
assert(true == hs.Equal(&newhs))
}