mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
2b6e86ec1b
* extract DeterministicGenesisStateWithGenesisBlock (cherry picked from commit a5e3a9c9bbbacb23a644f5c68c92839a315f66a1) # Conflicts: # testing/util/state.go * part 1 * part 2 * part 3 * fix errors * db interface public visibility Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package stategen
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
"github.com/prysmaticlabs/prysm/testing/util"
|
|
)
|
|
|
|
func TestResume(t *testing.T) {
|
|
ctx := context.Background()
|
|
beaconDB := testDB.SetupDB(t)
|
|
|
|
service := New(beaconDB)
|
|
b := util.NewBeaconBlock()
|
|
util.SaveBlock(t, ctx, service.beaconDB, b)
|
|
root, err := b.Block.HashTreeRoot()
|
|
require.NoError(t, err)
|
|
beaconState, _ := util.DeterministicGenesisState(t, 32)
|
|
require.NoError(t, beaconState.SetSlot(params.BeaconConfig().SlotsPerEpoch))
|
|
require.NoError(t, service.beaconDB.SaveState(ctx, beaconState, root))
|
|
require.NoError(t, service.beaconDB.SaveGenesisBlockRoot(ctx, root))
|
|
require.NoError(t, service.beaconDB.SaveFinalizedCheckpoint(ctx, ðpb.Checkpoint{Root: root[:]}))
|
|
|
|
resumeState, err := service.Resume(ctx, beaconState)
|
|
require.NoError(t, err)
|
|
require.DeepSSZEqual(t, beaconState.InnerStateUnsafe(), resumeState.InnerStateUnsafe())
|
|
assert.Equal(t, params.BeaconConfig().SlotsPerEpoch, service.finalizedInfo.slot, "Did not get watned slot")
|
|
assert.Equal(t, service.finalizedInfo.root, root, "Did not get wanted root")
|
|
assert.NotNil(t, service.finalizedState(), "Wanted a non nil finalized state")
|
|
}
|