Skip to content

Commit

Permalink
replace tabs with spaces in test
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Jul 23, 2024
1 parent ba5ec2d commit ebc9a46
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions src/test/java/com/esaulpaugh/headlong/rlp/RLPStreamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,50 +61,50 @@ public class RLPStreamTest {
(byte) 0xca, (byte) 0x84, 92, '\r', '\n', '\f', (byte) 0x84, '\u0009', 'o', 'g', 's',
};

@Test
public void testRLPOutputStream() throws Throwable {
Object[] objects = new Object[] {
Strings.decode("0573490923738490"),
new HashSet<byte[]>(),
new Object[] { new byte[] { 0x77, 0x61 } }
};
TestUtils.assertThrown(NullPointerException.class, () -> {try(RLPOutputStream ros = new RLPOutputStream(null)){}});
try (Baos baos = new Baos(); RLPOutputStream ros = new RLPOutputStream(baos)) {
ros.write(0xc0);
ros.write(new byte[] { (byte) 0x7f, (byte) 0x20 });
ros.writeSequence(new byte[] { 0x01 }, new byte[] { 0x02 });
ros.writeSequence(Collections.singletonList(new byte[] { 0x03 }));
ros.writeList(Arrays.asList(new byte[] { 0x04 }, new byte[] { 0x05 }, new byte[] { 0x06 }));
byte[] bytes = baos.toByteArray();
assertEquals("81c0827f20010203c3040506", Strings.encode(bytes));
}
try (Baos baos = new Baos(); RLPOutputStream ros = new RLPOutputStream(baos)) {
Notation notation = Notation.forObjects(objects);
ros.writeSequence(objects);
byte[] bytes = baos.toByteArray();
assertEquals(notation, Notation.forEncoding(bytes));
}
try (Baos baos = new Baos(); RLPOutputStream ros = new RLPOutputStream(baos)) {
ros.writeList(Arrays.asList(objects));
byte[] bytes = baos.toByteArray();
assertEquals(Notation.forObjects(new Object[] { objects }), Notation.forEncoding(bytes));
assertEquals("ce880573490923738490c0c3827761", baos.toString());
assertEquals("ce880573490923738490c0c3827761", ros.toString());
}
}
@Test
public void testRLPOutputStream() throws Throwable {
Object[] objects = new Object[] {
Strings.decode("0573490923738490"),
new HashSet<byte[]>(),
new Object[] { new byte[] { 0x77, 0x61 } }
};
TestUtils.assertThrown(NullPointerException.class, () -> {try(RLPOutputStream ros = new RLPOutputStream(null)){}});
try (Baos baos = new Baos(); RLPOutputStream ros = new RLPOutputStream(baos)) {
ros.write(0xc0);
ros.write(new byte[] { (byte) 0x7f, (byte) 0x20 });
ros.writeSequence(new byte[] { 0x01 }, new byte[] { 0x02 });
ros.writeSequence(Collections.singletonList(new byte[] { 0x03 }));
ros.writeList(Arrays.asList(new byte[] { 0x04 }, new byte[] { 0x05 }, new byte[] { 0x06 }));
byte[] bytes = baos.toByteArray();
assertEquals("81c0827f20010203c3040506", Strings.encode(bytes));
}
try (Baos baos = new Baos(); RLPOutputStream ros = new RLPOutputStream(baos)) {
Notation notation = Notation.forObjects(objects);
ros.writeSequence(objects);
byte[] bytes = baos.toByteArray();
assertEquals(notation, Notation.forEncoding(bytes));
}
try (Baos baos = new Baos(); RLPOutputStream ros = new RLPOutputStream(baos)) {
ros.writeList(Arrays.asList(objects));
byte[] bytes = baos.toByteArray();
assertEquals(Notation.forObjects(new Object[] { objects }), Notation.forEncoding(bytes));
assertEquals("ce880573490923738490c0c3827761", baos.toString());
assertEquals("ce880573490923738490c0c3827761", ros.toString());
}
}

@Test
public void testObjectRLPStream() throws IOException {

// write RLP
Baos baos = new Baos();
try (ObjectOutputStream oos = new ObjectOutputStream(new RLPOutputStream(baos))) {
oos.writeUTF("hello");
try (ObjectOutputStream oos = new ObjectOutputStream(new RLPOutputStream(baos))) {
oos.writeUTF("hello");
// oos.flush();
oos.writeChar('Z');
// oos.writeObject(Tuple.of("jinro", new byte[] { (byte) 0xc0 }, new Boolean[] { false, true }));
oos.flush();
}
oos.writeChar('Z');
// oos.writeObject(Tuple.of("jinro", new byte[] { (byte) 0xc0 }, new Boolean[] { false, true }));
oos.flush();
}

// decode RLP
Iterator<RLPItem> iter = RLP_STRICT.sequenceIterator(baos.toByteArray());
Expand Down

0 comments on commit ebc9a46

Please sign in to comment.