Add block ban flag --invalid-block-roots (#7042)

This commit is contained in:
Eitan Seri-Levi
2025-03-17 07:18:22 -06:00
committed by GitHub
parent 9db29b023b
commit 8ce9edc584
8 changed files with 140 additions and 4 deletions

View File

@@ -2773,3 +2773,43 @@ fn beacon_node_backend_override() {
assert_eq!(config.store.backend, BeaconNodeBackend::LevelDb);
});
}
#[test]
fn invalid_block_roots_flag() {
let dir = TempDir::new().expect("Unable to create temporary directory");
let mut file =
File::create(dir.path().join("invalid-block-roots")).expect("Unable to create file");
file.write_all(b"2db899881ed8546476d0b92c6aa9110bea9a4cd0dbeb5519eb0ea69575f1f359, 2db899881ed8546476d0b92c6aa9110bea9a4cd0dbeb5519eb0ea69575f1f358, 0x3db899881ed8546476d0b92c6aa9110bea9a4cd0dbeb5519eb0ea69575f1f358")
.expect("Unable to write to file");
CommandLineTest::new()
.flag(
"invalid-block-roots",
dir.path().join("invalid-block-roots").as_os_str().to_str(),
)
.run_with_zero_port()
.with_config(|config| assert_eq!(config.chain.invalid_block_roots.len(), 3))
}
#[test]
fn invalid_block_roots_default_holesky() {
use beacon_node::beacon_chain::chain_config::INVALID_HOLESKY_BLOCK_ROOT;
CommandLineTest::new()
.flag("network", Some("holesky"))
.run_with_zero_port()
.with_config(|config| {
assert_eq!(config.chain.invalid_block_roots.len(), 1);
assert!(config
.chain
.invalid_block_roots
.contains(&*INVALID_HOLESKY_BLOCK_ROOT));
})
}
#[test]
fn invalid_block_roots_default_mainnet() {
CommandLineTest::new()
.run_with_zero_port()
.with_config(|config| {
assert!(config.chain.invalid_block_roots.is_empty());
})
}