Browse Source

evidence: remove unused param (#4726)

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>
pull/4730/head
Marko 5 years ago
committed by GitHub
parent
commit
7a6ca0c1bf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 30 additions and 31 deletions
  1. +1
    -1
      consensus/reactor_test.go
  2. +5
    -5
      evidence/pool_test.go
  3. +2
    -2
      evidence/reactor_test.go
  4. +9
    -9
      evidence/store_test.go
  5. +4
    -4
      state/execution_test.go
  6. +2
    -3
      state/validation_test.go
  7. +4
    -4
      types/block_test.go
  8. +1
    -1
      types/evidence.go
  9. +2
    -2
      types/evidence_test.go

+ 1
- 1
consensus/reactor_test.go View File

@ -204,7 +204,7 @@ type mockEvidencePool struct {
func newMockEvidencePool(val []byte) *mockEvidencePool {
return &mockEvidencePool{
ev: []types.Evidence{types.NewMockEvidence(1, time.Now().UTC(), 1, val)},
ev: []types.Evidence{types.NewMockEvidence(1, time.Now().UTC(), val)},
}
}


+ 5
- 5
evidence/pool_test.go View File

@ -33,8 +33,8 @@ func TestEvidencePool(t *testing.T) {
blockStore = initializeBlockStore(blockStoreDB, sm.LoadState(stateDB), valAddr)
evidenceTime = time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
goodEvidence = types.NewMockEvidence(height, time.Now(), 0, valAddr)
badEvidence = types.NewMockEvidence(1, evidenceTime, 0, valAddr)
goodEvidence = types.NewMockEvidence(height, time.Now(), valAddr)
badEvidence = types.NewMockEvidence(1, evidenceTime, valAddr)
)
pool, err := NewPool(stateDB, evidenceDB, blockStore)
@ -85,7 +85,7 @@ func TestEvidencePoolIsCommitted(t *testing.T) {
require.NoError(t, err)
// evidence not seen yet:
evidence := types.NewMockEvidence(height, time.Now(), 0, valAddr)
evidence := types.NewMockEvidence(height, time.Now(), valAddr)
assert.False(t, pool.IsCommitted(evidence))
// evidence seen but not yet committed:
@ -127,7 +127,7 @@ func TestEvidencePoolAddEvidence(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.evDescription, func(t *testing.T) {
ev := types.NewMockEvidence(tc.evHeight, tc.evTime, 0, valAddr)
ev := types.NewMockEvidence(tc.evHeight, tc.evTime, valAddr)
err := pool.AddEvidence(ev)
if tc.expErr {
assert.Error(t, err)
@ -152,7 +152,7 @@ func TestEvidencePoolUpdate(t *testing.T) {
require.NoError(t, err)
// create new block (no need to save it to blockStore)
evidence := types.NewMockEvidence(height, time.Now(), 0, valAddr)
evidence := types.NewMockEvidence(height, time.Now(), valAddr)
lastCommit := makeCommit(height, valAddr)
block := types.MakeBlock(height+1, []types.Tx{}, lastCommit, []types.Evidence{evidence})
// update state (partially)


+ 2
- 2
evidence/reactor_test.go View File

@ -116,7 +116,7 @@ func _waitForEvidence(
func sendEvidence(t *testing.T, evpool *Pool, valAddr []byte, n int) types.EvidenceList {
evList := make([]types.Evidence, n)
for i := 0; i < n; i++ {
ev := types.NewMockEvidence(int64(i+1), time.Now().UTC(), 0, valAddr)
ev := types.NewMockEvidence(int64(i+1), time.Now().UTC(), valAddr)
err := evpool.AddEvidence(ev)
require.NoError(t, err)
evList[i] = ev
@ -225,7 +225,7 @@ func TestListMessageValidationBasic(t *testing.T) {
valAddr := []byte("myval")
evListMsg.Evidence = make([]types.Evidence, n)
for i := 0; i < n; i++ {
evListMsg.Evidence[i] = types.NewMockEvidence(int64(i+1), time.Now(), 0, valAddr)
evListMsg.Evidence[i] = types.NewMockEvidence(int64(i+1), time.Now(), valAddr)
}
tc.malleateEvListMsg(evListMsg)
assert.Equal(t, tc.expectErr, evListMsg.ValidateBasic() != nil, "Validate Basic had an unexpected result")


+ 9
- 9
evidence/store_test.go View File

@ -19,7 +19,7 @@ func TestStoreAddDuplicate(t *testing.T) {
store := NewStore(db)
priority := int64(10)
ev := types.NewMockEvidence(2, time.Now().UTC(), 1, []byte("val1"))
ev := types.NewMockEvidence(2, time.Now().UTC(), []byte("val1"))
added, err := store.AddNewEvidence(ev, priority)
require.NoError(t, err)
@ -36,7 +36,7 @@ func TestStoreCommitDuplicate(t *testing.T) {
store := NewStore(db)
priority := int64(10)
ev := types.NewMockEvidence(2, time.Now().UTC(), 1, []byte("val1"))
ev := types.NewMockEvidence(2, time.Now().UTC(), []byte("val1"))
store.MarkEvidenceAsCommitted(ev)
@ -56,7 +56,7 @@ func TestStoreMark(t *testing.T) {
assert.Equal(t, 0, len(pendingEv))
priority := int64(10)
ev := types.NewMockEvidence(2, time.Now().UTC(), 1, []byte("val1"))
ev := types.NewMockEvidence(2, time.Now().UTC(), []byte("val1"))
added, err := store.AddNewEvidence(ev, priority)
require.NoError(t, err)
@ -105,12 +105,12 @@ func TestStorePriority(t *testing.T) {
ev types.MockEvidence
priority int64
}{
{types.NewMockEvidence(2, time.Now().UTC(), 1, []byte("val1")), 17},
{types.NewMockEvidence(5, time.Now().UTC(), 2, []byte("val2")), 15},
{types.NewMockEvidence(10, time.Now().UTC(), 2, []byte("val2")), 13},
{types.NewMockEvidence(100, time.Now().UTC(), 2, []byte("val2")), 11},
{types.NewMockEvidence(90, time.Now().UTC(), 2, []byte("val2")), 11},
{types.NewMockEvidence(80, time.Now().UTC(), 2, []byte("val2")), 11},
{types.NewMockEvidence(2, time.Now().UTC(), []byte("val1")), 17},
{types.NewMockEvidence(5, time.Now().UTC(), []byte("val2")), 15},
{types.NewMockEvidence(10, time.Now().UTC(), []byte("val2")), 13},
{types.NewMockEvidence(100, time.Now().UTC(), []byte("val2")), 11},
{types.NewMockEvidence(90, time.Now().UTC(), []byte("val2")), 11},
{types.NewMockEvidence(80, time.Now().UTC(), []byte("val2")), 11},
}
for _, c := range cases {


+ 4
- 4
state/execution_test.go View File

@ -127,10 +127,10 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
prevParts := types.PartSetHeader{}
prevBlockID := types.BlockID{Hash: prevHash, PartsHeader: prevParts}
height1, idx1, val1 := int64(8), 0, state.Validators.Validators[0].Address
height2, idx2, val2 := int64(3), 1, state.Validators.Validators[1].Address
ev1 := types.NewMockEvidence(height1, time.Now(), idx1, val1)
ev2 := types.NewMockEvidence(height2, time.Now(), idx2, val2)
height1, val1 := int64(8), state.Validators.Validators[0].Address
height2, val2 := int64(3), state.Validators.Validators[1].Address
ev1 := types.NewMockEvidence(height1, time.Now(), val1)
ev2 := types.NewMockEvidence(height2, time.Now(), val2)
now := tmtime.Now()
valSet := state.Validators


+ 2
- 3
state/validation_test.go View File

@ -211,8 +211,7 @@ func TestValidateBlockEvidence(t *testing.T) {
for height := int64(1); height < validationTestsStopHeight; height++ {
proposerAddr := state.Validators.GetProposer().Address
proposerIdx, _ := state.Validators.GetByAddress(proposerAddr)
goodEvidence := types.NewMockEvidence(height, time.Now(), proposerIdx, proposerAddr)
goodEvidence := types.NewMockEvidence(height, time.Now(), proposerAddr)
if height > 1 {
/*
A block with too much evidence fails
@ -265,7 +264,7 @@ func TestValidateFailBlockOnCommittedEvidence(t *testing.T) {
// A block with a couple pieces of evidence passes.
block := makeBlock(state, height)
addr, _ := state.Validators.GetByIndex(0)
alreadyCommittedEvidence := types.NewMockEvidence(height, time.Now(), 0, addr)
alreadyCommittedEvidence := types.NewMockEvidence(height, time.Now(), addr)
block.Evidence.Evidence = []types.Evidence{alreadyCommittedEvidence}
block.EvidenceHash = block.Evidence.Hash()
err := blockExec.ValidateBlock(state, block)


+ 4
- 4
types/block_test.go View File

@ -40,7 +40,7 @@ func TestBlockAddEvidence(t *testing.T) {
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
require.NoError(t, err)
ev := NewMockEvidence(h, time.Now(), 0, valSet.Validators[0].Address)
ev := NewMockEvidence(h, time.Now(), valSet.Validators[0].Address)
evList := []Evidence{ev}
block := MakeBlock(h, txs, commit, evList)
@ -60,7 +60,7 @@ func TestBlockValidateBasic(t *testing.T) {
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
require.NoError(t, err)
ev := NewMockEvidence(h, time.Now(), 0, valSet.Validators[0].Address)
ev := NewMockEvidence(h, time.Now(), valSet.Validators[0].Address)
evList := []Evidence{ev}
testCases := []struct {
@ -123,7 +123,7 @@ func TestBlockMakePartSetWithEvidence(t *testing.T) {
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
require.NoError(t, err)
ev := NewMockEvidence(h, time.Now(), 0, valSet.Validators[0].Address)
ev := NewMockEvidence(h, time.Now(), valSet.Validators[0].Address)
evList := []Evidence{ev}
partSet := MakeBlock(h, []Tx{Tx("Hello World")}, commit, evList).MakePartSet(512)
@ -140,7 +140,7 @@ func TestBlockHashesTo(t *testing.T) {
commit, err := MakeCommit(lastID, h-1, 1, voteSet, vals, time.Now())
require.NoError(t, err)
ev := NewMockEvidence(h, time.Now(), 0, valSet.Validators[0].Address)
ev := NewMockEvidence(h, time.Now(), valSet.Validators[0].Address)
evList := []Evidence{ev}
block := MakeBlock(h, []Tx{Tx("Hello World")}, commit, evList)


+ 1
- 1
types/evidence.go View File

@ -957,7 +957,7 @@ type MockEvidence struct {
var _ Evidence = &MockEvidence{}
// UNSTABLE
func NewMockEvidence(height int64, eTime time.Time, idx int, address []byte) MockEvidence {
func NewMockEvidence(height int64, eTime time.Time, address []byte) MockEvidence {
return MockEvidence{
EvidenceHeight: height,
EvidenceTime: eTime,


+ 2
- 2
types/evidence_test.go View File

@ -171,12 +171,12 @@ func TestDuplicateVoteEvidenceValidation(t *testing.T) {
}
func TestMockGoodEvidenceValidateBasic(t *testing.T) {
goodEvidence := NewMockEvidence(int64(1), time.Now(), 1, []byte{1})
goodEvidence := NewMockEvidence(int64(1), time.Now(), []byte{1})
assert.Nil(t, goodEvidence.ValidateBasic())
}
func TestMockBadEvidenceValidateBasic(t *testing.T) {
badEvidence := NewMockEvidence(int64(1), time.Now(), 1, []byte{1})
badEvidence := NewMockEvidence(int64(1), time.Now(), []byte{1})
assert.Nil(t, badEvidence.ValidateBasic())
}


Loading…
Cancel
Save