@@ -78,6 +78,11 @@ public class AdversarialDataTest {
7878 invalidTest (MapLeaf .unsafeCreate (new MapEntry [0 ]));
7979 }
8080
81+ @ Test public void testBadAddress () {
82+ invalidTest (Address .unsafeCreate (-1 ));
83+ invalidTest (Address .unsafeCreate (Long .MIN_VALUE ));
84+ }
85+
8186 @ SuppressWarnings ({ "unchecked" , "null" })
8287 @ Test public void testBadSetTree () {
8388 SetTree <CVMLong > a = Samples .INT_SET_300 ;
@@ -204,6 +209,19 @@ public void testBadIndex() {
204209 Index c2 =Index .create (Blobs .fromHex ("1231" ),CVMLong .ZERO );
205210 invalidTest (Index .unsafeCreate (3 , null , new Ref [] {c1 .getRef (),c2 .getRef ()}, 5 , 2 ));
206211 }
212+
213+ { // Two colliding children
214+ Index c1 =Index .create (Blobs .fromHex ("1230" ),CVMLong .ONE );
215+ Index c2 =Index .create (Blobs .fromHex ("1230" ),CVMLong .ZERO );
216+ invalidTest (Index .unsafeCreate (3 , null , new Ref [] {c1 .getRef (),c2 .getRef ()}, 1 , 2 ));
217+ invalidTest (Index .unsafeCreate (3 , null , new Ref [] {c1 .getRef (),c2 .getRef ()}, 3 , 2 ));
218+ }
219+
220+ { // Two colliding children at max depth
221+ Index c1 =Index .create (Blobs .fromHex ("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef00" ),CVMLong .ONE );
222+ Index c2 =Index .create (Blobs .fromHex ("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef11" ),CVMLong .ONE );
223+ invalidTest (Index .unsafeCreate (64 , null , new Ref [] {c1 .getRef (),c2 .getRef ()}, 3 , 2 ));
224+ }
207225
208226 }
209227
@@ -303,7 +321,7 @@ private void doEncodingTest(ACell b) {
303321 Blob enc =null ;
304322 try {
305323 enc = b .getEncoding ();
306- } catch (Throwable t ) {
324+ } catch (Exception t ) {
307325 // probably no valid encoding, so skip this test
308326 return ;
309327 }
@@ -316,7 +334,7 @@ private void doEncodingTest(ACell b) {
316334 // not a readable format, so probably not dangerous
317335 return ;
318336 } catch (InvalidDataException e ) {
319- fail ("Failed to validate after re-reading?" );
337+ fail ("Failed to validate after re-reading?" , e );
320338 }
321339
322340 if (c .isCompletelyEncoded ()) {
0 commit comments