Skip to content

Commit c2c492d

Browse files
committed
Handle missing slasher backend in tests
1 parent 33bae81 commit c2c492d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

beacon_node/beacon_chain/tests/block_verification.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,9 +987,23 @@ async fn block_gossip_verification() {
987987
#[tokio::test]
988988
async fn verify_block_for_gossip_slashing_detection() {
989989
let slasher_dir = tempdir().unwrap();
990-
let slasher = Arc::new(
991-
Slasher::open(SlasherConfig::new(slasher_dir.path().into()), test_logger()).unwrap(),
992-
);
990+
991+
let slasher_result =
992+
Slasher::open(SlasherConfig::new(slasher_dir.path().into()), test_logger());
993+
994+
// The slasher should only instantiate if a backend feature-flag has been
995+
// provided.
996+
//
997+
// For example: `--features slasher/lmdb`
998+
let slasher = if cfg!(any(feature = "mdbx", feature = "lmdb")) {
999+
Arc::new(slasher_result.unwrap())
1000+
} else {
1001+
assert!(matches!(
1002+
slasher_result,
1003+
Err(slasher::Error::SlasherDatabaseBackendDisabled)
1004+
));
1005+
return;
1006+
};
9931007

9941008
let inner_slasher = slasher.clone();
9951009
let harness = BeaconChainHarness::builder(MainnetEthSpec)

0 commit comments

Comments
 (0)