unsupported length test moved to ignored list
This commit is contained in:
parent
e682c4a4b0
commit
bb824e2717
|
@ -1,5 +1,6 @@
|
||||||
package org.ethereum.util;
|
package org.ethereum.util;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import org.ethereum.crypto.HashUtil;
|
import org.ethereum.crypto.HashUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -670,6 +671,7 @@ public class RLPTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodeLength() {
|
public void testEncodeLength() {
|
||||||
|
|
||||||
int length;
|
int length;
|
||||||
int offset;
|
int offset;
|
||||||
byte[] encodedLength;
|
byte[] encodedLength;
|
||||||
|
@ -686,18 +688,35 @@ public class RLPTest {
|
||||||
encodedLength = RLP.encodeLength(length, offset);
|
encodedLength = RLP.encodeLength(length, offset);
|
||||||
expected = "f838";
|
expected = "f838";
|
||||||
assertEquals(expected, Hex.toHexString(encodedLength));
|
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
|
// Code from: http://stackoverflow.com/a/4785776/459349
|
||||||
private String bytesToAscii(byte[] b) {
|
private String bytesToAscii(byte[] b) {
|
||||||
|
|
Loading…
Reference in New Issue