mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-07 10:12:19 +00:00
b954db9704
* Revert "Update fastssz (#6760)"
This reverts commit 78a25f99c3
.
* Merge refs/heads/master into revert-6760-update-fssz
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package blockchain
|
|
|
|
import (
|
|
"testing"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestHotStateCache_RoundTrip(t *testing.T) {
|
|
c := newCheckPointInfoCache()
|
|
cp := ðpb.Checkpoint{
|
|
Epoch: 1,
|
|
Root: bytesutil.PadTo([]byte{'a'}, 32),
|
|
}
|
|
info, err := c.get(cp)
|
|
require.NoError(t, err)
|
|
require.Equal(t, (*pb.CheckPtInfo)(nil), info)
|
|
|
|
i := &pb.CheckPtInfo{
|
|
Seed: bytesutil.PadTo([]byte{'c'}, 32),
|
|
GenesisRoot: bytesutil.PadTo([]byte{'d'}, 32),
|
|
ActiveIndices: []uint64{0, 1, 2, 3},
|
|
}
|
|
|
|
require.NoError(t, c.put(cp, i))
|
|
info, err = c.get(cp)
|
|
require.NoError(t, err)
|
|
require.DeepEqual(t, info, i)
|
|
}
|
|
|
|
func TestHotStateCache_CanPrune(t *testing.T) {
|
|
c := newCheckPointInfoCache()
|
|
for i := 0; i < maxInfoSize+1; i++ {
|
|
cp := ðpb.Checkpoint{Epoch: uint64(i)}
|
|
require.NoError(t, c.put(cp, &pb.CheckPtInfo{}))
|
|
}
|
|
require.Equal(t, len(c.cache.Keys()), maxInfoSize)
|
|
}
|