MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / TestConsensusConfig_ValidateBasic

Function TestConsensusConfig_ValidateBasic

config/config_test.go:144–184  ·  view source on GitHub ↗

nolint:lll

(t *testing.T)

Source from the content-addressed store, hash-verified

142
143//nolint:lll
144func TestConsensusConfig_ValidateBasic(t *testing.T) {
145 testcases := map[string]struct {
146 modify func(*ConsensusConfig)
147 expectErr bool
148 }{
149 "TimeoutPropose": {func(c *ConsensusConfig) { c.TimeoutPropose = time.Second }, false},
150 "TimeoutPropose negative": {func(c *ConsensusConfig) { c.TimeoutPropose = -1 }, true},
151 "TimeoutProposeDelta": {func(c *ConsensusConfig) { c.TimeoutProposeDelta = time.Second }, false},
152 "TimeoutProposeDelta negative": {func(c *ConsensusConfig) { c.TimeoutProposeDelta = -1 }, true},
153 "TimeoutPrevote": {func(c *ConsensusConfig) { c.TimeoutPrevote = time.Second }, false},
154 "TimeoutPrevote negative": {func(c *ConsensusConfig) { c.TimeoutPrevote = -1 }, true},
155 "TimeoutPrevoteDelta": {func(c *ConsensusConfig) { c.TimeoutPrevoteDelta = time.Second }, false},
156 "TimeoutPrevoteDelta negative": {func(c *ConsensusConfig) { c.TimeoutPrevoteDelta = -1 }, true},
157 "TimeoutPrecommit": {func(c *ConsensusConfig) { c.TimeoutPrecommit = time.Second }, false},
158 "TimeoutPrecommit negative": {func(c *ConsensusConfig) { c.TimeoutPrecommit = -1 }, true},
159 "TimeoutPrecommitDelta": {func(c *ConsensusConfig) { c.TimeoutPrecommitDelta = time.Second }, false},
160 "TimeoutPrecommitDelta negative": {func(c *ConsensusConfig) { c.TimeoutPrecommitDelta = -1 }, true},
161 "TimeoutCommit": {func(c *ConsensusConfig) { c.TimeoutCommit = time.Second }, false},
162 "TimeoutCommit negative": {func(c *ConsensusConfig) { c.TimeoutCommit = -1 }, true},
163 "PeerGossipSleepDuration": {func(c *ConsensusConfig) { c.PeerGossipSleepDuration = time.Second }, false},
164 "PeerGossipSleepDuration negative": {func(c *ConsensusConfig) { c.PeerGossipSleepDuration = -1 }, true},
165 "PeerQueryMaj23SleepDuration": {func(c *ConsensusConfig) { c.PeerQueryMaj23SleepDuration = time.Second }, false},
166 "PeerQueryMaj23SleepDuration negative": {func(c *ConsensusConfig) { c.PeerQueryMaj23SleepDuration = -1 }, true},
167 "DoubleSignCheckHeight negative": {func(c *ConsensusConfig) { c.DoubleSignCheckHeight = -1 }, true},
168 }
169
170 for desc, tc := range testcases {
171 tc := tc // appease linter
172 t.Run(desc, func(t *testing.T) {
173 cfg := DefaultConsensusConfig()
174 tc.modify(cfg)
175
176 err := cfg.ValidateBasic()
177 if tc.expectErr {
178 assert.Error(t, err)
179 } else {
180 assert.NoError(t, err)
181 }
182 })
183 }
184}
185
186func TestInstrumentationConfigValidateBasic(t *testing.T) {
187 cfg := TestInstrumentationConfig()

Callers

nothing calls this directly

Calls 4

DefaultConsensusConfigFunction · 0.85
RunMethod · 0.65
ValidateBasicMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected