mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
9be8a456eb
* Sweeping replace of ssz.HashTreeRoot(block) to stateutil.BlockRoot, minor tweaks to critical path of proposeBlock * imports * Merge branch 'master' into better-block-htr * Add --enable-custom-block-htr to e2e flags * Merge branch 'better-block-htr' of github.com:prysmaticlabs/prysm into better-block-htr
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package stateutil_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
)
|
|
|
|
func TestBlockRoot(t *testing.T) {
|
|
resetCfg := featureconfig.InitWithReset(&featureconfig.Flags{EnableBlockHTR: true})
|
|
defer resetCfg()
|
|
genState, keys := testutil.DeterministicGenesisState(t, 100)
|
|
blk, err := testutil.GenerateFullBlock(genState, keys, testutil.DefaultBlockGenConfig(), 10)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
expectedRoot, err := stateutil.BlockRoot(blk.Block)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
receivedRoot, err := stateutil.BlockRoot(blk.Block)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if receivedRoot != expectedRoot {
|
|
t.Fatalf("Wanted %#x but got %#x", expectedRoot, receivedRoot)
|
|
}
|
|
blk, err = testutil.GenerateFullBlock(genState, keys, testutil.DefaultBlockGenConfig(), 100)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
expectedRoot, err = stateutil.BlockRoot(blk.Block)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
receivedRoot, err = stateutil.BlockRoot(blk.Block)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if receivedRoot != expectedRoot {
|
|
t.Fatalf("Wanted %#x but got %#x", expectedRoot, receivedRoot)
|
|
}
|
|
}
|