mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 16:37:39 +00:00
44b93d9df9
* fixes segfault * Merge branch 'master' into fix-nil-segfaults * upd state * Merge branch 'master' into fix-nil-segfaults * updates shard=1 * Merge refs/heads/master into fix-nil-segfaults * Merge refs/heads/master into fix-nil-segfaults * Merge refs/heads/master into fix-nil-segfaults * fixes tests * Merge branch 'fix-nil-segfaults' of github.com:prysmaticlabs/prysm into fix-nil-segfaults * reset config to nil * add flag assertion to other beacon-chain/rpc files * Merge refs/heads/master into fix-nil-segfaults * fix the rest featureconfig.init calls * Merge branch 'fix-nil-segfaults' of github.com:prysmaticlabs/prysm into fix-nil-segfaults * remove config setting from init * gazelle * reset shard back to 4
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package stateutil_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/go-ssz"
|
|
"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 := ssz.HashTreeRoot(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 = ssz.HashTreeRoot(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)
|
|
}
|
|
}
|