(t *testing.T)
| 250 | } |
| 251 | |
| 252 | func 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 | |
| 273 | func TestMaxCommitBytes(t *testing.T) { |
| 274 | // time is varint encoded so need to pick the max. |
nothing calls this directly
no test coverage detected
searching dependent graphs…