FIX UNITTESTS

This commit is contained in:
AnilChinchawale 2018-06-30 15:07:40 +05:30
parent f7fac4ec91
commit 5f79d00d04
2 changed files with 12 additions and 6 deletions

View file

@ -47,8 +47,8 @@ import (
var (
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
ErrNoGenesis = errors.New("Genesis not found in chain")
Checkpoint = make(chan int)
ErrNoGenesis = errors.New("Genesis not found in chain")
)
const (
@ -1185,6 +1185,11 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty
stats.processed++
stats.usedGas += usedGas
stats.report(chain, i, bc.stateCache.TrieDB().Size())
if i == len(chain)-1 {
if (bc.chainConfig.Clique != nil) && (chain[i].NumberU64()%bc.chainConfig.Clique.Epoch) == 0 {
Checkpoint <- 1
}
}
}
// Append a single chain head event if we've progressed the chain
if lastCanon != nil && bc.CurrentBlock().Hash() == lastCanon.Hash() {
@ -1422,11 +1427,9 @@ func (bc *BlockChain) reportBlock(block *types.Block, receipts types.Receipts, e
log.Error(fmt.Sprintf(`
########## BAD BLOCK #########
Chain config: %v
Number: %v
Hash: 0x%x
%v
Error: %v
##############################
`, bc.chainConfig, block.Number(), block.Hash(), receiptString, err))
@ -1561,4 +1564,4 @@ func (bc *BlockChain) SubscribeChainSideEvent(ch chan<- ChainSideEvent) event.Su
// SubscribeLogsEvent registers a subscription of []*types.Log.
func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription {
return bc.scope.Track(bc.logsFeed.Subscribe(ch))
}
}

View file

@ -488,6 +488,9 @@ func (self *worker) commitNewWork() {
log.Info("Commit new mining work", "number", work.Block.Number(), "txs", work.tcount, "uncles", len(uncles), "elapsed", common.PrettyDuration(time.Since(tstart)))
self.unconfirmed.Shift(work.Block.NumberU64() - 1)
}
if (work.config.Clique != nil) && (work.Block.NumberU64()%work.config.Clique.Epoch) == 0 {
core.Checkpoint <- 1
}
self.push(work)
}
@ -601,4 +604,4 @@ func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, c
env.receipts = append(env.receipts, receipt)
return nil, receipt.Logs
}
}