This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Storage mock and test for get_block_id
Specifically, when retrieving block_id from a Papyrus snapshot it can be a large hash, which we had a bug on back when we assumed it was a u64. commit-id:979a9b19
- Loading branch information
Gilad Chase
committed
Nov 20, 2023
1 parent
e0e8af6
commit dda3a61
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use std::collections::HashMap; | ||
|
||
use crate::errors::NativeBlockifierResult; | ||
use crate::storage::Storage; | ||
|
||
pub struct MockStorage { | ||
pub block_number_to_class_hash: HashMap<u64, Vec<u8>>, | ||
// .. Add more as needed. | ||
} | ||
impl Storage for MockStorage { | ||
fn get_block_id(&self, block_number: u64) -> NativeBlockifierResult<Option<Vec<u8>>> { | ||
Ok(self.block_number_to_class_hash.get(&block_number).cloned()) | ||
} | ||
|
||
fn get_state_marker(&self) -> NativeBlockifierResult<u64> { | ||
todo!() | ||
} | ||
|
||
fn get_header_marker(&self) -> NativeBlockifierResult<u64> { | ||
todo!() | ||
} | ||
|
||
fn revert_block(&mut self, _block_number: u64) -> NativeBlockifierResult<()> { | ||
todo!() | ||
} | ||
|
||
fn append_block( | ||
&mut self, | ||
_block_id: u64, | ||
_previous_block_id: Option<crate::py_utils::PyFelt>, | ||
_py_block_info: crate::py_state_diff::PyBlockInfo, | ||
_py_state_diff: crate::py_state_diff::PyStateDiff, | ||
_declared_class_hash_to_class: HashMap< | ||
crate::py_utils::PyFelt, | ||
(crate::py_utils::PyFelt, String), | ||
>, | ||
_deprecated_declared_class_hash_to_class: HashMap<crate::py_utils::PyFelt, String>, | ||
) -> NativeBlockifierResult<()> { | ||
todo!() | ||
} | ||
|
||
fn validate_aligned(&self, _source_block_number: u64) { | ||
todo!() | ||
} | ||
|
||
fn reader(&self) -> &papyrus_storage::StorageReader { | ||
todo!() | ||
} | ||
|
||
fn writer(&mut self) -> &mut papyrus_storage::StorageWriter { | ||
todo!() | ||
} | ||
|
||
fn close(&mut self) { | ||
todo!() | ||
} | ||
} |