Skip to content

Commit

Permalink
Update RLPTest.testWrapUnwrap()
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalinin committed Aug 30, 2018
1 parent a01e51d commit 5474319
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ethereumj-core/src/test/java/org/ethereum/util/RLPTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1778,16 +1778,19 @@ public void testDepthLimit() {
@Test
public void testWrapUnwrap() {

byte[] shortItemData = new byte[] {(byte) 0x81};
byte[] longItemData = new byte[57]; new Random().nextBytes(longItemData);

byte[] nullArray = RLP.encodeElement(new byte[] {});
byte[] singleZero = RLP.encodeElement(new byte[] {0});
byte[] singleByte = RLP.encodeElement(new byte[] {1});
byte[] shortItem = RLP.encodeElement(new byte[] {(byte) 0x81});
byte[] longItemData = new byte[57]; new Random().nextBytes(longItemData);
byte[] shortItem = RLP.encodeElement(shortItemData);
byte[] longItem = RLP.encodeElement(longItemData);
byte[] shortList = RLP.encodeList(shortItem, shortItem, shortItem);
byte[] longList = RLP.encodeList(longItem, longItem, longItem);

byte[] encoded = RLP.wrapList(nullArray, singleZero, singleByte, shortItem, longItem, shortList, longList);
byte[] encoded = RLP.wrapList(nullArray, singleZero, singleByte, shortItem, longItem,
shortList, longList, shortItemData, longItemData);
RLPList decoded = RLP.unwrapList(encoded);

assertArrayEquals(nullArray, decoded.get(0).getRLPData());
Expand All @@ -1797,5 +1800,7 @@ public void testWrapUnwrap() {
assertArrayEquals(longItem, decoded.get(4).getRLPData());
assertArrayEquals(shortList, decoded.get(5).getRLPData());
assertArrayEquals(longList, decoded.get(6).getRLPData());
assertArrayEquals(shortItemData, decoded.get(7).getRLPData());
assertArrayEquals(longItemData, decoded.get(8).getRLPData());
}
}

0 comments on commit 5474319

Please sign in to comment.