RLP { public static byte[] encodeString(String srcString) { return encodeElement(srcString.getBytes()); }  static int decodeInt(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int index); static byte[] decodeIP4Bytes(byte[] data, int index); static int getFirstListElement(byte[] payload, int pos); static int getNextElementIndex(byte[] payload, int pos); static void fullTraverse(byte[] msgData, int level, int startPos,
			int endPos, int levelToIndex, Queue<Integer> index); static byte getCommandCode(byte[] data); static RLPList decode2(byte[] msgData); 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[] encodeString(String srcString); static byte[] encodeBigInteger(BigInteger srcBigInteger); static byte[] encodeElement(byte[] srcData); static byte[] encodeList(byte[]... elements);  }
@Test public void test7() { byte[] data = RLP.encodeString(""); assertArrayEquals(new byte[]{(byte)0x80}, data); byte[] expected = { (byte)0x90, (byte)0x45, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x65, (byte)0x75, (byte)0x6D, (byte)0x4A, (byte)0x20, (byte)0x43, (byte)0x6C, (byte)0x69, (byte)0x65, (byte)0x6E, (byte)0x74}; String test = "EthereumJ Client"; data = RLP.encodeString(test); assertArrayEquals(expected, data); String test2 = "Ethereum(++)/ZeroGox/v0.5.0/ncurses/Linux/g++"; byte[] expected2 = { (byte)0xAD, (byte)0x45, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x65, (byte)0x75, (byte)0x6D, (byte)0x28, (byte)0x2B, (byte)0x2B, (byte)0x29, (byte)0x2F, (byte)0x5A, (byte)0x65, (byte)0x72, (byte)0x6F, (byte)0x47, (byte)0x6F, (byte)0x78, (byte)0x2F, (byte)0x76, (byte)0x30, (byte)0x2E, (byte)0x35, (byte)0x2E, (byte)0x30, (byte)0x2F, (byte)0x6E, (byte)0x63, (byte)0x75, (byte)0x72, (byte)0x73, (byte)0x65, (byte)0x73, (byte)0x2F, (byte)0x4C, (byte)0x69, (byte)0x6E, (byte)0x75, (byte)0x78, (byte)0x2F, (byte)0x67, (byte)0x2B, (byte)0x2B}; data = RLP.encodeString(test2); assertArrayEquals(expected2, data); String test3 = "Ethereum(++)/ZeroGox/v0.5.0/ncurses/Linux/g++Ethereum(++)/ZeroGox/v0.5.0/ncurses/Linux/g++"; byte[] expected3 = {(byte)0xB8, (byte)0x5A, (byte)0x45, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x65, (byte)0x75, (byte)0x6D, (byte)0x28, (byte)0x2B, (byte)0x2B, (byte)0x29, (byte)0x2F, (byte)0x5A, (byte)0x65, (byte)0x72, (byte)0x6F, (byte)0x47, (byte)0x6F, (byte)0x78, (byte)0x2F, (byte)0x76, (byte)0x30, (byte)0x2E, (byte)0x35, (byte)0x2E, (byte)0x30, (byte)0x2F, (byte)0x6E, (byte)0x63, (byte)0x75, (byte)0x72, (byte)0x73, (byte)0x65, (byte)0x73, (byte)0x2F, (byte)0x4C, (byte)0x69, (byte)0x6E, (byte)0x75, (byte)0x78, (byte)0x2F, (byte)0x67, (byte)0x2B, (byte)0x2B, (byte)0x45, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x65, (byte)0x75, (byte)0x6D, (byte)0x28, (byte)0x2B, (byte)0x2B, (byte)0x29, (byte)0x2F, (byte)0x5A, (byte)0x65, (byte)0x72, (byte)0x6F, (byte)0x47, (byte)0x6F, (byte)0x78, (byte)0x2F, (byte)0x76, (byte)0x30, (byte)0x2E, (byte)0x35, (byte)0x2E, (byte)0x30, (byte)0x2F, (byte)0x6E, (byte)0x63, (byte)0x75, (byte)0x72, (byte)0x73, (byte)0x65, (byte)0x73, (byte)0x2F, (byte)0x4C, (byte)0x69, (byte)0x6E, (byte)0x75, (byte)0x78, (byte)0x2F, (byte)0x67, (byte)0x2B, (byte)0x2B}; data = RLP.encodeString(test3); assertArrayEquals(expected3, data); }