diff --git a/evidence/pool_test.go b/evidence/pool_test.go index 8f696a640..38b0b8f86 100644 --- a/evidence/pool_test.go +++ b/evidence/pool_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/line/ostracon/crypto" "github.com/line/ostracon/crypto/bls" "github.com/line/ostracon/crypto/composite" "github.com/line/ostracon/crypto/ed25519" @@ -325,12 +326,11 @@ func TestLightClientAttackEvidenceLifecycle(t *testing.T) { func TestRecoverPendingEvidence(t *testing.T) { height := int64(10) val := types.NewMockPV(types.PrivKeyComposite) // TODO 🏺 need to test by all key types - valAddress := val.PrivKey.PubKey().Address() evidenceDB := dbm.NewMemDB() stateStore := initializeValidatorState(val, height) state, err := stateStore.Load() require.NoError(t, err) - blockStore := initializeBlockStore(dbm.NewMemDB(), state, valAddress) + blockStore := initializeBlockStore(dbm.NewMemDB(), state, val.PrivKey) // create previous pool and populate it pool, err := evidence.NewPool(evidenceDB, stateStore, blockStore) require.NoError(t, err) @@ -424,13 +424,15 @@ func initializeValidatorState(privVal types.PrivValidator, height int64) sm.Stor // initializeBlockStore creates a block storage and populates it w/ a dummy // block at +height+. -func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) *store.BlockStore { +func initializeBlockStore(db dbm.DB, state sm.State, valPrivkey crypto.PrivKey) *store.BlockStore { blockStore := store.NewBlockStore(db) + valAddr := valPrivkey.PubKey().Address() for i := int64(1); i <= state.LastBlockHeight; i++ { round := int32(0) lastCommit := makeCommit(i-1, valAddr) - proof := state.MakeHashMessage(round) + message := state.MakeHashMessage(round) + proof, _ := valPrivkey.VRFProve(message) block, _ := state.MakeBlock(i, []types.Tx{}, lastCommit, nil, state.Validators.SelectProposer(proof, i, round).Address, round, proof) block.Header.Time = defaultEvidenceTime.Add(time.Duration(i) * time.Minute) @@ -457,11 +459,10 @@ func makeCommit(height int64, valAddr []byte) *types.Commit { func defaultTestPool(height int64) (*evidence.Pool, types.MockPV) { val := types.NewMockPV(types.PrivKeyComposite) // TODO 🏺 need to test by all key types - valAddress := val.PrivKey.PubKey().Address() evidenceDB := dbm.NewMemDB() stateStore := initializeValidatorState(val, height) state, _ := stateStore.Load() - blockStore := initializeBlockStore(dbm.NewMemDB(), state, valAddress) + blockStore := initializeBlockStore(dbm.NewMemDB(), state, val.PrivKey) pool, err := evidence.NewPool(evidenceDB, stateStore, blockStore) if err != nil { panic("test evidence pool could not be created") diff --git a/evidence/verify_test.go b/evidence/verify_test.go index d8a3b5fbc..44d81a3e2 100644 --- a/evidence/verify_test.go +++ b/evidence/verify_test.go @@ -8,8 +8,6 @@ import ( "github.com/line/ostracon/light" - "github.com/coniks-sys/coniks-go/crypto/vrf" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -17,6 +15,7 @@ import ( "github.com/line/ostracon/crypto" "github.com/line/ostracon/crypto/tmhash" + "github.com/line/ostracon/crypto/vrf" "github.com/line/ostracon/evidence" "github.com/line/ostracon/evidence/mocks" "github.com/line/ostracon/libs/log" @@ -735,7 +734,7 @@ func makeHeaderRandom(height int64) *types.Header { LastResultsHash: crypto.CRandBytes(tmhash.Size), EvidenceHash: crypto.CRandBytes(tmhash.Size), ProposerAddress: crypto.CRandBytes(crypto.AddressSize), - Proof: crypto.CRandBytes(vrf.ProofSize), + Proof: crypto.CRandBytes(vrf.ProofLength()), } } diff --git a/types/block_test.go b/types/block_test.go index e0163a929..9c0535b1b 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -518,8 +518,8 @@ func TestHeaderHash(t *testing.T) { EvidenceHash: tmhash.Sum([]byte("evidence_hash")), ProposerAddress: crypto.AddressHash([]byte("proposer_address")), Round: 1, - Proof: tmhash.Sum([]byte("proof")), - }, hexBytesFromString("0368E6F15B6B7BC9DC5B10F36F37D6F867E132A22333F083A11290324274E183")}, + Proof: make([]byte, vrf.ProofLength()), + }, hexBytesFromString("5616282392957326AF5D014F227B82C9EB1081CD7FB85C8BAE1476E2E3BF77F8")}, {"nil header yields nil", nil, nil}, {"nil VotersHash yields nil", &Header{ Version: tmversion.Consensus{Block: 1, App: 2}, @@ -537,7 +537,7 @@ func TestHeaderHash(t *testing.T) { EvidenceHash: tmhash.Sum([]byte("evidence_hash")), ProposerAddress: crypto.AddressHash([]byte("proposer_address")), Round: 1, - Proof: tmhash.Sum([]byte("proof")), + Proof: make([]byte, vrf.ProofLength()), }, nil}, } for _, tc := range testCases {