mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Store the database in a role specific subdirectory (#9645)
* Store the database in a role specific subdirectory This is a cleaned up version of #8658 fixing #6880 polkadot companion: paritytech/polkadot#2923 * Disable prometheus in tests * Also change p2p port * Fix migration logic * Use different identification file for rocks and parity db Add tests for paritydb migration
This commit is contained in:
committed by
GitHub
parent
4849e34270
commit
16144e7404
@@ -186,7 +186,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn open_database(db_path: &Path) -> sp_blockchain::Result<()> {
|
||||
fn open_database(db_path: &Path, db_type: DatabaseType) -> sp_blockchain::Result<()> {
|
||||
crate::utils::open_database::<Block>(
|
||||
&DatabaseSettings {
|
||||
state_cache_size: 0,
|
||||
@@ -196,7 +196,7 @@ mod tests {
|
||||
keep_blocks: KeepBlocks::All,
|
||||
transaction_storage: TransactionStorageMode::BlockBody,
|
||||
},
|
||||
DatabaseType::Full,
|
||||
db_type,
|
||||
)
|
||||
.map(|_| ())
|
||||
}
|
||||
@@ -205,25 +205,28 @@ mod tests {
|
||||
fn downgrade_never_happens() {
|
||||
let db_dir = tempfile::TempDir::new().unwrap();
|
||||
create_db(db_dir.path(), Some(CURRENT_VERSION + 1));
|
||||
assert!(open_database(db_dir.path()).is_err());
|
||||
assert!(open_database(db_dir.path(), DatabaseType::Full).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn open_empty_database_works() {
|
||||
let db_type = DatabaseType::Full;
|
||||
let db_dir = tempfile::TempDir::new().unwrap();
|
||||
open_database(db_dir.path()).unwrap();
|
||||
open_database(db_dir.path()).unwrap();
|
||||
assert_eq!(current_version(db_dir.path()).unwrap(), CURRENT_VERSION);
|
||||
let db_dir = db_dir.path().join(db_type.as_str());
|
||||
open_database(&db_dir, db_type).unwrap();
|
||||
open_database(&db_dir, db_type).unwrap();
|
||||
assert_eq!(current_version(&db_dir).unwrap(), CURRENT_VERSION);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upgrade_to_3_works() {
|
||||
let db_type = DatabaseType::Full;
|
||||
for version_from_file in &[None, Some(1), Some(2)] {
|
||||
let db_dir = tempfile::TempDir::new().unwrap();
|
||||
let db_path = db_dir.path();
|
||||
create_db(db_path, *version_from_file);
|
||||
open_database(db_path).unwrap();
|
||||
assert_eq!(current_version(db_path).unwrap(), CURRENT_VERSION);
|
||||
let db_path = db_dir.path().join(db_type.as_str());
|
||||
create_db(&db_path, *version_from_file);
|
||||
open_database(&db_path, db_type).unwrap();
|
||||
assert_eq!(current_version(&db_path).unwrap(), CURRENT_VERSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user