[Java] Avoid unnecessary array copying in tests (#247)
This commit is contained in:
parent
7695db3330
commit
88924c8aa7
|
@ -6,7 +6,6 @@ import ethereum.ckzg4844.test_formats.*;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -234,10 +233,6 @@ public class TestUtils {
|
||||||
return randomBLSFieldElement().toArray(ByteOrder.LITTLE_ENDIAN);
|
return randomBLSFieldElement().toArray(ByteOrder.LITTLE_ENDIAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InputStream readResource(final String resource) {
|
|
||||||
return Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getFiles(String path) {
|
public static List<String> getFiles(String path) {
|
||||||
try {
|
try {
|
||||||
try (Stream<Path> stream = Files.list(Paths.get(path))) {
|
try (Stream<Path> stream = Files.list(Paths.get(path))) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ public class BlobToKzgCommitmentTest {
|
||||||
private String blob;
|
private String blob;
|
||||||
|
|
||||||
public byte[] getBlob() {
|
public byte[] getBlob() {
|
||||||
return Bytes.fromHexString(blob).toArray();
|
return Bytes.fromHexString(blob).toArrayUnsafe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ public class ComputeBlobKzgProofTest {
|
||||||
private String commitment;
|
private String commitment;
|
||||||
|
|
||||||
public byte[] getBlob() {
|
public byte[] getBlob() {
|
||||||
return Bytes.fromHexString(blob).toArray();
|
return Bytes.fromHexString(blob).toArrayUnsafe();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getCommitment() {
|
public byte[] getCommitment() {
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class ComputeKzgProofTest {
|
||||||
private String z;
|
private String z;
|
||||||
|
|
||||||
public byte[] getBlob() {
|
public byte[] getBlob() {
|
||||||
return Bytes.fromHexString(blob).toArray();
|
return Bytes.fromHexString(blob).toArrayUnsafe();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getZ() {
|
public byte[] getZ() {
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class VerifyBlobKzgProofBatchTest {
|
||||||
return TestUtils.flatten(
|
return TestUtils.flatten(
|
||||||
blobs.stream()
|
blobs.stream()
|
||||||
.map(Bytes::fromHexString)
|
.map(Bytes::fromHexString)
|
||||||
.map(Bytes::toArray)
|
.map(Bytes::toArrayUnsafe)
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
.toArray(byte[][]::new));
|
.toArray(byte[][]::new));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class VerifyBlobKzgProofTest {
|
||||||
private String proof;
|
private String proof;
|
||||||
|
|
||||||
public byte[] getBlob() {
|
public byte[] getBlob() {
|
||||||
return Bytes.fromHexString(blob).toArray();
|
return Bytes.fromHexString(blob).toArrayUnsafe();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getCommitment() {
|
public byte[] getCommitment() {
|
||||||
|
|
Loading…
Reference in New Issue