-
Notifications
You must be signed in to change notification settings - Fork 199
/
outportStub.go
74 lines (59 loc) · 1.89 KB
/
outportStub.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
package testscommon
import (
"github.com/ElrondNetwork/elrond-go-core/data"
"github.com/ElrondNetwork/elrond-go-core/data/indexer"
"github.com/ElrondNetwork/elrond-go/outport"
)
// OutportStub is a mock implementation fot the OutportHandler interface
type OutportStub struct {
SaveBlockCalled func(args *indexer.ArgsSaveBlockData)
SaveValidatorsRatingCalled func(index string, validatorsInfo []*indexer.ValidatorRatingInfo)
SaveValidatorsPubKeysCalled func(shardPubKeys map[uint32][][]byte, epoch uint32)
HasDriversCalled func() bool
}
// SaveBlock -
func (as *OutportStub) SaveBlock(args *indexer.ArgsSaveBlockData) {
if as.SaveBlockCalled != nil {
as.SaveBlockCalled(args)
}
}
// SaveValidatorsRating --
func (as *OutportStub) SaveValidatorsRating(index string, validatorsInfo []*indexer.ValidatorRatingInfo) {
if as.SaveValidatorsRatingCalled != nil {
as.SaveValidatorsRatingCalled(index, validatorsInfo)
}
}
// SaveValidatorsPubKeys -
func (as *OutportStub) SaveValidatorsPubKeys(shardPubKeys map[uint32][][]byte, epoch uint32) {
if as.SaveValidatorsPubKeysCalled != nil {
as.SaveValidatorsPubKeysCalled(shardPubKeys, epoch)
}
}
// IsInterfaceNil returns true if there is no value under the interface
func (as *OutportStub) IsInterfaceNil() bool {
return as == nil
}
// HasDrivers -
func (as *OutportStub) HasDrivers() bool {
if as.HasDriversCalled != nil {
return as.HasDriversCalled()
}
return false
}
// RevertIndexedBlock -
func (as *OutportStub) RevertIndexedBlock(_ data.HeaderHandler, _ data.BodyHandler) {
}
// SaveAccounts -
func (as *OutportStub) SaveAccounts(_ uint64, _ []data.UserAccountHandler) {
}
// Close -
func (as *OutportStub) Close() error {
return nil
}
// SaveRoundsInfo -
func (as *OutportStub) SaveRoundsInfo(_ []*indexer.RoundInfo) {
}
// SubscribeDriver -
func (as *OutportStub) SubscribeDriver(_ outport.Driver) error {
return nil
}