fix lightchain unit tests

This commit is contained in:
Tuna 2019-01-12 15:14:24 +07:00
parent 196def5fc2
commit 148495ccfd
3 changed files with 3 additions and 12 deletions

View file

@ -1684,11 +1684,7 @@ Error: %v
// because nonces can be verified sparsely, not needing to check each.
func (bc *BlockChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
start := time.Now()
state, err := bc.State()
if err != nil {
return 0, err
}
if i, err := bc.hc.ValidateHeaderChain(chain, state, checkFreq); err != nil {
if i, err := bc.hc.ValidateHeaderChain(chain, checkFreq); err != nil {
return i, err
}

View file

@ -33,7 +33,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/hashicorp/golang-lru"
"github.com/ethereum/go-ethereum/core/state"
)
const (
@ -204,7 +203,7 @@ func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, er
// header writes should be protected by the parent chain mutex individually.
type WhCallback func(*types.Header) error
func (hc *HeaderChain) ValidateHeaderChain(chain []*types.Header, state *state.StateDB, checkFreq int) (int, error) {
func (hc *HeaderChain) ValidateHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
// Do a sanity check that the provided chain is actually ordered and linked
for i := 1; i < len(chain); i++ {
if chain[i].Number.Uint64() != chain[i-1].Number.Uint64()+1 || chain[i].ParentHash != chain[i-1].Hash() {

View file

@ -344,11 +344,7 @@ func (self *LightChain) postChainEvents(events []interface{}) {
// chain events when necessary.
func (self *LightChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
start := time.Now()
state, err := self.State()
if err != nil {
return 0, err
}
if i, err := self.hc.ValidateHeaderChain(chain, state, checkFreq); err != nil {
if i, err := self.hc.ValidateHeaderChain(chain, checkFreq); err != nil {
return i, err
}