aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-03-04 01:41:51 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-03-05 03:27:09 +0800
commit871dfd399be8ee657109112d527645c2c1b3a8f9 (patch)
tree8daf0d07fdd308b55302dcbf11845657b97883e8 /core/chain_manager.go
parent15f491e5007d1507f20d0edce36cc9c0bd5cbd37 (diff)
downloaddexon-871dfd399be8ee657109112d527645c2c1b3a8f9.tar.gz
dexon-871dfd399be8ee657109112d527645c2c1b3a8f9.tar.zst
dexon-871dfd399be8ee657109112d527645c2c1b3a8f9.zip
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
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index f2382cf8d..17bfb1f3e 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -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()