MCPcopy Create free account
hub / github.com/CPChain/chain / testHeaderChainImport

Function testHeaderChainImport

core/blockchain_test.go:141–153  ·  view source on GitHub ↗

testHeaderChainImport tries to process a chain of header, writing them into the database if successful.

(chain []*types.Header, blockchain *BlockChain)

Source from the content-addressed store, hash-verified

139// testHeaderChainImport tries to process a chain of header, writing them into
140// the database if successful.
141func testHeaderChainImport(chain []*types.Header, blockchain *BlockChain) error {
142 for _, header := range chain {
143 // Try and validate the header
144 if err := blockchain.engine.VerifyHeader(blockchain, header, false, nil); err != nil {
145 return err
146 }
147 // Manually insert the header into the database, but don't reorganise (allows subsequent testing)
148 blockchain.mu.Lock()
149 rawdb.WriteHeader(blockchain.db, header)
150 blockchain.mu.Unlock()
151 }
152 return nil
153}
154
155func TestLastBlock(t *testing.T) {
156 db := database.NewMemDatabase()

Callers

nothing calls this directly

Calls 4

LockMethod · 0.80
WriteHeaderMethod · 0.80
UnlockMethod · 0.80
VerifyHeaderMethod · 0.65

Tested by

no test coverage detected