MCPcopy Create free account
hub / github.com/tendermint/tendermint / TestCommitValidateBasic

Function TestCommitValidateBasic

types/block_test.go:252–271  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

250}
251
252func TestCommitValidateBasic(t *testing.T) {
253 testCases := []struct {
254 testName string
255 malleateCommit func(*Commit)
256 expectErr bool
257 }{
258 {"Random Commit", func(com *Commit) {}, false},
259 {"Incorrect signature", func(com *Commit) { com.Signatures[0].Signature = []byte{0} }, false},
260 {"Incorrect height", func(com *Commit) { com.Height = int64(-100) }, true},
261 {"Incorrect round", func(com *Commit) { com.Round = -100 }, true},
262 }
263 for _, tc := range testCases {
264 tc := tc
265 t.Run(tc.testName, func(t *testing.T) {
266 com := randCommit(time.Now())
267 tc.malleateCommit(com)
268 assert.Equal(t, tc.expectErr, com.ValidateBasic() != nil, "Validate Basic had an unexpected result")
269 })
270 }
271}
272
273func TestMaxCommitBytes(t *testing.T) {
274 // time is varint encoded so need to pick the max.

Callers

nothing calls this directly

Calls 5

NowFunction · 0.92
randCommitFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65
ValidateBasicMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…