pub struct TrieTestHarness { /* private fields */ }test-utils only.Expand description
General-purpose test harness for storage trie tests.
Manages a base storage dataset, computes expected roots via StorageRoot, and generates
V2 proofs via StorageProofCalculator using mock cursors.
Implementations§
Source§impl TrieTestHarness
impl TrieTestHarness
Sourcepub fn new(storage: BTreeMap<B256, U256>) -> Self
pub fn new(storage: BTreeMap<B256, U256>) -> Self
Creates a new test harness from a map of hashed storage slots to values.
Sourcepub fn get_root_with_updates(
&self,
changeset: &BTreeMap<B256, U256>,
) -> (B256, StorageTrieUpdates)
pub fn get_root_with_updates( &self, changeset: &BTreeMap<B256, U256>, ) -> (B256, StorageTrieUpdates)
Computes the storage root and trie updates after applying the given changeset on top of the current base storage.
Builds a HashedPostStateCursorFactory overlay, derives a prefix set from the
changeset keys, and passes both into StorageRoot::new_hashed.
Sourcepub fn apply_changeset(&mut self, changeset: BTreeMap<B256, U256>)
pub fn apply_changeset(&mut self, changeset: BTreeMap<B256, U256>)
Merges changeset into the base storage (zero values remove entries) and
rebuilds the harness from scratch with the resulting storage.
Sourcepub const fn hashed_address(&self) -> B256
pub const fn hashed_address(&self) -> B256
Returns the hashed address used for all storage trie operations.
Sourcepub const fn storage(&self) -> &BTreeMap<B256, U256>
pub const fn storage(&self) -> &BTreeMap<B256, U256>
Returns a reference to the base storage dataset.
Sourcepub const fn original_root(&self) -> B256
pub const fn original_root(&self) -> B256
Returns the expected storage root.
Sourcepub const fn storage_trie_updates(&self) -> &StorageTrieUpdates
pub const fn storage_trie_updates(&self) -> &StorageTrieUpdates
Returns a reference to the storage trie updates.
Sourcepub fn set_trie_nodes(
&mut self,
trie_nodes: BTreeMap<Nibbles, BranchNodeCompact>,
)
pub fn set_trie_nodes( &mut self, trie_nodes: BTreeMap<Nibbles, BranchNodeCompact>, )
Replaces the trie cursor factory with one backed by the given trie nodes.
Sourcepub fn trie_cursor_factory(&self) -> MockTrieCursorFactory
pub fn trie_cursor_factory(&self) -> MockTrieCursorFactory
Returns a clone of the mock trie cursor factory.
Sourcepub fn hashed_cursor_factory(&self) -> MockHashedCursorFactory
pub fn hashed_cursor_factory(&self) -> MockHashedCursorFactory
Returns a clone of the mock hashed cursor factory.
Sourcepub fn root_node(&self) -> ProofTrieNodeV2
pub fn root_node(&self) -> ProofTrieNodeV2
Obtains the root node of the storage trie via StorageProofCalculator.
Sourcepub fn proof_v2(
&self,
targets: &mut [ProofV2Target],
) -> (Vec<ProofTrieNodeV2>, Option<B256>)
pub fn proof_v2( &self, targets: &mut [ProofV2Target], ) -> (Vec<ProofTrieNodeV2>, Option<B256>)
Generates storage proofs for the given targets using StorageProofCalculator.
Also computes and returns the root hash (if the proof contains a root node) by reusing the calculator after the proof call.
Sourcepub fn minimize_trie_updates(&self, updates: &mut StorageTrieUpdates)
pub fn minimize_trie_updates(&self, updates: &mut StorageTrieUpdates)
Removes all entries from updates that are redundant with the starting storage
trie updates.
A storage node is redundant if it exists in the starting set with the same value. A removed node is redundant if it was already absent from the starting set.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TrieTestHarness
impl !UnwindSafe for TrieTestHarness
impl Freeze for TrieTestHarness
impl Send for TrieTestHarness
impl Sync for TrieTestHarness
impl Unpin for TrieTestHarness
impl UnsafeUnpin for TrieTestHarness
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeDebug for Twhere
T: Debug,
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 200 bytes