use of tech.pegasys.teku.storage.server.kvstore.TestKvStoreDatabase in project teku by ConsenSys.
the class DatabaseMigraterTest method shouldCopyVariablesFromHotDb.
@Test
void shouldCopyVariablesFromHotDb(@TempDir Path tmpDir) throws Exception {
final DataDirLayout dataDirLayout = prepareTempDir(tmpDir, "5");
DatabaseMigrater migrater = getDatabaseMigrater(dataDirLayout);
final UInt64 genesis = dataStructureUtil.randomUInt64();
final Checkpoint finalizedCheckpoint = dataStructureUtil.randomCheckpoint();
migrater.openDatabases(DatabaseVersion.V5, DatabaseVersion.LEVELDB2);
TestKvStoreDatabase originalDb = new TestKvStoreDatabase(migrater.getOriginalDatabase());
try (KvStoreHotDao.HotUpdater updater = originalDb.getHotDao().hotUpdater()) {
updater.setGenesisTime(genesis);
updater.setFinalizedCheckpoint(finalizedCheckpoint);
updater.commit();
}
migrater.migrateData();
TestKvStoreDatabase newDb = new TestKvStoreDatabase(migrater.getNewDatabase());
assertThat(newDb.getHotDao().getGenesisTime()).isEqualTo(originalDb.getHotDao().getGenesisTime());
assertThat(newDb.getHotDao().getGenesisTime()).contains(genesis);
assertThat(newDb.getHotDao().getFinalizedCheckpoint()).isEqualTo(originalDb.getHotDao().getFinalizedCheckpoint());
assertThat(newDb.getHotDao().getFinalizedCheckpoint()).contains(finalizedCheckpoint);
migrater.closeDatabases();
}
use of tech.pegasys.teku.storage.server.kvstore.TestKvStoreDatabase in project teku by ConsenSys.
the class DatabaseMigraterTest method shouldCopyColumnData.
@Test
void shouldCopyColumnData(@TempDir Path tmpDir) throws IOException, DatabaseMigraterError {
final DataDirLayout dataDirLayout = prepareTempDir(tmpDir, "5");
DatabaseMigrater migrater = getDatabaseMigrater(dataDirLayout);
final BeaconBlockAndState blockAndState = dataStructureUtil.randomBlockAndState(1_000_000);
migrater.openDatabases(DatabaseVersion.V5, DatabaseVersion.LEVELDB2);
TestKvStoreDatabase originalDb = new TestKvStoreDatabase(migrater.getOriginalDatabase());
try (KvStoreHotDao.HotUpdater updater = originalDb.getHotDao().hotUpdater()) {
updater.addHotState(blockAndState.getBlock().getRoot(), blockAndState.getState());
updater.commit();
}
migrater.migrateData();
TestKvStoreDatabase newDb = new TestKvStoreDatabase(migrater.getNewDatabase());
assertThat(newDb.getHotDao().getHotState(blockAndState.getRoot())).contains(blockAndState.getState());
migrater.closeDatabases();
}
Aggregations