func proc() (*BlockProcessor, *ChainManager) { db, _ := ethdb.NewMemDatabase() var mux event.TypeMux chainMan := NewChainManager(db, db, &mux) return NewBlockProcessor(db, db, ezp.New(), nil, chainMan, &mux), chainMan }
func proc() (*BlockProcessor, *ChainManager) { db, _ := ethdb.NewMemDatabase() var mux event.TypeMux genesis := GenesisBlock(0, db) chainMan, err := NewChainManager(genesis, db, db, thePow(), &mux) if err != nil { fmt.Println(err) } return NewBlockProcessor(db, db, ezp.New(), chainMan, &mux), chainMan }
func TestNumber(t *testing.T) { pow := ezp.New() _, chain := proc() statedb := state.New(chain.Genesis().Root(), chain.stateDb) header := makeHeader(chain.Genesis(), statedb) header.Number = big.NewInt(3) err := ValidateHeader(pow, header, chain.Genesis(), false) if err != BlockNumberErr { t.Errorf("expected block number error, got %q", err) } header = makeHeader(chain.Genesis(), statedb) err = ValidateHeader(pow, header, chain.Genesis(), false) if err == BlockNumberErr { t.Errorf("didn't expect block number error") } }
func TestNumber(t *testing.T) { _, chain := proc() block1 := chain.NewBlock(common.Address{}) block1.Header().Number = big.NewInt(3) block1.Header().Time-- pow := ezp.New() err := ValidateHeader(pow, block1.Header(), chain.Genesis().Header(), false) if err != BlockNumberErr { t.Errorf("expected block number error %v", err) } block1 = chain.NewBlock(common.Address{}) err = ValidateHeader(pow, block1.Header(), chain.Genesis().Header(), false) if err == BlockNumberErr { t.Errorf("didn't expect block number error") } }