mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 05:38:55 +00:00
f385a1dea6
* no more skip slot cache * imports * deprecated * fix flakeyness * disable in e2e * build * fix viz Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
54 lines
998 B
Go
54 lines
998 B
Go
package cache_test
|
|
|
|
import (
|
|
"context"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
|
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
)
|
|
|
|
func TestSkipSlotCache_RoundTrip(t *testing.T) {
|
|
ctx := context.Background()
|
|
c := cache.NewSkipSlotCache()
|
|
|
|
state, err := c.Get(ctx, 5)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if state != nil {
|
|
t.Errorf("Empty cache returned an object: %v", state)
|
|
}
|
|
|
|
if err := c.MarkInProgress(5); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
state, err = stateTrie.InitializeFromProto(&pb.BeaconState{
|
|
Slot: 10,
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err = c.Put(ctx, 5, state); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if err := c.MarkNotInProgress(5); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
res, err := c.Get(ctx, 5)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if !reflect.DeepEqual(state.CloneInnerState(), res.CloneInnerState()) {
|
|
t.Error("Expected equal protos to return from cache")
|
|
}
|
|
}
|