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

Function validateHeader

tests/block_test_util.go:198–233  ·  view source on GitHub ↗
(h *btHeader, h2 *types.Header)

Source from the content-addressed store, hash-verified

196}
197
198func validateHeader(h *btHeader, h2 *types.Header) error {
199 if h.Bloom != h2.LogsBloom {
200 return fmt.Errorf("LogsBloom: want: %x have: %x", h.Bloom, h2.LogsBloom)
201 }
202 if h.Coinbase != h2.Coinbase {
203 return fmt.Errorf("Coinbase: want: %x have: %x", h.Coinbase, h2.Coinbase)
204 }
205 if h.Number.Cmp(h2.Number) != 0 {
206 return fmt.Errorf("Number: want: %v have: %v", h.Number, h2.Number)
207 }
208 if h.ParentHash != h2.ParentHash {
209 return fmt.Errorf("Parent hash: want: %x have: %x", h.ParentHash, h2.ParentHash)
210 }
211 if h.ReceiptTrie != h2.ReceiptsRoot {
212 return fmt.Errorf("Receipt hash: want: %x have: %x", h.ReceiptTrie, h2.ReceiptsRoot)
213 }
214 if h.TransactionsTrie != h2.TxsRoot {
215 return fmt.Errorf("Tx hash: want: %x have: %x", h.TransactionsTrie, h2.TxsRoot)
216 }
217 if h.StateRoot != h2.StateRoot {
218 return fmt.Errorf("State hash: want: %x have: %x", h.StateRoot, h2.StateRoot)
219 }
220 if !bytes.Equal(h.ExtraData, h2.Extra) {
221 return fmt.Errorf("Extra data: want: %x have: %x", h.ExtraData, h2.Extra)
222 }
223 if h.GasLimit != h2.GasLimit {
224 return fmt.Errorf("GasLimit: want: %d have: %d", h.GasLimit, h2.GasLimit)
225 }
226 if h.GasUsed != h2.GasUsed {
227 return fmt.Errorf("GasUsed: want: %d have: %d", h.GasUsed, h2.GasUsed)
228 }
229 if h.Timestamp.Cmp(h2.Time) != 0 {
230 return fmt.Errorf("Timestamp: want: %v have: %v", h.Timestamp, h2.Time)
231 }
232 return nil
233}
234
235func (t *BlockTest) validatePostState(statedb *state.StateDB) error {
236 // validate post state accounts in test file against what we have in state db

Callers 2

insertBlocksMethod · 0.85

Calls 2

CmpMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected