-
Notifications
You must be signed in to change notification settings - Fork 198
/
oneShardCoordinatorMock.go
60 lines (48 loc) · 1.27 KB
/
oneShardCoordinatorMock.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
package mock
import (
"github.com/ElrondNetwork/elrond-go-core/core"
)
type oneShardCoordinatorMock struct {
shardID uint32
noShards uint32
ComputeIdCalled func(address []byte) uint32
}
// NewOneShardCoordinatorMock -
func NewOneShardCoordinatorMock() *oneShardCoordinatorMock {
return &oneShardCoordinatorMock{noShards: 1}
}
// NumberOfShards -
func (scm *oneShardCoordinatorMock) NumberOfShards() uint32 {
return scm.noShards
}
// ComputeId -
func (scm *oneShardCoordinatorMock) ComputeId(address []byte) uint32 {
if scm.ComputeIdCalled != nil {
return scm.ComputeIdCalled(address)
}
return uint32(0)
}
// SelfId -
func (scm *oneShardCoordinatorMock) SelfId() uint32 {
return scm.shardID
}
// SetSelfId -
func (scm *oneShardCoordinatorMock) SetSelfId(shardID uint32) error {
scm.shardID = shardID
return nil
}
// SameShard -
func (scm *oneShardCoordinatorMock) SameShard(_, _ []byte) bool {
return true
}
// CommunicationIdentifier -
func (scm *oneShardCoordinatorMock) CommunicationIdentifier(destShardID uint32) string {
if destShardID == core.MetachainShardId {
return "_0_META"
}
return "_0"
}
// IsInterfaceNil returns true if there is no value under the interface
func (scm *oneShardCoordinatorMock) IsInterfaceNil() bool {
return scm == nil
}