feat: add reth test-vectors compact --write|--read (#11954)

This commit is contained in:
joshieDo
2024-10-25 03:34:12 +09:00
committed by GitHub
parent ba78e43938
commit 777417ad8a
51 changed files with 857 additions and 101 deletions

View File

@ -20,6 +20,7 @@ derive_more.workspace = true
modular-bitfield.workspace = true
serde.workspace = true
thiserror.workspace = true
arbitrary = { workspace = true, features = ["derive"], optional = true }
[dev-dependencies]
arbitrary = { workspace = true, features = ["derive"] }
@ -29,3 +30,13 @@ proptest-arbitrary-interop.workspace = true
serde_json.workspace = true
test-fuzz.workspace = true
toml.workspace = true
[features]
test-utils = [
"dep:arbitrary",
"reth-codecs/test-utils"
]
arbitrary = [
"alloy-primitives/arbitrary",
"reth-codecs/arbitrary"
]

View File

@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
/// Saves the pruning progress of a stage.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, Compact)]
#[cfg_attr(test, derive(Default, arbitrary::Arbitrary))]
#[cfg_attr(any(test, feature = "test-utils"), derive(Default, arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub struct PruneCheckpoint {
/// Highest pruned block number. If it's [None], the pruning for block `0` is not finished yet.

View File

@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
/// Prune mode.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, Compact)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(test, derive(arbitrary::Arbitrary))]
#[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub enum PruneMode {
/// Prune all blocks.
@ -17,6 +17,13 @@ pub enum PruneMode {
Before(BlockNumber),
}
#[cfg(any(test, feature = "test-utils"))]
impl Default for PruneMode {
fn default() -> Self {
Self::Full
}
}
impl PruneMode {
/// Prune blocks up to the specified block number. The specified block number is also pruned.
///
@ -69,13 +76,6 @@ impl PruneMode {
}
}
#[cfg(test)]
impl Default for PruneMode {
fn default() -> Self {
Self::Full
}
}
#[cfg(test)]
mod tests {
use crate::{