/
storageManagerStub.go
104 lines (84 loc) · 2.5 KB
/
storageManagerStub.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package mock
import (
"github.com/ElrondNetwork/elrond-go/common"
"github.com/ElrondNetwork/elrond-go/state"
)
// StorageManagerStub -
type StorageManagerStub struct {
DatabaseCalled func() common.DBWriteCacher
TakeSnapshotCalled func([]byte)
SetCheckpointCalled func([]byte)
PruneCalled func([]byte)
CancelPruneCalled func([]byte)
MarkForEvictionCalled func([]byte, common.ModifiedHashes) error
GetDbThatContainsHashCalled func([]byte) common.DBWriteCacher
GetSnapshotThatContainsHashCalled func(rootHash []byte) common.SnapshotDbHandler
IsPruningEnabledCalled func() bool
EnterSnapshotModeCalled func()
ExitSnapshotModeCalled func()
IsInterfaceNilCalled func() bool
}
// Database -
func (sms *StorageManagerStub) Database() common.DBWriteCacher {
if sms.DatabaseCalled != nil {
return sms.DatabaseCalled()
}
return nil
}
// TakeSnapshot -
func (sms *StorageManagerStub) TakeSnapshot([]byte) {
}
// SetCheckpoint -
func (sms *StorageManagerStub) SetCheckpoint([]byte) {
}
// Prune -
func (sms *StorageManagerStub) Prune([]byte, state.TriePruningIdentifier) {
}
// CancelPrune -
func (sms *StorageManagerStub) CancelPrune([]byte, state.TriePruningIdentifier) {
}
// MarkForEviction -
func (sms *StorageManagerStub) MarkForEviction(d []byte, m common.ModifiedHashes) error {
if sms.MarkForEvictionCalled != nil {
return sms.MarkForEvictionCalled(d, m)
}
return nil
}
// GetSnapshotThatContainsHash -
func (sms *StorageManagerStub) GetSnapshotThatContainsHash(d []byte) common.SnapshotDbHandler {
if sms.GetSnapshotThatContainsHashCalled != nil {
return sms.GetSnapshotThatContainsHashCalled(d)
}
return nil
}
// IsPruningEnabled -
func (sms *StorageManagerStub) IsPruningEnabled() bool {
if sms.IsPruningEnabledCalled != nil {
return sms.IsPruningEnabledCalled()
}
return false
}
// EnterSnapshotMode -
func (sms *StorageManagerStub) EnterSnapshotMode() {
if sms.EnterSnapshotModeCalled != nil {
sms.EnterSnapshotModeCalled()
}
}
// ExitSnapshotMode -
func (sms *StorageManagerStub) ExitSnapshotMode() {
if sms.ExitSnapshotModeCalled != nil {
sms.ExitSnapshotModeCalled()
}
}
// GetSnapshotDbBatchDelay -
func (sms *StorageManagerStub) GetSnapshotDbBatchDelay() int {
return 0
}
// Close -
func (sms *StorageManagerStub) Close() error {
return nil
}
// IsInterfaceNil -
func (sms *StorageManagerStub) IsInterfaceNil() bool {
return sms == nil
}