File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
stackslib/src/chainstate/stacks/index Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -122,8 +122,31 @@ pub trait MarfConnection<T: MarfTrieId> {
122
122
123
123
fn sqlite_conn ( & self ) -> & Connection ;
124
124
125
+ /// Get and check a value against get_from_hash
126
+ /// (test only)
127
+ #[ cfg( test) ]
128
+ fn get_and_check_with_hash ( & mut self , block_hash : & T , key : & str ) {
129
+ let res = self . with_conn ( |c| MARF :: get_by_key ( c, block_hash, key) ) ;
130
+ let res_with_hash =
131
+ self . with_conn ( |c| MARF :: get_by_hash ( c, block_hash, & TrieHash :: from_key ( key) ) ) ;
132
+ match ( res, res_with_hash) {
133
+ ( Ok ( Some ( x) ) , Ok ( Some ( y) ) ) => {
134
+ assert_eq ! ( x, y) ;
135
+ }
136
+ ( Ok ( None ) , Ok ( None ) ) => { }
137
+ ( Err ( _) , Err ( _) ) => { }
138
+ ( x, y) => {
139
+ panic ! ( "Inconsistency: {x:?} != {y:?}" ) ;
140
+ }
141
+ }
142
+ }
143
+
144
+ #[ cfg( not( test) ) ]
145
+ fn get_and_check_with_hash ( & mut self , _block_hash : & T , _key : & str ) { }
146
+
125
147
/// Resolve a key from the MARF to a MARFValue with respect to the given block height.
126
148
fn get ( & mut self , block_hash : & T , key : & str ) -> Result < Option < MARFValue > , Error > {
149
+ self . get_and_check_with_hash ( block_hash, key) ;
127
150
self . with_conn ( |c| MARF :: get_by_key ( c, block_hash, key) )
128
151
}
129
152
You can’t perform that action at this time.
0 commit comments