mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
no cache tests (#3284)
This commit is contained in:
parent
ebb0e398d3
commit
7f475bee00
@ -50,6 +50,47 @@ func TestStore_BlocksCRUD(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStore_BlocksCRUD_NoCache(t *testing.T) {
|
||||
db := setupDB(t)
|
||||
defer teardownDB(t, db)
|
||||
ctx := context.Background()
|
||||
block := ðpb.BeaconBlock{
|
||||
Slot: 20,
|
||||
ParentRoot: []byte{1, 2, 3},
|
||||
}
|
||||
blockRoot, err := ssz.SigningRoot(block)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
retrievedBlock, err := db.Block(ctx, blockRoot)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if retrievedBlock != nil {
|
||||
t.Errorf("Expected nil block, received %v", retrievedBlock)
|
||||
}
|
||||
if err := db.SaveBlock(ctx, block); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
db.blockCache.Delete(string(blockRoot[:]))
|
||||
if !db.HasBlock(ctx, blockRoot) {
|
||||
t.Error("Expected block to exist in the db")
|
||||
}
|
||||
retrievedBlock, err = db.Block(ctx, blockRoot)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !proto.Equal(block, retrievedBlock) {
|
||||
t.Errorf("Wanted %v, received %v", block, retrievedBlock)
|
||||
}
|
||||
if err := db.DeleteBlock(ctx, blockRoot); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if db.HasBlock(ctx, blockRoot) {
|
||||
t.Error("Expected block to have been deleted from the db")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStore_Blocks_FiltersCorrectly(t *testing.T) {
|
||||
db := setupDB(t)
|
||||
defer teardownDB(t, db)
|
||||
|
@ -78,3 +78,41 @@ func TestStore_ValidatorLatestVoteCRUD(t *testing.T) {
|
||||
t.Error("Expected validator latest vote to have been deleted from the db")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStore_ValidatorLatestVoteCRUD_NoCache(t *testing.T) {
|
||||
db := setupDB(t)
|
||||
defer teardownDB(t, db)
|
||||
ctx := context.Background()
|
||||
validatorIdx := uint64(100)
|
||||
latestVote := &pb.ValidatorLatestVote{
|
||||
Epoch: 1,
|
||||
Root: []byte("root"),
|
||||
}
|
||||
retrievedVote, err := db.ValidatorLatestVote(ctx, validatorIdx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if retrievedVote != nil {
|
||||
t.Errorf("Expected nil validator latest vote, received %v", retrievedVote)
|
||||
}
|
||||
if err := db.SaveValidatorLatestVote(ctx, validatorIdx, latestVote); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
db.votesCache.Delete(string(validatorIdx))
|
||||
if !db.HasValidatorLatestVote(ctx, validatorIdx) {
|
||||
t.Error("Expected validator latest vote to exist in the db")
|
||||
}
|
||||
retrievedVote, err = db.ValidatorLatestVote(ctx, validatorIdx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !proto.Equal(latestVote, retrievedVote) {
|
||||
t.Errorf("Wanted %d, received %d", latestVote, retrievedVote)
|
||||
}
|
||||
if err := db.DeleteValidatorLatestVote(ctx, validatorIdx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if db.HasValidatorLatestVote(ctx, validatorIdx) {
|
||||
t.Error("Expected validator latest vote to have been deleted from the db")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user