### Question:
RLP { public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.equals(BigInteger.ZERO)) { return encodeByte((byte) 0); } else { return encodeElement(asUnsignedByteArray(srcBigInteger)); } }  static int decodeInt(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int index); static RLPList decode2(byte[] msgData); static RLPElement decode2OneItem(byte[] msgData, int startPos); static DecodeResult decode(byte[] data, int pos); static byte[] encode(Object input); static byte[] encodeLength(int length, int offset); static byte[] encodeByte(byte singleByte); static byte[] encodeShort(short singleShort); static byte[] encodeInt(int singleInt); static byte[] encodeLong(long l); static byte[] encodeString(String srcString); static byte[] encodeBigInteger(BigInteger srcBigInteger); static byte[] encodeElement(byte[] srcData); static int calcElementPrefixSize(byte[] srcData); static byte[] encodeListHeader(int size); static byte[] encodeLongElementHeader(int length); static byte[] encodeList(byte[]... elements);  }### Answer:
@Test public void testEncodeBigInteger() { BigInteger test = new BigInteger( "100102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", 16); String expected = "a0100102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"; byte[] encoderesult = RLP.encode(test); assertEquals(expected, Hex.toHexString(encoderesult)); byte[] decodeResult = (byte[]) decode(encoderesult, 0).getDecoded(); assertEquals(test, new BigInteger(1, decodeResult)); }
@Test public void encodeBigIntegerEdge_1() { BigInteger integer = new BigInteger("80", 10); byte[] encodedData = encodeBigInteger(integer); System.out.println(Hex.toHexString(encodedData)); }
@Test public void test6() { byte[] expected = new byte[] {(byte) 0x80}; byte[] data = encodeBigInteger(BigInteger.ZERO); assertArrayEquals(expected, data); }