cmd/devp2p: implement snap protocol testing (#24276)

This also contains some changes to the protocol handler to
make the tests pass.
This commit is contained in:
Martin Holst Swende
2022-02-04 15:24:32 +01:00
committed by GitHub
parent aaca58a7a1
commit 6ce4670bc0
9 changed files with 864 additions and 18 deletions

View File

@ -26,6 +26,7 @@ import (
"os"
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/forkid"
"github.com/ethereum/go-ethereum/core/types"
@ -67,6 +68,13 @@ func (c *Chain) TotalDifficultyAt(height int) *big.Int {
return sum
}
func (c *Chain) RootAt(height int) common.Hash {
if height < c.Len() {
return c.blocks[height].Root()
}
return common.Hash{}
}
// ForkID gets the fork id of the chain.
func (c *Chain) ForkID() forkid.ID {
return forkid.NewID(c.chainConfig, c.blocks[0].Hash(), uint64(c.Len()))