@Test public void decodeValueWithLeadingZerosAsUnsignedInt() { RLPInput in = RLP.input(h("0x84000000D0")); assertThat(in.readUnsignedInt()).isEqualTo(208); }
@Test public void decodeValueWithLeadingZerosAsBytesValue() { RLPInput in = RLP.input(h("0x8800000000000000D0")); assertThat(BytesValues.extractLong(in.readBytesValue())).isEqualTo(208); } }
@Test public void decodeValueWithLeadingZerosAsUnsignedShort() { RLPInput in = RLP.input(h("0x8200D0")); assertThat(in.readUnsignedShort()).isEqualTo(208); }
@Test public void rlpListSizeHoldsMaxValue() { // Size value encode max positive int. So, size is decoded, but // RLP is malformed because the actual payload is not present AssertionsForClassTypes.assertThatThrownBy(() -> RLP.input(h("0xFB7FFFFFFF")).readBytesValue()) .isInstanceOf(CorruptedRLPInputException.class) .hasMessageContaining( "Input doesn't have enough data for RLP encoding: encoding advertise a payload ending at byte 2147483652 but input has size 5"); }
@Test public void rlpItemSizeHoldsMaxValue() { // Size value encode max positive int. So, size is decoded, but // RLP is malformed because the actual payload is not present AssertionsForClassTypes.assertThatThrownBy(() -> RLP.input(h("0xBB7FFFFFFF")).readBytesValue()) .isInstanceOf(CorruptedRLPInputException.class) .hasMessageContaining("payload should start at offset 5 but input has only 5 bytes"); }
@Test public void singleLongElementBoundaryCase_6() { // A RLPx Frame can have a maximum length of 0xffffff, so boundary above this // will be not be real world scenarios. final RLPInput in = RLP.input(h("0xbb01000000" + times("3c", 16777216))); assertThat(in.isDone()).isFalse(); assertThat(in.readBytesValue()).isEqualTo(h(times("3c", 16777216))); assertThat(in.isDone()).isTrue(); }