mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
ce725ceec3
* Move state pkg to stateV0 pkg * Build.bazel * Remove unused RootsArrayHashTreeRoot * Revert "Remove unused RootsArrayHashTreeRoot" This reverts commit bf0bda30d1a8eb7a071f6e3ce9ee85041b45aca6. Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
package stategen
|
|
|
|
import (
|
|
"testing"
|
|
|
|
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateV0"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestHotStateCache_RoundTrip(t *testing.T) {
|
|
c := newHotStateCache()
|
|
root := [32]byte{'A'}
|
|
state := c.get(root)
|
|
assert.Equal(t, iface.BeaconState(nil), state)
|
|
assert.Equal(t, false, c.has(root), "Empty cache has an object")
|
|
|
|
state, err := stateV0.InitializeFromProto(&pb.BeaconState{
|
|
Slot: 10,
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
c.put(root, state)
|
|
assert.Equal(t, true, c.has(root), "Empty cache does not have an object")
|
|
|
|
res := c.get(root)
|
|
assert.NotNil(t, state)
|
|
assert.DeepEqual(t, res.CloneInnerState(), state.CloneInnerState(), "Expected equal protos to return from cache")
|
|
|
|
c.delete(root)
|
|
assert.Equal(t, false, c.has(root), "Cache not supposed to have the object")
|
|
}
|