Browse Source

rpc: /broadcast_evidence nil evidence check (#5109)

pull/5116/head
Callum Waters 5 years ago
committed by GitHub
parent
commit
c552a5b21e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions
  1. +7
    -0
      rpc/client/evidence_test.go
  2. +5
    -0
      rpc/core/evidence.go

+ 7
- 0
rpc/client/evidence_test.go View File

@ -222,3 +222,10 @@ func TestBroadcastEvidence_ConflictingHeadersEvidence(t *testing.T) {
assert.Equal(t, ev.Hash(), result.Hash, "expected result hash to match evidence hash")
}
}
func TestBroadcastEmptyEvidence(t *testing.T) {
for _, c := range GetClients() {
_, err := c.BroadcastEvidence(nil)
assert.Error(t, err)
}
}

+ 5
- 0
rpc/core/evidence.go View File

@ -1,6 +1,7 @@
package core
import (
"errors"
"fmt"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
@ -11,6 +12,10 @@ import (
// BroadcastEvidence broadcasts evidence of the misbehavior.
// More: https://docs.tendermint.com/master/rpc/#/Info/broadcast_evidence
func BroadcastEvidence(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
if ev == nil {
return nil, errors.New("no evidence was provided")
}
if err := ev.ValidateBasic(); err != nil {
return nil, fmt.Errorf("evidence.ValidateBasic failed: %w", err)
}


Loading…
Cancel
Save