(cm *core.BlockChain, validBlocks []btBlock)
| 253 | } |
| 254 | |
| 255 | func (t *BlockTest) validateImportedHeaders(cm *core.BlockChain, validBlocks []btBlock) error { |
| 256 | // to get constant lookup when verifying block headers by hash (some tests have many blocks) |
| 257 | bmap := make(map[common.Hash]btBlock, len(t.json.Blocks)) |
| 258 | for _, b := range validBlocks { |
| 259 | bmap[b.BlockHeader.Hash] = b |
| 260 | } |
| 261 | // iterate over blocks backwards from HEAD and validate imported |
| 262 | // headers vs test file. some tests have reorgs, and we import |
| 263 | // block-by-block, so we can only validate imported headers after |
| 264 | // all blocks have been processed by BlockChain, as they may not |
| 265 | // be part of the longest chain until last block is imported. |
| 266 | for b := cm.CurrentBlock(); b != nil && b.NumberU64() != 0; b = cm.GetBlockByHash(b.Header().ParentHash) { |
| 267 | if err := validateHeader(bmap[b.Hash()].BlockHeader, b.Header()); err != nil { |
| 268 | return fmt.Errorf("Imported block header validation failed: %v", err) |
| 269 | } |
| 270 | } |
| 271 | return nil |
| 272 | } |
| 273 | |
| 274 | func (bb *btBlock) decode() (*types.Block, error) { |
| 275 | data, err := hexutil.Decode(bb.Rlp) |
no test coverage detected