Add initial implementation of block tests
* Add blocktest cmd and support for block tests files in tests/BlockTests , the launched node does not connect to network, resets state with a genesis block from the test file and starts the RPC API
This commit is contained in:
@ -231,6 +231,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()
|
||||
|
@ -22,7 +22,7 @@ func (err *ParentErr) Error() string {
|
||||
}
|
||||
|
||||
func ParentError(hash []byte) error {
|
||||
return &ParentErr{Message: fmt.Sprintf("Block's parent unkown %x", hash)}
|
||||
return &ParentErr{Message: fmt.Sprintf("Block's parent unknown %x", hash)}
|
||||
}
|
||||
|
||||
func IsParentErr(err error) bool {
|
||||
|
Reference in New Issue
Block a user