@Test
public void testEncodeLength() {

    // length < 56
    int length = 1;
    int offset = 128;
    byte[] encodedLength = encodeLength(length, offset);
    String expected = "81";
    assertEquals(expected, Hex.toHexString(encodedLength));
    // 56 > length < 2^64
    length = 56;
    offset = 192;
    encodedLength = encodeLength(length, offset);
    expected = "f838";
    assertEquals(expected, Hex.toHexString(encodedLength));
}