(t *testing.T)
| 180 | } |
| 181 | |
| 182 | func TestEvidencePoolUpdate(t *testing.T) { |
| 183 | height := int64(21) |
| 184 | pool, val := defaultTestPool(height) |
| 185 | state := pool.State() |
| 186 | |
| 187 | // create new block (no need to save it to blockStore) |
| 188 | prunedEv := types.NewMockDuplicateVoteEvidenceWithValidator(1, defaultEvidenceTime.Add(1*time.Minute), |
| 189 | val, evidenceChainID) |
| 190 | err := pool.AddEvidence(prunedEv) |
| 191 | require.NoError(t, err) |
| 192 | ev := types.NewMockDuplicateVoteEvidenceWithValidator(height, defaultEvidenceTime.Add(21*time.Minute), |
| 193 | val, evidenceChainID) |
| 194 | lastCommit := makeCommit(height, val.PrivKey.PubKey().Address()) |
| 195 | block := types.MakeBlock(height+1, []types.Tx{}, lastCommit, []types.Evidence{ev}) |
| 196 | // update state (partially) |
| 197 | state.LastBlockHeight = height + 1 |
| 198 | state.LastBlockTime = defaultEvidenceTime.Add(22 * time.Minute) |
| 199 | err = pool.CheckEvidence(types.EvidenceList{ev}) |
| 200 | require.NoError(t, err) |
| 201 | |
| 202 | pool.Update(state, block.Evidence.Evidence) |
| 203 | // a) Update marks evidence as committed so pending evidence should be empty |
| 204 | evList, evSize := pool.PendingEvidence(defaultEvidenceMaxBytes) |
| 205 | assert.Empty(t, evList) |
| 206 | assert.Zero(t, evSize) |
| 207 | |
| 208 | // b) If we try to check this evidence again it should fail because it has already been committed |
| 209 | err = pool.CheckEvidence(types.EvidenceList{ev}) |
| 210 | if assert.Error(t, err) { |
| 211 | assert.Equal(t, "evidence was already committed", err.(*types.ErrInvalidEvidence).Reason.Error()) |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | func TestVerifyPendingEvidencePasses(t *testing.T) { |
| 216 | var height int64 = 1 |
nothing calls this directly
no test coverage detected