unsupported length test moved to ignored list

This commit is contained in:
romanman 2014-06-26 19:43:09 +01:00
parent e682c4a4b0
commit bb824e2717
1 changed files with 30 additions and 11 deletions

View File

@ -1,5 +1,6 @@
package org.ethereum.util;
import org.junit.Ignore;
import org.spongycastle.util.encoders.Hex;
import org.ethereum.crypto.HashUtil;
import org.junit.Test;
@ -670,6 +671,7 @@ public class RLPTest {
@Test
public void testEncodeLength() {
int length;
int offset;
byte[] encodedLength;
@ -686,18 +688,35 @@ public class RLPTest {
encodedLength = RLP.encodeLength(length, offset);
expected = "f838";
assertEquals(expected, Hex.toHexString(encodedLength));
// length > 2^64
// TODO: Fix this test - when casting double to int, information gets lost since 'int' is max (2^31)-1
double maxLength = Math.pow(256, 8); offset = 192;
try {
encodedLength = RLP.encodeLength( (int) maxLength, offset);
System.out.println("length: " + length + ", offset: " + offset + ", encoded: " + Arrays.toString(encodedLength));
fail("Expecting RuntimeException: 'Input too long'");
} catch(RuntimeException e) {
// Success!
}
}
@Test
@Ignore
public void unsupportedLength(){
// length > 2^64
// TODO: Fix this test - when casting double to int, information gets lost since 'int' is max (2^31)-1
int length;
int offset;
length = 56;
offset = 192;
byte[] encodedLength;
double maxLength = Math.pow(256, 8);
try {
encodedLength = RLP.encodeLength( (int) maxLength, offset);
System.out.println("length: " + length + ", offset: " + offset + ", encoded: " + Arrays.toString(encodedLength));
fail("Expecting RuntimeException: 'Input too long'");
} catch(RuntimeException e) {
// Success!
}
}
// Code from: http://stackoverflow.com/a/4785776/459349
private String bytesToAscii(byte[] b) {