2021-10-06 00:46:07 +00:00
|
|
|
use logging::test_logger;
|
2021-12-21 08:23:17 +00:00
|
|
|
use slasher::{test_utils::indexed_att, Config, Slasher};
|
2021-01-06 06:36:11 +00:00
|
|
|
use tempfile::tempdir;
|
2020-11-23 03:43:22 +00:00
|
|
|
use types::Epoch;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn attestation_pruning_empty_wrap_around() {
|
2021-01-06 06:36:11 +00:00
|
|
|
let tempdir = tempdir().unwrap();
|
2021-12-21 08:23:17 +00:00
|
|
|
let mut config = Config::new(tempdir.path().into());
|
2020-11-23 03:43:22 +00:00
|
|
|
config.validator_chunk_size = 1;
|
|
|
|
config.chunk_size = 16;
|
|
|
|
config.history_length = 16;
|
|
|
|
|
2021-10-06 00:46:07 +00:00
|
|
|
let slasher = Slasher::open(config.clone(), test_logger()).unwrap();
|
2020-11-23 03:43:22 +00:00
|
|
|
|
|
|
|
let v = vec![0];
|
|
|
|
let history_length = config.history_length as u64;
|
|
|
|
|
|
|
|
let mut current_epoch = Epoch::new(history_length - 1);
|
|
|
|
|
|
|
|
slasher.accept_attestation(indexed_att(v.clone(), 0, history_length - 1, 0));
|
|
|
|
slasher.process_queued(current_epoch).unwrap();
|
|
|
|
slasher.prune_database(current_epoch).unwrap();
|
|
|
|
|
|
|
|
// Delete the previous attestation
|
|
|
|
current_epoch = Epoch::new(2 * history_length + 2);
|
|
|
|
slasher.prune_database(current_epoch).unwrap();
|
|
|
|
|
|
|
|
// Add an attestation that would be surrounded with the modulo considered
|
|
|
|
slasher.accept_attestation(indexed_att(
|
2021-01-28 23:31:06 +00:00
|
|
|
v,
|
2020-11-23 03:43:22 +00:00
|
|
|
2 * history_length - 3,
|
|
|
|
2 * history_length - 2,
|
|
|
|
1,
|
|
|
|
));
|
|
|
|
slasher.process_queued(current_epoch).unwrap();
|
|
|
|
}
|