Merge pull request #426 from Gustav-Simonsson/add_blockchain_tests

Add initial implementation of block tests
This commit is contained in:
Jeffrey Wilcke
2015-03-05 17:43:56 +01:00
4 changed files with 377 additions and 1 deletions

View File

@ -234,6 +234,21 @@ func (bc *ChainManager) Reset() {
bc.setTotalDifficulty(ethutil.Big("0"))
}
func (bc *ChainManager) ResetWithGenesisBlock(gb *types.Block) {
bc.mu.Lock()
defer bc.mu.Unlock()
for block := bc.currentBlock; block != nil; block = bc.GetBlock(block.Header().ParentHash) {
bc.db.Delete(block.Hash())
}
// Prepare the genesis block
bc.genesisBlock = gb
bc.write(bc.genesisBlock)
bc.insert(bc.genesisBlock)
bc.currentBlock = bc.genesisBlock
}
func (self *ChainManager) Export() []byte {
self.mu.RLock()
defer self.mu.RUnlock()