-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch default slasher backend to LMDB
- Loading branch information
1 parent
7b1a0d4
commit ca3c950
Showing
15 changed files
with
169 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ authors = ["Michael Sproul <[email protected]>"] | |
edition = "2021" | ||
|
||
[features] | ||
default = ["mdbx"] | ||
default = ["lmdb"] | ||
mdbx = ["dep:mdbx"] | ||
lmdb = ["lmdb-rkv", "lmdb-rkv-sys"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#![cfg(any(feature = "mdbx", feature = "lmdb"))] | ||
|
||
use slasher::{config::MDBX_DATA_FILENAME, Config, DatabaseBackend, DatabaseBackendOverride}; | ||
use std::fs::File; | ||
use tempfile::tempdir; | ||
|
||
#[test] | ||
#[cfg(all(feature = "mdbx", feature = "lmdb"))] | ||
fn override_no_existing_db() { | ||
let tempdir = tempdir().unwrap(); | ||
let mut config = Config::new(tempdir.path().into()); | ||
assert_eq!(config.override_backend(), DatabaseBackendOverride::Noop); | ||
} | ||
|
||
#[test] | ||
#[cfg(all(feature = "mdbx", feature = "lmdb"))] | ||
fn override_with_existing_mdbx_db() { | ||
let tempdir = tempdir().unwrap(); | ||
let mut config = Config::new(tempdir.path().into()); | ||
|
||
File::create(config.database_path.join(MDBX_DATA_FILENAME)).unwrap(); | ||
|
||
assert_eq!( | ||
config.override_backend(), | ||
DatabaseBackendOverride::Success(DatabaseBackend::Lmdb) | ||
); | ||
assert_eq!(config.backend, DatabaseBackend::Mdbx); | ||
} | ||
|
||
#[test] | ||
#[cfg(all(feature = "mdbx", feature = "lmdb"))] | ||
fn no_override_with_existing_mdbx_db() { | ||
let tempdir = tempdir().unwrap(); | ||
let mut config = Config::new(tempdir.path().into()); | ||
config.backend = DatabaseBackend::Mdbx; | ||
|
||
File::create(config.database_path.join(MDBX_DATA_FILENAME)).unwrap(); | ||
|
||
assert_eq!(config.override_backend(), DatabaseBackendOverride::Noop); | ||
assert_eq!(config.backend, DatabaseBackend::Mdbx); | ||
} | ||
|
||
#[test] | ||
#[cfg(all(not(feature = "mdbx"), feature = "lmdb"))] | ||
fn failed_override_with_existing_mdbx_db() { | ||
let tempdir = tempdir().unwrap(); | ||
let mut config = Config::new(tempdir.path().into()); | ||
|
||
let filename = config.database_path.join(MDBX_DATA_FILENAME); | ||
File::create(&filename).unwrap(); | ||
|
||
assert_eq!( | ||
config.override_backend(), | ||
DatabaseBackendOverride::Failure(filename) | ||
); | ||
assert_eq!(config.backend, DatabaseBackend::Lmdb); | ||
} |