mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-24 07:14:46 +00:00
Extend BeaconChain persistence testing
This commit is contained in:
@@ -8,7 +8,9 @@ pub use reduced_tree::ThreadSafeReducedTree;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, String>;
|
||||
|
||||
pub trait LmdGhost<S: Store, E: EthSpec>: Send + Sync + Sized {
|
||||
// Note: the `PartialEq` bound is only required for testing. If it becomes a serious annoyance we
|
||||
// can remove it.
|
||||
pub trait LmdGhost<S: Store, E: EthSpec>: PartialEq + Send + Sync + Sized {
|
||||
/// Create a new instance, with the given `store` and `finalized_root`.
|
||||
fn new(store: Arc<S>, finalized_block: &BeaconBlock<E>, finalized_root: Hash256) -> Self;
|
||||
|
||||
|
||||
@@ -55,6 +55,13 @@ impl<T, E> fmt::Debug for ThreadSafeReducedTree<T, E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> PartialEq for ThreadSafeReducedTree<T, E> {
|
||||
/// This implementation ignores the `store`.
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
*self.core.read() == *other.core.read()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> LmdGhost<T, E> for ThreadSafeReducedTree<T, E>
|
||||
where
|
||||
T: Store,
|
||||
@@ -200,6 +207,15 @@ impl<T, E> fmt::Debug for ReducedTree<T, E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> PartialEq for ReducedTree<T, E> {
|
||||
/// This implementation ignores the `store` field.
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.nodes == other.nodes
|
||||
&& self.latest_votes == other.latest_votes
|
||||
&& self.root == other.root
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> ReducedTree<T, E>
|
||||
where
|
||||
T: Store,
|
||||
@@ -918,7 +934,7 @@ pub struct Vote {
|
||||
///
|
||||
/// E.g., a `get` or `insert` to an out-of-bounds element will cause the Vec to grow (using
|
||||
/// Default) to the smallest size required to fulfill the request.
|
||||
#[derive(Default, Clone, Debug)]
|
||||
#[derive(Default, Clone, Debug, PartialEq)]
|
||||
pub struct ElasticList<T>(Vec<T>);
|
||||
|
||||
impl<T> ElasticList<T>
|
||||
|
||||
Reference in New Issue
Block a user