mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
fix unit tests: remove state
This commit is contained in:
parent
337b7c64ee
commit
7c1e1e0abe
3 changed files with 8 additions and 15 deletions
|
|
@ -48,13 +48,12 @@ func TestHeaderVerification(t *testing.T) {
|
|||
for i := 0; i < len(blocks); i++ {
|
||||
for j, valid := range []bool{true, false} {
|
||||
var results <-chan error
|
||||
state, _ := chain.State()
|
||||
if valid {
|
||||
engine := ethash.NewFaker()
|
||||
_, results = engine.VerifyHeaders(chain, state, []*types.Header{headers[i]}, []bool{true})
|
||||
_, results = engine.VerifyHeaders(chain, []*types.Header{headers[i]}, []bool{true})
|
||||
} else {
|
||||
engine := ethash.NewFakeFailer(headers[i].Number.Uint64())
|
||||
_, results = engine.VerifyHeaders(chain, state, []*types.Header{headers[i]}, []bool{true})
|
||||
_, results = engine.VerifyHeaders(chain, []*types.Header{headers[i]}, []bool{true})
|
||||
}
|
||||
// Wait for the verification result
|
||||
select {
|
||||
|
|
@ -106,13 +105,11 @@ func testHeaderConcurrentVerification(t *testing.T, threads int) {
|
|||
var results <-chan error
|
||||
if valid {
|
||||
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{})
|
||||
state, _ := chain.State()
|
||||
_, results = chain.engine.VerifyHeaders(chain, state, headers, seals)
|
||||
_, results = chain.engine.VerifyHeaders(chain, headers, seals)
|
||||
chain.Stop()
|
||||
} else {
|
||||
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeFailer(uint64(len(headers)-1)), vm.Config{})
|
||||
state, _ := chain.State()
|
||||
_, results = chain.engine.VerifyHeaders(chain, state, headers, seals)
|
||||
_, results = chain.engine.VerifyHeaders(chain, headers, seals)
|
||||
chain.Stop()
|
||||
}
|
||||
// Wait for all the verification results
|
||||
|
|
@ -176,8 +173,7 @@ func testHeaderConcurrentAbortion(t *testing.T, threads int) {
|
|||
// Start the verifications and immediately abort
|
||||
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeDelayer(time.Millisecond), vm.Config{})
|
||||
defer chain.Stop()
|
||||
state, _ := chain.State()
|
||||
abort, results := chain.engine.VerifyHeaders(chain, state, headers, seals)
|
||||
abort, results := chain.engine.VerifyHeaders(chain, headers, seals)
|
||||
close(abort)
|
||||
|
||||
// Deplete the results channel
|
||||
|
|
|
|||
|
|
@ -103,8 +103,7 @@ func printChain(bc *BlockChain) {
|
|||
func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error {
|
||||
for _, block := range chain {
|
||||
// Try and process the block
|
||||
st, _ := blockchain.State()
|
||||
err := blockchain.engine.VerifyHeader(blockchain, st, block.Header(), true)
|
||||
err := blockchain.engine.VerifyHeader(blockchain, block.Header(), true)
|
||||
if err == nil {
|
||||
err = blockchain.validator.ValidateBody(block)
|
||||
}
|
||||
|
|
@ -142,8 +141,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error {
|
|||
func testHeaderChainImport(chain []*types.Header, blockchain *BlockChain) error {
|
||||
for _, header := range chain {
|
||||
// Try and validate the header
|
||||
state, _ := blockchain.State()
|
||||
if err := blockchain.engine.VerifyHeader(blockchain, state, header, false); err != nil {
|
||||
if err := blockchain.engine.VerifyHeader(blockchain, header, false); err != nil {
|
||||
return err
|
||||
}
|
||||
// Manually insert the header into the database, but don't reorganise (allows subsequent testing)
|
||||
|
|
|
|||
|
|
@ -117,8 +117,7 @@ func testFork(t *testing.T, LightChain *LightChain, i, n int, comparator func(td
|
|||
func testHeaderChainImport(chain []*types.Header, lightchain *LightChain) error {
|
||||
for _, header := range chain {
|
||||
// Try and validate the header
|
||||
state, _ := lightchain.State()
|
||||
if err := lightchain.engine.VerifyHeader(lightchain.hc, state, header, true); err != nil {
|
||||
if err := lightchain.engine.VerifyHeader(lightchain.hc, header, true); err != nil {
|
||||
return err
|
||||
}
|
||||
// Manually insert the header into the database, but don't reorganize (allows subsequent testing)
|
||||
|
|
|
|||
Loading…
Reference in a new issue