mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
7f7866ff2a
* Starting a quick PoC * Rate limit to one epoch worth of blocks in memory * Proof of concept working * Quick comment out * Save previous finalized checkpoint * Test * Minor fixes * More run time fixes * Remove panic * Feature flag * Removed unused methods * Fixed tests * E2e test * comment * Compatible with current initial sync * Starting * New cache * Cache getters and setters * It should be part of state gen * Need to use cache for DB * Don't have to use finalized state * Rm unused file * some changes to memory mgmt when using mempool * More run time fixes * Can sync to head * Feedback * Revert "some changes to memory mgmt when using mempool" This reverts commit f5b3e7ff4714fef9f0397007f519a45fa259ad24. * Fixed sync tests * Fixed existing tests * Test for state summary getter * Gaz * Fix kafka passthrough * Fixed inputs * Gaz * Fixed build * Fixed visibility * Trying without the ignore * Didn't work.. * Fix kafka Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
package stategen
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
|
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
)
|
|
|
|
func TestResume(t *testing.T) {
|
|
ctx := context.Background()
|
|
db := testDB.SetupDB(t)
|
|
defer testDB.TeardownDB(t, db)
|
|
|
|
service := New(db, cache.NewStateSummaryCache())
|
|
root := [32]byte{'A'}
|
|
beaconState, _ := testutil.DeterministicGenesisState(t, 32)
|
|
beaconState.SetSlot(params.BeaconConfig().SlotsPerEpoch)
|
|
service.beaconDB.SaveState(ctx, beaconState, root)
|
|
service.beaconDB.SaveArchivedPointRoot(ctx, root, 1)
|
|
service.beaconDB.SaveLastArchivedIndex(ctx, 1)
|
|
|
|
resumeState, err := service.Resume(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if !proto.Equal(beaconState.InnerStateUnsafe(), resumeState.InnerStateUnsafe()) {
|
|
t.Error("Diff saved state")
|
|
}
|
|
if service.splitInfo.slot != params.BeaconConfig().SlotsPerEpoch {
|
|
t.Errorf("Did not get watned slot")
|
|
}
|
|
if root != service.splitInfo.root {
|
|
t.Errorf("Did not get wanted root")
|
|
}
|
|
}
|
|
|
|
func TestVerifySlotsPerArchivePoint(t *testing.T) {
|
|
type tc struct {
|
|
input uint64
|
|
result bool
|
|
}
|
|
tests := []tc{
|
|
{0, false},
|
|
{1, false},
|
|
{params.BeaconConfig().SlotsPerEpoch, true},
|
|
{params.BeaconConfig().SlotsPerEpoch + 1, false},
|
|
{params.BeaconConfig().SlotsPerHistoricalRoot, true},
|
|
{params.BeaconConfig().SlotsPerHistoricalRoot + 1, false},
|
|
}
|
|
for _, tt := range tests {
|
|
if got := verifySlotsPerArchivePoint(tt.input); got != tt.result {
|
|
t.Errorf("verifySlotsPerArchivePoint(%d) = %v, want %v", tt.input, got, tt.result)
|
|
}
|
|
}
|
|
}
|