@@ -78,6 +78,11 @@ public class AdversarialDataTest {
78
78
invalidTest (MapLeaf .unsafeCreate (new MapEntry [0 ]));
79
79
}
80
80
81
+ @ Test public void testBadAddress () {
82
+ invalidTest (Address .unsafeCreate (-1 ));
83
+ invalidTest (Address .unsafeCreate (Long .MIN_VALUE ));
84
+ }
85
+
81
86
@ SuppressWarnings ({ "unchecked" , "null" })
82
87
@ Test public void testBadSetTree () {
83
88
SetTree <CVMLong > a = Samples .INT_SET_300 ;
@@ -204,6 +209,19 @@ public void testBadIndex() {
204
209
Index c2 =Index .create (Blobs .fromHex ("1231" ),CVMLong .ZERO );
205
210
invalidTest (Index .unsafeCreate (3 , null , new Ref [] {c1 .getRef (),c2 .getRef ()}, 5 , 2 ));
206
211
}
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
+ }
207
225
208
226
}
209
227
@@ -303,7 +321,7 @@ private void doEncodingTest(ACell b) {
303
321
Blob enc =null ;
304
322
try {
305
323
enc = b .getEncoding ();
306
- } catch (Throwable t ) {
324
+ } catch (Exception t ) {
307
325
// probably no valid encoding, so skip this test
308
326
return ;
309
327
}
@@ -316,7 +334,7 @@ private void doEncodingTest(ACell b) {
316
334
// not a readable format, so probably not dangerous
317
335
return ;
318
336
} catch (InvalidDataException e ) {
319
- fail ("Failed to validate after re-reading?" );
337
+ fail ("Failed to validate after re-reading?" , e );
320
338
}
321
339
322
340
if (c .isCompletelyEncoded ()) {
0 commit comments