mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-22 03:30:38 +00:00
f2223feb21
## Issue Addressed
N/A
## Proposed Changes
Add lints for rust 1.71
[3789134](3789134ae2
) is probably the one that needs most attention as it changes beacon state code. I changed the `is_in_inactivity_leak ` function to return a `ArithError` as not all consumers of that function work well with a `BeaconState::Error`.
58 lines
1.7 KiB
Rust
58 lines
1.7 KiB
Rust
#![cfg(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);
|
|
}
|