File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -186,4 +186,36 @@ mod test {
186
186
187
187
assert_eq ! ( verify, true , "should verify proof successfully" ) ;
188
188
}
189
+
190
+ #[ test]
191
+ fn it_generates_correct_merkle_tree_with_odd_leaves ( ) {
192
+ let h1 = <[ u8 ; 32 ] >:: from_hex (
193
+ "13c21db99584c9bb3e9ad98061f6ca39364049b328b74822be6303a4da18014d" ,
194
+ )
195
+ . unwrap ( ) ;
196
+ let h2 = <[ u8 ; 32 ] >:: from_hex (
197
+ "b1bea7b8b58cd47d475bfe07dbe6df33f50f7a76957c51cebe8254257542fd7d" ,
198
+ )
199
+ . unwrap ( ) ;
200
+
201
+ let h3 = <[ u8 ; 32 ] >:: from_hex (
202
+ "c455ef23d4db0091e1e25ef5d652a2832a1fc4fa82b8e66c290a692836e0cbe6" ,
203
+ )
204
+ . unwrap ( ) ;
205
+
206
+ // odd leaves
207
+ let top = MerkleTree :: new ( & [ h1, h2, h3] ) ;
208
+
209
+ let root = hex:: encode ( & top. root ( ) ) ;
210
+
211
+ assert_eq ! (
212
+ root, "e68ea33571084e5dea276b089a10fa7be9d59accf3d7838c0d9b050bf72634a1" ,
213
+ "should generate the correct root"
214
+ ) ;
215
+
216
+ let proof = top. proof ( 0 ) ;
217
+ let verify = top. verify ( proof) ;
218
+
219
+ assert_eq ! ( verify, true , "should verify proof successfully" ) ;
220
+ }
189
221
}
You can’t perform that action at this time.
0 commit comments