mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 03:51:29 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
38 lines
1022 B
Go
38 lines
1022 B
Go
package cache_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/cache"
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/state"
|
|
state_native "github.com/prysmaticlabs/prysm/v4/beacon-chain/state/state-native"
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
|
)
|
|
|
|
func TestSkipSlotCache_RoundTrip(t *testing.T) {
|
|
ctx := context.Background()
|
|
c := cache.NewSkipSlotCache()
|
|
|
|
r := [32]byte{'a'}
|
|
s, err := c.Get(ctx, r)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, state.BeaconState(nil), s, "Empty cache returned an object")
|
|
|
|
require.NoError(t, c.MarkInProgress(r))
|
|
|
|
s, err = state_native.InitializeFromProtoPhase0(ðpb.BeaconState{
|
|
Slot: 10,
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
c.Put(ctx, r, s)
|
|
c.MarkNotInProgress(r)
|
|
|
|
res, err := c.Get(ctx, r)
|
|
require.NoError(t, err)
|
|
assert.DeepEqual(t, res.ToProto(), s.ToProto(), "Expected equal protos to return from cache")
|
|
}
|