Skip to content

Commit

Permalink
modify rlp encode
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyong199311080810 committed Dec 20, 2019
1 parent c36a53c commit 39454d6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'org.tdf'
version '1.1.14'
version '1.1.15'

sourceCompatibility = 1.8

Expand Down
7 changes: 2 additions & 5 deletions src/main/java/org/tdf/rlp/RLPParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private int estimateSize() {
if (prefix < OFFSET_SHORT_ITEM) {
return 1;
}
if (prefix < OFFSET_LONG_ITEM) {
if (prefix <= OFFSET_LONG_ITEM) {
return prefix - OFFSET_SHORT_ITEM + 1;
}
if (prefix < OFFSET_SHORT_LIST) {
Expand Down Expand Up @@ -136,11 +136,8 @@ private RLPItem readItem() {
if (prefix < OFFSET_SHORT_ITEM) {
return RLPItem.fromBytes(new byte[]{(byte) prefix});
}
if (prefix < OFFSET_LONG_ITEM) {
if (prefix <= OFFSET_LONG_ITEM) {
int length = prefix - OFFSET_SHORT_ITEM;
if (length == 0) {
return RLPItem.NULL;
}
RLPItem item = new RLPItem(new LazyByteArray(raw, offset, offset + length));
skip(length);
return item;
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/org/tdf/rlp/RLPTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,6 @@ public void testIgnore(){
assert el.get(1).asString().equals("111");
}

@Ignore
@Test
public void testbug() throws Exception{
LazyByteArray data = new LazyByteArray(HexBytes.decode("3d4d105a3fc6db71d35ed654b1b7aab73d8fa50d"), 0, 20);
Expand All @@ -1646,6 +1645,6 @@ public void testbug() throws Exception{
.data(data)
.build();
RLPList li = RLPList.of(item1, item2);
assert RLPElement.fromEncoded(li.getEncoded(), false).size() == 3;
assert RLPElement.fromEncoded(li.getEncoded(), false).size() == 2;
}
}

0 comments on commit 39454d6

Please sign in to comment.