@@ -250,171 +250,6 @@ func TestStatelessToDot(t *testing.T) {
250250 }
251251}
252252
253- // TODO move this to proof_test
254- func TestStatelessDeserialize (t * testing.T ) {
255- root := New ()
256- for _ , k := range [][]byte {zeroKeyTest , oneKeyTest , fourtyKeyTest , ffx32KeyTest } {
257- root .Insert (k , fourtyKeyTest , nil )
258- }
259-
260- proof , _ , _ , _ , _ := MakeVerkleMultiProof (root , keylist {zeroKeyTest , fourtyKeyTest }, map [string ][]byte {string (zeroKeyTest ): fourtyKeyTest , string (fourtyKeyTest ): fourtyKeyTest })
261-
262- serialized , statediff , err := SerializeProof (proof )
263- if err != nil {
264- t .Fatalf ("could not serialize proof: %v" , err )
265- }
266-
267- dproof , err := DeserializeProof (serialized , statediff )
268- if err != nil {
269- t .Fatalf ("error deserializing proof: %v" , err )
270- }
271-
272- droot , err := TreeFromProof (dproof , root .Commit ())
273- if err != nil {
274- t .Fatal (err )
275- }
276-
277- if ! Equal (droot .Commit (), root .Commitment ()) {
278- t .Log (ToDot (droot ), ToDot (root ))
279- t .Fatalf ("differing root commitments %x != %x" , droot .Commitment ().Bytes (), root .Commitment ().Bytes ())
280- }
281-
282- if ! Equal (droot .(* InternalNode ).children [0 ].(* LeafNode ).commitment , root .(* InternalNode ).children [0 ].Commit ()) {
283- t .Fatal ("differing commitment for child #0" )
284- }
285-
286- if ! Equal (droot .(* InternalNode ).children [64 ].Commit (), root .(* InternalNode ).children [64 ].Commit ()) {
287- t .Fatal ("differing commitment for child #64" )
288- }
289- }
290-
291- func TestStatelessDeserializeMissginChildNode (t * testing.T ) {
292- root := New ()
293- for _ , k := range [][]byte {zeroKeyTest , oneKeyTest , ffx32KeyTest } {
294- root .Insert (k , fourtyKeyTest , nil )
295- }
296-
297- proof , _ , _ , _ , _ := MakeVerkleMultiProof (root , keylist {zeroKeyTest , fourtyKeyTest }, map [string ][]byte {string (zeroKeyTest ): fourtyKeyTest , string (fourtyKeyTest ): nil })
298-
299- serialized , statediff , err := SerializeProof (proof )
300- if err != nil {
301- t .Fatalf ("could not serialize proof: %v" , err )
302- }
303-
304- dproof , err := DeserializeProof (serialized , statediff )
305- if err != nil {
306- t .Fatalf ("error deserializing proof: %v" , err )
307- }
308-
309- droot , err := TreeFromProof (dproof , root .Commit ())
310- if err != nil {
311- t .Fatal (err )
312- }
313-
314- if ! Equal (droot .Commit (), root .Commit ()) {
315- t .Fatal ("differing root commitments" )
316- }
317- t .Log (ToDot (root ))
318- t .Log (ToDot (droot ))
319- if ! Equal (droot .(* InternalNode ).children [0 ].Commit (), root .(* InternalNode ).children [0 ].Commit ()) {
320- t .Fatal ("differing commitment for child #0" )
321- }
322-
323- if droot .(* InternalNode ).children [64 ] != nil {
324- t .Fatalf ("non-nil child #64: %v" , droot .(* InternalNode ).children [64 ])
325- }
326- }
327-
328- func TestStatelessDeserializeDepth2 (t * testing.T ) {
329- root := New ()
330- key1 , _ := hex .DecodeString ("0000010000000000000000000000000000000000000000000000000000000000" )
331- for _ , k := range [][]byte {zeroKeyTest , key1 } {
332- root .Insert (k , fourtyKeyTest , nil )
333- }
334-
335- proof , _ , _ , _ , _ := MakeVerkleMultiProof (root , keylist {zeroKeyTest , key1 }, map [string ][]byte {string (zeroKeyTest ): fourtyKeyTest , string (key1 ): nil })
336-
337- serialized , statediff , err := SerializeProof (proof )
338- if err != nil {
339- t .Fatalf ("could not serialize proof: %v" , err )
340- }
341-
342- dproof , err := DeserializeProof (serialized , statediff )
343- if err != nil {
344- t .Fatalf ("error deserializing proof: %v" , err )
345- }
346-
347- droot , err := TreeFromProof (dproof , root .Commit ())
348- if err != nil {
349- t .Fatal (err )
350- }
351-
352- if ! Equal (droot .Commit (), root .Commit ()) {
353- t .Fatal ("differing root commitments" )
354- }
355-
356- if ! Equal (droot .(* InternalNode ).children [0 ].Commit (), root .(* InternalNode ).children [0 ].Commit ()) {
357- t .Fatal ("differing commitment for child #0" )
358- }
359- }
360-
361- func TestStatelessGetProofItems (t * testing.T ) {
362- insertedKeys := [][]byte {zeroKeyTest , oneKeyTest , ffx32KeyTest }
363- provenKeys := [][]byte {zeroKeyTest , fourtyKeyTest }
364-
365- root := New ()
366- for _ , k := range insertedKeys {
367- root .Insert (k , fourtyKeyTest , nil )
368- }
369-
370- proof , _ , _ , _ , _ := MakeVerkleMultiProof (root , keylist (provenKeys ), map [string ][]byte {string (zeroKeyTest ): fourtyKeyTest , string (fourtyKeyTest ): nil })
371-
372- serialized , statediff , err := SerializeProof (proof )
373- if err != nil {
374- t .Fatalf ("could not serialize proof: %v" , err )
375- }
376-
377- dproof , err := DeserializeProof (serialized , statediff )
378- if err != nil {
379- t .Fatalf ("error deserializing proof: %v" , err )
380- }
381-
382- droot , err := TreeFromProof (dproof , root .Commit ())
383- if err != nil {
384- t .Fatal (err )
385- }
386-
387- pel , _ , _ := droot .GetProofItems (keylist (provenKeys ))
388- pef , _ , _ := root .GetProofItems (keylist (provenKeys ))
389-
390- for i , c := range pel .Cis {
391- if ! Equal (c , pef .Cis [i ]) {
392- t .Fatalf ("differing commitment at %d: %x != %x" , i , c .Bytes (), pef .Cis [i ].Bytes ())
393- }
394- }
395- if len (pel .Cis ) != len (pef .Cis ) {
396- t .Fatal ("commitments have different length" )
397- }
398-
399- if ! bytes .Equal (pel .Zis , pef .Zis ) {
400- t .Fatalf ("differing index list %v != %v" , pel .Zis , pef .Zis )
401- }
402- if len (pel .Zis ) != len (pef .Zis ) {
403- t .Fatal ("indices have different length" )
404- }
405-
406- for i , y := range pel .Yis {
407- l := y .Bytes ()
408- f := pef .Yis [i ].Bytes ()
409- if ! bytes .Equal (l [:], f [:]) {
410- t .Fatalf ("differing eval #%d %x != %x" , i , l , f )
411- }
412- }
413- if len (pel .Yis ) != len (pef .Yis ) {
414- t .Fatal ("evaluations have different length" )
415- }
416- }
417-
418253// This test checks that node resolution works for StatelessNode
419254func TestStatelessInsertIntoHash (t * testing.T ) {
420255 root := NewStateless ()
0 commit comments