mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
c0076cc7a2
* Move interfaces from github.com/prysmaticlabs/prysm/beacon-chain/state/interface to github.com/prysmaticlabs/prysm/beacon-chain/state * remove/rename state2
35 lines
997 B
Go
35 lines
997 B
Go
package stategen
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
|
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
|
statepb "github.com/prysmaticlabs/prysm/proto/prysm/v2/state"
|
|
"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'}
|
|
s := c.get(root)
|
|
assert.Equal(t, state.BeaconState(nil), s)
|
|
assert.Equal(t, false, c.has(root), "Empty cache has an object")
|
|
|
|
s, err := v1.InitializeFromProto(&statepb.BeaconState{
|
|
Slot: 10,
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
c.put(root, s)
|
|
assert.Equal(t, true, c.has(root), "Empty cache does not have an object")
|
|
|
|
res := c.get(root)
|
|
assert.NotNil(t, s)
|
|
assert.DeepEqual(t, res.CloneInnerState(), s.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")
|
|
}
|