-
Notifications
You must be signed in to change notification settings - Fork 199
/
coreComponentsMock.go
143 lines (121 loc) · 3.99 KB
/
coreComponentsMock.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package mock
import (
"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/data/endProcess"
"github.com/ElrondNetwork/elrond-go-core/data/typeConverters"
"github.com/ElrondNetwork/elrond-go-core/hashing"
"github.com/ElrondNetwork/elrond-go-core/marshal"
"github.com/ElrondNetwork/elrond-go/consensus"
"github.com/ElrondNetwork/elrond-go/process"
"github.com/ElrondNetwork/elrond-go/sharding"
"github.com/ElrondNetwork/elrond-go/storage"
)
// CoreComponentsMock -
type CoreComponentsMock struct {
IntMarsh marshal.Marshalizer
TxMarsh marshal.Marshalizer
Hash hashing.Hasher
TxSignHasherField hashing.Hasher
UInt64ByteSliceConv typeConverters.Uint64ByteSliceConverter
AddrPubKeyConv core.PubkeyConverter
ValPubKeyConv core.PubkeyConverter
PathHdl storage.PathManagerHandler
ChainIdCalled func() string
MinTransactionVersionCalled func() uint32
GenesisNodesSetupCalled func() sharding.GenesisNodesSetupHandler
TxVersionCheckField process.TxVersionCheckerHandler
EpochNotifierField process.EpochNotifier
RoundField consensus.RoundHandler
StatusField core.AppStatusHandler
ChanStopNode chan endProcess.ArgEndProcess
NodeTypeProviderField core.NodeTypeProviderHandler
}
// ChanStopNodeProcess -
func (ccm *CoreComponentsMock) ChanStopNodeProcess() chan endProcess.ArgEndProcess {
if ccm.ChanStopNode != nil {
return ccm.ChanStopNode
}
return endProcess.GetDummyEndProcessChannel()
}
// InternalMarshalizer -
func (ccm *CoreComponentsMock) InternalMarshalizer() marshal.Marshalizer {
return ccm.IntMarsh
}
// SetInternalMarshalizer -
func (ccm *CoreComponentsMock) SetInternalMarshalizer(m marshal.Marshalizer) error {
ccm.IntMarsh = m
return nil
}
// TxMarshalizer -
func (ccm *CoreComponentsMock) TxMarshalizer() marshal.Marshalizer {
return ccm.TxMarsh
}
// Hasher -
func (ccm *CoreComponentsMock) Hasher() hashing.Hasher {
return ccm.Hash
}
// TxSignHasher -
func (ccm *CoreComponentsMock) TxSignHasher() hashing.Hasher {
return ccm.TxSignHasherField
}
// Uint64ByteSliceConverter -
func (ccm *CoreComponentsMock) Uint64ByteSliceConverter() typeConverters.Uint64ByteSliceConverter {
return ccm.UInt64ByteSliceConv
}
// AddressPubKeyConverter -
func (ccm *CoreComponentsMock) AddressPubKeyConverter() core.PubkeyConverter {
return ccm.AddrPubKeyConv
}
// ValidatorPubKeyConverter -
func (ccm *CoreComponentsMock) ValidatorPubKeyConverter() core.PubkeyConverter {
return ccm.ValPubKeyConv
}
// PathHandler -
func (ccm *CoreComponentsMock) PathHandler() storage.PathManagerHandler {
return ccm.PathHdl
}
// ChainID -
func (ccm *CoreComponentsMock) ChainID() string {
if ccm.ChainIdCalled != nil {
return ccm.ChainIdCalled()
}
return "undefined"
}
// MinTransactionVersion -
func (ccm *CoreComponentsMock) MinTransactionVersion() uint32 {
if ccm.MinTransactionVersionCalled != nil {
return ccm.MinTransactionVersionCalled()
}
return 1
}
// TxVersionChecker -
func (ccm *CoreComponentsMock) TxVersionChecker() process.TxVersionCheckerHandler {
return ccm.TxVersionCheckField
}
// GenesisNodesSetup -
func (ccm *CoreComponentsMock) GenesisNodesSetup() sharding.GenesisNodesSetupHandler {
if ccm.GenesisNodesSetupCalled != nil {
return ccm.GenesisNodesSetupCalled()
}
return nil
}
// EpochNotifier -
func (ccm *CoreComponentsMock) EpochNotifier() process.EpochNotifier {
return ccm.EpochNotifierField
}
// RoundHandler -
func (ccm *CoreComponentsMock) RoundHandler() consensus.RoundHandler {
return ccm.RoundField
}
// StatusHandler -
func (ccm *CoreComponentsMock) StatusHandler() core.AppStatusHandler {
return ccm.StatusField
}
// NodeTypeProvider -
func (ccm *CoreComponentsMock) NodeTypeProvider() core.NodeTypeProviderHandler {
return ccm.NodeTypeProviderField
}
// IsInterfaceNil -
func (ccm *CoreComponentsMock) IsInterfaceNil() bool {
return ccm == nil
}