Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix builds with slasher-redb #6077

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ test-network-%:
# Run the tests in the `slasher` crate for all supported database backends.
test-slasher:
cargo nextest run --release -p slasher --features "lmdb,$(TEST_FEATURES)"
cargo nextest run --release -p slasher --no-default-features --features "redb,$(TEST_FEATURES)"
cargo nextest run --release -p slasher --no-default-features --features "mdbx,$(TEST_FEATURES)"
cargo nextest run --release -p slasher --features "lmdb,mdbx,$(TEST_FEATURES)" # both backends enabled
cargo nextest run --release -p slasher --features "lmdb,mdbx,redb,$(TEST_FEATURES)" # all backends enabled

# Runs only the tests/state_transition_vectors tests.
run-state-transition-tests:
Expand Down
2 changes: 1 addition & 1 deletion slasher/src/database/redb_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Environment {
}

pub fn filenames(&self, config: &Config) -> Vec<PathBuf> {
vec![config.database_path.join(BASE_DB)]
vec![config.database_path.join(REDB_DATA_FILENAME)]
}

pub fn begin_rw_txn(&self) -> Result<RwTransaction, Error> {
Expand Down
20 changes: 2 additions & 18 deletions slasher/tests/backend.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(any(feature = "lmdb", feature = "redb"))]
#![cfg(feature = "lmdb")]

use slasher::{config::MDBX_DATA_FILENAME, Config, DatabaseBackend, DatabaseBackendOverride};
use std::fs::File;
Expand Down Expand Up @@ -41,7 +41,7 @@ fn no_override_with_existing_mdbx_db() {
}

#[test]
#[cfg(all(not(feature = "mdbx"), feature = "lmdb", not(feature = "redb")))]
#[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());
Expand All @@ -55,19 +55,3 @@ fn failed_override_with_existing_mdbx_db() {
);
assert_eq!(config.backend, DatabaseBackend::Lmdb);
}

#[test]
#[cfg(feature = "redb")]
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::Redb);
}