prysm-pulse/beacon-chain/db/kv/migrate_snappy_test.go
Preston Van Loon e203f66fe0 DB Improvements: Snappy compression, remove some unnecessary batch / goroutines (#4125)
* do not use batch for SaveAttestations
* use snappy compression
* Encode / decode everything with snappy
* Add snappy migration path
* batch is probably fine...
* fix test
* gofmt
* Merge branch 'master' of github.com:prysmaticlabs/prysm into remove-batch-attestations
* add sanity check
* remove that thing
* gaz
* Merge branch 'master' of github.com:prysmaticlabs/prysm into remove-batch-attestations
2019-11-27 06:32:56 +00:00

49 lines
925 B
Go

package kv
import (
"context"
"testing"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
)
// Sanity check that an object can be accessed after migration.
func TestStore_MigrateSnappy(t *testing.T) {
db := setupDB(t)
ctx := context.Background()
block := &ethpb.BeaconBlock{
Slot: 200,
}
root, err := ssz.SigningRoot(block)
if err != nil {
t.Fatal(err)
}
if err := db.SaveBlock(ctx, block); err != nil {
t.Fatal(err)
}
path := db.databasePath
db.Close()
c := featureconfig.Get()
c.EnableSnappyDBCompression = true
featureconfig.Init(c)
db2, err := NewKVStore(path)
if err != nil {
t.Fatalf("Failed to instantiate DB: %v", err)
}
defer teardownDB(t, db2)
blk, err := db.Block(ctx, root)
if err != nil {
t.Fatal(err)
}
if !ssz.DeepEqual(blk, block) {
t.Fatal("Blocks not same")
}
}