mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
de0143e036
* save origin block root before finalize * add test for SaveOrigin * goimports :( * signature to LoadGenesis changed in a diff PR Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: terence tsao <terence@prysmaticlabs.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state/genesis"
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
"github.com/prysmaticlabs/prysm/testing/util"
|
|
)
|
|
|
|
func TestSaveOrigin(t *testing.T) {
|
|
// Embedded Genesis works with Mainnet config
|
|
params.SetupTestConfigCleanup(t)
|
|
cfg := params.BeaconConfig()
|
|
cfg.ConfigName = params.ConfigNames[params.Mainnet]
|
|
params.OverrideBeaconConfig(cfg)
|
|
|
|
ctx := context.Background()
|
|
db := setupDB(t)
|
|
|
|
st, err := genesis.State(params.Mainnet.String())
|
|
require.NoError(t, err)
|
|
|
|
sb, err := st.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
require.NoError(t, db.LoadGenesis(ctx, sb))
|
|
|
|
// this is necessary for mainnet, because LoadGenesis is short-circuited by the embedded state,
|
|
// so the genesis root key is never written to the db.
|
|
require.NoError(t, db.EnsureEmbeddedGenesis(ctx))
|
|
|
|
cst, err := util.NewBeaconState()
|
|
require.NoError(t, err)
|
|
csb, err := cst.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
cb := util.NewBeaconBlock()
|
|
scb, err := wrapper.WrappedSignedBeaconBlock(cb)
|
|
require.NoError(t, err)
|
|
cbb, err := scb.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
require.NoError(t, db.SaveOrigin(ctx, csb, cbb))
|
|
}
|