@@ -445,17 +445,17 @@ pub(crate) fn test_node_db_key() -> String {
445445 data : NodeData :: Binary ( BinaryData { left_data : hash, right_data : hash } ) ,
446446 hash,
447447 } ;
448- let binary_node_key = binary_node . db_key ( & dummy_contract_address) . 0 ;
448+ let binary_node_key = db_key ( & binary_node , & dummy_contract_address) . 0 ;
449449
450450 let edge_node: FactDbFilledNode < StarknetStorageValue > = FactDbFilledNode {
451451 data : NodeData :: Edge ( EdgeData { bottom_data : hash, path_to_bottom : Default :: default ( ) } ) ,
452452 hash,
453453 } ;
454454
455- let edge_node_key = edge_node . db_key ( & dummy_contract_address) . 0 ;
455+ let edge_node_key = db_key ( & edge_node , & dummy_contract_address) . 0 ;
456456
457457 let storage_leaf = FactDbFilledNode { data : NodeData :: Leaf ( StarknetStorageValue ( zero) ) , hash } ;
458- let storage_leaf_key = storage_leaf . db_key ( & dummy_contract_address) . 0 ;
458+ let storage_leaf_key = db_key ( & storage_leaf , & dummy_contract_address) . 0 ;
459459
460460 let state_tree_leaf = FactDbFilledNode {
461461 data : NodeData :: Leaf ( ContractState {
@@ -465,11 +465,11 @@ pub(crate) fn test_node_db_key() -> String {
465465 } ) ,
466466 hash,
467467 } ;
468- let state_tree_leaf_key = state_tree_leaf . db_key ( & EmptyKeyContext ) . 0 ;
468+ let state_tree_leaf_key = db_key ( & state_tree_leaf , & EmptyKeyContext ) . 0 ;
469469
470470 let compiled_class_leaf =
471471 FactDbFilledNode { data : NodeData :: Leaf ( CompiledClassHash ( zero) ) , hash } ;
472- let compiled_class_leaf_key = compiled_class_leaf . db_key ( & EmptyKeyContext ) . 0 ;
472+ let compiled_class_leaf_key = db_key ( & compiled_class_leaf , & EmptyKeyContext ) . 0 ;
473473
474474 // Store keys in a HashMap.
475475 let mut map: HashMap < String , Vec < u8 > > = HashMap :: new ( ) ;
@@ -544,7 +544,7 @@ async fn test_storage_node(data: HashMap<String, String>) -> CommitterPythonTest
544544 // Store the binary node in the storage.
545545 rust_fact_storage
546546 . set (
547- binary_rust . db_key ( & dummy_contract_address) ,
547+ db_key ( & binary_rust , & dummy_contract_address) ,
548548 binary_rust. serialize ( ) . map_err ( |error| {
549549 PythonTestError :: SpecificError ( CommitterSpecificTestError :: Serialization ( error) )
550550 } ) ?,
@@ -578,7 +578,7 @@ async fn test_storage_node(data: HashMap<String, String>) -> CommitterPythonTest
578578 // Store the edge node in the storage.
579579 rust_fact_storage
580580 . set (
581- edge_rust . db_key ( & dummy_contract_address) ,
581+ db_key ( & edge_rust , & dummy_contract_address) ,
582582 edge_rust. serialize ( ) . map_err ( |error| {
583583 PythonTestError :: SpecificError ( CommitterSpecificTestError :: Serialization ( error) )
584584 } ) ?,
@@ -601,7 +601,7 @@ async fn test_storage_node(data: HashMap<String, String>) -> CommitterPythonTest
601601 // Store the storage leaf node in the storage.
602602 rust_fact_storage
603603 . set (
604- storage_leaf_rust . db_key ( & dummy_contract_address) ,
604+ db_key ( & storage_leaf_rust , & dummy_contract_address) ,
605605 storage_leaf_rust. serialize ( ) . map_err ( |error| {
606606 PythonTestError :: SpecificError ( CommitterSpecificTestError :: Serialization ( error) )
607607 } ) ?,
@@ -633,7 +633,7 @@ async fn test_storage_node(data: HashMap<String, String>) -> CommitterPythonTest
633633 // Store the contract state leaf node in the storage.
634634 rust_fact_storage
635635 . set (
636- contract_state_leaf_rust . db_key ( & EmptyKeyContext ) ,
636+ db_key ( & contract_state_leaf_rust , & EmptyKeyContext ) ,
637637 contract_state_leaf_rust. serialize ( ) . map_err ( |error| {
638638 PythonTestError :: SpecificError ( CommitterSpecificTestError :: Serialization ( error) )
639639 } ) ?,
@@ -657,7 +657,7 @@ async fn test_storage_node(data: HashMap<String, String>) -> CommitterPythonTest
657657 // Store the compiled class leaf node in the storage.
658658 rust_fact_storage
659659 . set (
660- compiled_class_leaf_rust . db_key ( & EmptyKeyContext ) ,
660+ db_key ( & compiled_class_leaf_rust , & EmptyKeyContext ) ,
661661 compiled_class_leaf_rust. serialize ( ) . map_err ( |error| {
662662 PythonTestError :: SpecificError ( CommitterSpecificTestError :: Serialization ( error) )
663663 } ) ?,
@@ -677,3 +677,11 @@ pub(crate) async fn filled_forest_output_test() -> CommitterPythonTestResult {
677677 let output_string = serde_json:: to_string ( & output) . expect ( "Failed to serialize" ) ;
678678 Ok ( output_string)
679679}
680+
681+ pub fn db_key (
682+ node : & FactDbFilledNode < L > ,
683+ key_context : & <L as HasStaticPrefix >:: KeyContext ,
684+ ) -> DbKey {
685+ let suffix = node. hash . 0 . to_bytes_be ( ) ;
686+ node. get_db_key ( key_context, & self . suffix ( ) )
687+ }
0 commit comments