diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-18 20:14:21 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-18 20:14:21 +0800 |
commit | 655e94259765b02454df93205a30a271103de5a0 (patch) | |
tree | 818cd1e9156dda16d78257b2ad656edeb0058759 /core/block_processor_test.go | |
parent | be90ad89a89502ef3d2c0375d267b667618f5e7c (diff) | |
download | dexon-655e94259765b02454df93205a30a271103de5a0.tar.gz dexon-655e94259765b02454df93205a30a271103de5a0.tar.zst dexon-655e94259765b02454df93205a30a271103de5a0.zip |
Added GetBlock GetUncle with OOB guard
Diffstat (limited to 'core/block_processor_test.go')
-rw-r--r-- | core/block_processor_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/core/block_processor_test.go b/core/block_processor_test.go new file mode 100644 index 000000000..35aeaa714 --- /dev/null +++ b/core/block_processor_test.go @@ -0,0 +1,34 @@ +package core + +import ( + "math/big" + "testing" + + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/event" +) + +func proc() (*BlockProcessor, *ChainManager) { + db, _ := ethdb.NewMemDatabase() + var mux event.TypeMux + + chainMan := NewChainManager(db, &mux) + return NewBlockProcessor(db, nil, chainMan, &mux), chainMan +} + +func TestNumber(t *testing.T) { + bp, chain := proc() + block1 := chain.NewBlock(nil) + block1.Header().Number = big.NewInt(3) + + err := bp.ValidateBlock(block1, chain.Genesis()) + if err != BlockNumberErr { + t.Errorf("expected block number error") + } + + block1 = chain.NewBlock(nil) + err = bp.ValidateBlock(block1, chain.Genesis()) + if err == BlockNumberErr { + t.Errorf("didn't expect block number error") + } +} |