fix: ensures that pruning data from static files only happens on calling commit() (#8101)

This commit is contained in:
joshieDo
2024-05-07 16:46:11 +01:00
committed by GitHub
parent 05e434eae3
commit a2623e8364
6 changed files with 114 additions and 25 deletions

View File

@ -272,12 +272,13 @@ mod tests {
db.insert_blocks(blocks.iter(), StorageKind::Database(None)).expect("insert blocks");
// Unwind headers from static_files and manually insert them into the database, so we're
// able to check that static_file_producer works
db.factory
.static_file_provider()
let static_file_provider = db.factory.static_file_provider();
let mut static_file_writer = static_file_provider
.latest_writer(StaticFileSegment::Headers)
.expect("get static file writer for headers")
.prune_headers(blocks.len() as u64)
.expect("prune headers");
.expect("get static file writer for headers");
static_file_writer.prune_headers(blocks.len() as u64).unwrap();
static_file_writer.commit().expect("prune headers");
let tx = db.factory.db_ref().tx_mut().expect("init tx");
blocks.iter().for_each(|block| {
TestStageDB::insert_header(None, &tx, &block.header, U256::ZERO)