github.com/line/ostracon@v1.0.10-0.20230328032236-7f20145f065d/test/e2e/tests/evidence_test.go (about) 1 package e2e_test 2 3 import ( 4 "bytes" 5 "testing" 6 7 e2e "github.com/line/ostracon/test/e2e/pkg" 8 "github.com/line/ostracon/types" 9 ) 10 11 // assert that all nodes that have blocks at the height of a misbehavior has evidence 12 // for that misbehavior 13 func TestEvidence_Misbehavior(t *testing.T) { 14 blocks := fetchBlockChain(t) 15 testNode(t, func(t *testing.T, node e2e.Node) { 16 for _, block := range blocks { 17 // Find any evidence blaming this node in this block 18 var nodeEvidence types.Evidence 19 for _, evidence := range block.Evidence.Evidence { 20 switch evidence := evidence.(type) { 21 case *types.DuplicateVoteEvidence: 22 if bytes.Equal(evidence.VoteA.ValidatorAddress, node.PrivvalKey.PubKey().Address()) { 23 nodeEvidence = evidence 24 } 25 default: 26 t.Fatalf("unexpected evidence type %T", evidence) 27 } 28 } 29 if nodeEvidence == nil { 30 continue // no evidence for the node at this height 31 } 32 } 33 }) 34 }