mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 13:37:24 +00:00
ScriptChunkTest: Use Guava for concatenating byte arrays.
This commit is contained in:
@@ -28,7 +28,8 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.spongycastle.util.Arrays;
|
|
||||||
|
import com.google.common.primitives.Bytes;
|
||||||
|
|
||||||
public class ScriptChunkTest {
|
public class ScriptChunkTest {
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ public class ScriptChunkTest {
|
|||||||
for (byte len = 1; len < OP_PUSHDATA1; len++) {
|
for (byte len = 1; len < OP_PUSHDATA1; len++) {
|
||||||
byte[] bytes = new byte[len];
|
byte[] bytes = new byte[len];
|
||||||
RANDOM.nextBytes(bytes);
|
RANDOM.nextBytes(bytes);
|
||||||
byte[] expected = Arrays.concatenate(new byte[] { len }, bytes);
|
byte[] expected = Bytes.concat(new byte[] { len }, bytes);
|
||||||
byte[] actual = new ScriptChunk(len, bytes).toByteArray();
|
byte[] actual = new ScriptChunk(len, bytes).toByteArray();
|
||||||
assertArrayEquals(expected, actual);
|
assertArrayEquals(expected, actual);
|
||||||
}
|
}
|
||||||
@@ -86,7 +87,7 @@ public class ScriptChunkTest {
|
|||||||
// OP_PUSHDATA1
|
// OP_PUSHDATA1
|
||||||
byte[] bytes = new byte[0xFF];
|
byte[] bytes = new byte[0xFF];
|
||||||
RANDOM.nextBytes(bytes);
|
RANDOM.nextBytes(bytes);
|
||||||
byte[] expected = Arrays.concatenate(new byte[] { OP_PUSHDATA1, (byte) 0xFF }, bytes);
|
byte[] expected = Bytes.concat(new byte[] { OP_PUSHDATA1, (byte) 0xFF }, bytes);
|
||||||
byte[] actual = new ScriptChunk(OP_PUSHDATA1, bytes).toByteArray();
|
byte[] actual = new ScriptChunk(OP_PUSHDATA1, bytes).toByteArray();
|
||||||
assertArrayEquals(expected, actual);
|
assertArrayEquals(expected, actual);
|
||||||
}
|
}
|
||||||
@@ -96,7 +97,7 @@ public class ScriptChunkTest {
|
|||||||
// OP_PUSHDATA2
|
// OP_PUSHDATA2
|
||||||
byte[] bytes = new byte[0x0102];
|
byte[] bytes = new byte[0x0102];
|
||||||
RANDOM.nextBytes(bytes);
|
RANDOM.nextBytes(bytes);
|
||||||
byte[] expected = Arrays.concatenate(new byte[] { OP_PUSHDATA2, 0x02, 0x01 }, bytes);
|
byte[] expected = Bytes.concat(new byte[] { OP_PUSHDATA2, 0x02, 0x01 }, bytes);
|
||||||
byte[] actual = new ScriptChunk(OP_PUSHDATA2, bytes).toByteArray();
|
byte[] actual = new ScriptChunk(OP_PUSHDATA2, bytes).toByteArray();
|
||||||
assertArrayEquals(expected, actual);
|
assertArrayEquals(expected, actual);
|
||||||
}
|
}
|
||||||
@@ -106,7 +107,7 @@ public class ScriptChunkTest {
|
|||||||
// OP_PUSHDATA4
|
// OP_PUSHDATA4
|
||||||
byte[] bytes = new byte[0x0102];
|
byte[] bytes = new byte[0x0102];
|
||||||
RANDOM.nextBytes(bytes);
|
RANDOM.nextBytes(bytes);
|
||||||
byte[] expected = Arrays.concatenate(new byte[] { OP_PUSHDATA4, 0x02, 0x01, 0x00, 0x00 }, bytes);
|
byte[] expected = Bytes.concat(new byte[] { OP_PUSHDATA4, 0x02, 0x01, 0x00, 0x00 }, bytes);
|
||||||
byte[] actual = new ScriptChunk(OP_PUSHDATA4, bytes).toByteArray();
|
byte[] actual = new ScriptChunk(OP_PUSHDATA4, bytes).toByteArray();
|
||||||
assertArrayEquals(expected, actual);
|
assertArrayEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user