cleaned up tests

This commit is contained in:
Callum
2020-04-27 07:29:12 +02:00
parent 1e6de1ec94
commit 7a07abecc7
4 changed files with 16 additions and 0 deletions
+1
View File
@@ -29,6 +29,7 @@ func (m mockEvPoolAlwaysCommitted) PendingEvidence(int64) []types.Evidence { ret
func (m mockEvPoolAlwaysCommitted) AddEvidence(types.Evidence) error { return nil }
func (m mockEvPoolAlwaysCommitted) Update(*types.Block, sm.State) {}
func (m mockEvPoolAlwaysCommitted) IsCommitted(types.Evidence) bool { return true }
func (m mockEvPoolAlwaysCommitted) IsPending(types.Evidence) bool { return false }
func newTestApp() proxy.AppConns {
app := &testApp{}
+2
View File
@@ -43,6 +43,7 @@ type EvidencePool interface {
Update(*types.Block, State)
// IsCommitted indicates if this evidence was already marked committed in another block.
IsCommitted(types.Evidence) bool
IsPending(types.Evidence) bool
}
// MockEvidencePool is an empty implementation of EvidencePool, useful for testing.
@@ -52,3 +53,4 @@ func (m MockEvidencePool) PendingEvidence(int64) []types.Evidence { return nil }
func (m MockEvidencePool) AddEvidence(types.Evidence) error { return nil }
func (m MockEvidencePool) Update(*types.Block, State) {}
func (m MockEvidencePool) IsCommitted(types.Evidence) bool { return false }
func (m MockEvidencePool) IsPending(types.Evidence) bool { return false }
+3
View File
@@ -136,6 +136,9 @@ func validateBlock(evidencePool EvidencePool, stateDB dbm.DB, state State, block
if evidencePool.IsCommitted(ev) {
return types.NewErrEvidenceInvalid(ev, errors.New("evidence was already committed"))
}
if evidencePool.IsPending(ev) {
return nil
}
}
if err := VerifyEvidence(stateDB, state, ev, &block.Header); err != nil {
return types.NewErrEvidenceInvalid(ev, err)