-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6017 from 317787106/feature/print_sr_queue_size
feat(log): print transaction size from pending and repush after generating block
- Loading branch information
Showing
2 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
plugins/src/test/java/org/tron/plugins/utils/ByteArrayTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.tron.plugins.utils; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
@Slf4j | ||
public class ByteArrayTest { | ||
|
||
@Test | ||
public void testToStrToInt() { | ||
String test = "abc"; | ||
byte[] testBytes = test.getBytes(); | ||
Assert.assertEquals(test, ByteArray.toStr(testBytes)); | ||
|
||
int i = 5; | ||
Assert.assertEquals(ByteArray.toInt(ByteArray.fromInt(i)), 5); | ||
} | ||
|
||
@Test | ||
public void testFromHexString() { | ||
Assert.assertArrayEquals(ByteArray.EMPTY_BYTE_ARRAY, ByteArray.fromHexString(null)); | ||
|
||
Assert.assertArrayEquals(ByteArray.fromHexString("12"), ByteArray.fromHexString("0x12")); | ||
|
||
Assert.assertArrayEquals(ByteArray.fromHexString("0x2"), ByteArray.fromHexString("0x02")); | ||
} | ||
|
||
@Test | ||
public void testCompareUnsigned() { | ||
byte[] a = new byte[] {1, 2}; | ||
Assert.assertEquals(0, ByteArray.compareUnsigned(a, a)); | ||
Assert.assertEquals(-1, ByteArray.compareUnsigned(null, a)); | ||
Assert.assertEquals(1, ByteArray.compareUnsigned(a, null)); | ||
|
||
byte[] b = new byte[] {1, 3}; | ||
Assert.assertEquals(-1, ByteArray.compareUnsigned(a, b)); | ||
Assert.assertEquals(1, ByteArray.compareUnsigned(b, a)); | ||
|
||
byte[] c = new byte[] {1, 2, 3}; | ||
Assert.assertEquals(-1, ByteArray.compareUnsigned(a, c)); | ||
Assert.assertEquals(1, ByteArray.compareUnsigned(c, a)); | ||
} | ||
} |