mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
5a66807989
* First take at updating everything to v5 * Patch gRPC gateway to use prysm v5 Fix patch * Update go ssz --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state/genesis"
|
|
"github.com/prysmaticlabs/prysm/v5/config/params"
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
|
"github.com/prysmaticlabs/prysm/v5/testing/util"
|
|
)
|
|
|
|
func TestSaveOrigin(t *testing.T) {
|
|
params.SetupTestConfigCleanup(t)
|
|
// Embedded Genesis works with Mainnet config
|
|
params.OverrideBeaconConfig(params.MainnetConfig().Copy())
|
|
|
|
ctx := context.Background()
|
|
db := setupDB(t)
|
|
|
|
st, err := genesis.State(params.MainnetName)
|
|
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 := blocks.NewSignedBeaconBlock(cb)
|
|
require.NoError(t, err)
|
|
cbb, err := scb.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
require.NoError(t, db.SaveOrigin(ctx, csb, cbb))
|
|
|
|
broot, err := scb.Block().HashTreeRoot()
|
|
require.NoError(t, err)
|
|
require.Equal(t, true, db.IsFinalizedBlock(ctx, broot))
|
|
}
|