From 11d584e67b4232bc7bbf447d0e43e0ef8ff095d8 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Mon, 4 Jul 2022 11:24:06 +0200 Subject: [PATCH] core: allow external code to set the block validator for malicious tests (#25119) * core: don't validate state * core: allow external validator * core: revert * core: comments * Update blockchain_reader.go * core: move SetValidator to blockchain.go * core: rename method --- core/blockchain.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index 0a5ba1da0b27..352871390712 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2374,3 +2374,10 @@ func (bc *BlockChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (i _, err := bc.hc.InsertHeaderChain(chain, start, bc.forker) return 0, err } + +// SetBlockValidatorForTesting sets the current validator. +// This method can be used to force an invalid blockchain to be verified for tests. +// This method is unsafe and should only be used before block import starts. +func (bc *BlockChain) SetBlockValidatorForTesting(v Validator) { + bc.validator = v +}