Add ref test count checks for all bindings (#211)
This commit is contained in:
parent
a1b52ac9e1
commit
5580f355ae
|
@ -80,7 +80,10 @@ public class ReferenceTests
|
||||||
Matcher matcher = new();
|
Matcher matcher = new();
|
||||||
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
||||||
|
|
||||||
foreach (string testFile in matcher.GetResultsInFullPath(_blobToKzgCommitmentTests))
|
IEnumerable<string> testFiles = matcher.GetResultsInFullPath(_blobToKzgCommitmentTests);
|
||||||
|
Assert.That(testFiles.Count(), Is.GreaterThan(0));
|
||||||
|
|
||||||
|
foreach (string testFile in testFiles)
|
||||||
{
|
{
|
||||||
string yaml = File.ReadAllText(testFile);
|
string yaml = File.ReadAllText(testFile);
|
||||||
BlobToKzgCommitmentTest test = _deserializer.Deserialize<BlobToKzgCommitmentTest>(yaml);
|
BlobToKzgCommitmentTest test = _deserializer.Deserialize<BlobToKzgCommitmentTest>(yaml);
|
||||||
|
@ -125,7 +128,10 @@ public class ReferenceTests
|
||||||
Matcher matcher = new();
|
Matcher matcher = new();
|
||||||
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
||||||
|
|
||||||
foreach (string testFile in matcher.GetResultsInFullPath(_computeKzgProofTests))
|
IEnumerable<string> testFiles = matcher.GetResultsInFullPath(_computeKzgProofTests);
|
||||||
|
Assert.That(testFiles.Count(), Is.GreaterThan(0));
|
||||||
|
|
||||||
|
foreach (string testFile in testFiles)
|
||||||
{
|
{
|
||||||
string yaml = File.ReadAllText(testFile);
|
string yaml = File.ReadAllText(testFile);
|
||||||
ComputeKzgProofTest test = _deserializer.Deserialize<ComputeKzgProofTest>(yaml);
|
ComputeKzgProofTest test = _deserializer.Deserialize<ComputeKzgProofTest>(yaml);
|
||||||
|
@ -174,7 +180,10 @@ public class ReferenceTests
|
||||||
Matcher matcher = new();
|
Matcher matcher = new();
|
||||||
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
||||||
|
|
||||||
foreach (string testFile in matcher.GetResultsInFullPath(_computeBlobKzgProofTests))
|
IEnumerable<string> testFiles = matcher.GetResultsInFullPath(_computeBlobKzgProofTests);
|
||||||
|
Assert.That(testFiles.Count(), Is.GreaterThan(0));
|
||||||
|
|
||||||
|
foreach (string testFile in testFiles)
|
||||||
{
|
{
|
||||||
string yaml = File.ReadAllText(testFile);
|
string yaml = File.ReadAllText(testFile);
|
||||||
ComputeBlobKzgProofTest test = _deserializer.Deserialize<ComputeBlobKzgProofTest>(yaml);
|
ComputeBlobKzgProofTest test = _deserializer.Deserialize<ComputeBlobKzgProofTest>(yaml);
|
||||||
|
@ -222,7 +231,10 @@ public class ReferenceTests
|
||||||
Matcher matcher = new();
|
Matcher matcher = new();
|
||||||
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
||||||
|
|
||||||
foreach (string testFile in matcher.GetResultsInFullPath(_verifyKzgProofTests))
|
IEnumerable<string> testFiles = matcher.GetResultsInFullPath(_verifyKzgProofTests);
|
||||||
|
Assert.That(testFiles.Count(), Is.GreaterThan(0));
|
||||||
|
|
||||||
|
foreach (string testFile in testFiles)
|
||||||
{
|
{
|
||||||
string yaml = File.ReadAllText(testFile);
|
string yaml = File.ReadAllText(testFile);
|
||||||
VerifyKzgProofTest test = _deserializer.Deserialize<VerifyKzgProofTest>(yaml);
|
VerifyKzgProofTest test = _deserializer.Deserialize<VerifyKzgProofTest>(yaml);
|
||||||
|
@ -268,7 +280,10 @@ public class ReferenceTests
|
||||||
Matcher matcher = new();
|
Matcher matcher = new();
|
||||||
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
||||||
|
|
||||||
foreach (string testFile in matcher.GetResultsInFullPath(_verifyBlobKzgProofTests))
|
IEnumerable<string> testFiles = matcher.GetResultsInFullPath(_verifyBlobKzgProofTests);
|
||||||
|
Assert.That(testFiles.Count(), Is.GreaterThan(0));
|
||||||
|
|
||||||
|
foreach (string testFile in testFiles)
|
||||||
{
|
{
|
||||||
string yaml = File.ReadAllText(testFile);
|
string yaml = File.ReadAllText(testFile);
|
||||||
VerifyBlobKzgProofTest test = _deserializer.Deserialize<VerifyBlobKzgProofTest>(yaml);
|
VerifyBlobKzgProofTest test = _deserializer.Deserialize<VerifyBlobKzgProofTest>(yaml);
|
||||||
|
@ -312,7 +327,10 @@ public class ReferenceTests
|
||||||
Matcher matcher = new();
|
Matcher matcher = new();
|
||||||
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
matcher.AddIncludePatterns(new[] { "*/*/data.yaml" });
|
||||||
|
|
||||||
foreach (string testFile in matcher.GetResultsInFullPath(_verifyBlobKzgProofBatchTests))
|
IEnumerable<string> testFiles = matcher.GetResultsInFullPath(_verifyBlobKzgProofBatchTests);
|
||||||
|
Assert.That(testFiles.Count(), Is.GreaterThan(0));
|
||||||
|
|
||||||
|
foreach (string testFile in testFiles)
|
||||||
{
|
{
|
||||||
string yaml = File.ReadAllText(testFile);
|
string yaml = File.ReadAllText(testFile);
|
||||||
VerifyBlobKzgProofBatchTest test = _deserializer.Deserialize<VerifyBlobKzgProofBatchTest>(yaml);
|
VerifyBlobKzgProofBatchTest test = _deserializer.Deserialize<VerifyBlobKzgProofBatchTest>(yaml);
|
||||||
|
|
|
@ -128,6 +128,8 @@ func TestBlobToKZGCommitment(t *testing.T) {
|
||||||
|
|
||||||
tests, err := filepath.Glob(blobToKZGCommitmentTests)
|
tests, err := filepath.Glob(blobToKZGCommitmentTests)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.True(t, len(tests) > 0)
|
||||||
|
|
||||||
for _, testPath := range tests {
|
for _, testPath := range tests {
|
||||||
t.Run(testPath, func(t *testing.T) {
|
t.Run(testPath, func(t *testing.T) {
|
||||||
testFile, err := os.Open(testPath)
|
testFile, err := os.Open(testPath)
|
||||||
|
@ -166,6 +168,8 @@ func TestComputeKZGProof(t *testing.T) {
|
||||||
|
|
||||||
tests, err := filepath.Glob(computeKZGProofTests)
|
tests, err := filepath.Glob(computeKZGProofTests)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.True(t, len(tests) > 0)
|
||||||
|
|
||||||
for _, testPath := range tests {
|
for _, testPath := range tests {
|
||||||
t.Run(testPath, func(t *testing.T) {
|
t.Run(testPath, func(t *testing.T) {
|
||||||
testFile, err := os.Open(testPath)
|
testFile, err := os.Open(testPath)
|
||||||
|
@ -218,6 +222,8 @@ func TestComputeBlobKZGProof(t *testing.T) {
|
||||||
|
|
||||||
tests, err := filepath.Glob(computeBlobKZGProofTests)
|
tests, err := filepath.Glob(computeBlobKZGProofTests)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.True(t, len(tests) > 0)
|
||||||
|
|
||||||
for _, testPath := range tests {
|
for _, testPath := range tests {
|
||||||
t.Run(testPath, func(t *testing.T) {
|
t.Run(testPath, func(t *testing.T) {
|
||||||
testFile, err := os.Open(testPath)
|
testFile, err := os.Open(testPath)
|
||||||
|
@ -265,6 +271,8 @@ func TestVerifyKZGProof(t *testing.T) {
|
||||||
|
|
||||||
tests, err := filepath.Glob(verifyKZGProofTests)
|
tests, err := filepath.Glob(verifyKZGProofTests)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.True(t, len(tests) > 0)
|
||||||
|
|
||||||
for _, testPath := range tests {
|
for _, testPath := range tests {
|
||||||
t.Run(testPath, func(t *testing.T) {
|
t.Run(testPath, func(t *testing.T) {
|
||||||
testFile, err := os.Open(testPath)
|
testFile, err := os.Open(testPath)
|
||||||
|
@ -325,6 +333,8 @@ func TestVerifyBlobKZGProof(t *testing.T) {
|
||||||
|
|
||||||
tests, err := filepath.Glob(verifyBlobKZGProofTests)
|
tests, err := filepath.Glob(verifyBlobKZGProofTests)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.True(t, len(tests) > 0)
|
||||||
|
|
||||||
for _, testPath := range tests {
|
for _, testPath := range tests {
|
||||||
t.Run(testPath, func(t *testing.T) {
|
t.Run(testPath, func(t *testing.T) {
|
||||||
testFile, err := os.Open(testPath)
|
testFile, err := os.Open(testPath)
|
||||||
|
@ -378,6 +388,8 @@ func TestVerifyBlobKZGProofBatch(t *testing.T) {
|
||||||
|
|
||||||
tests, err := filepath.Glob(verifyBlobKZGProofBatchTests)
|
tests, err := filepath.Glob(verifyBlobKZGProofBatchTests)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.True(t, len(tests) > 0)
|
||||||
|
|
||||||
for _, testPath := range tests {
|
for _, testPath := range tests {
|
||||||
t.Run(testPath, func(t *testing.T) {
|
t.Run(testPath, func(t *testing.T) {
|
||||||
testFile, err := os.Open(testPath)
|
testFile, err := os.Open(testPath)
|
||||||
|
|
|
@ -91,9 +91,11 @@ public class TestUtils {
|
||||||
|
|
||||||
public static List<BlobToKzgCommitmentTest> getBlobToKzgCommitmentTests() {
|
public static List<BlobToKzgCommitmentTest> getBlobToKzgCommitmentTests() {
|
||||||
final Stream.Builder<BlobToKzgCommitmentTest> tests = Stream.builder();
|
final Stream.Builder<BlobToKzgCommitmentTest> tests = Stream.builder();
|
||||||
|
List<String> testFiles = getTestFiles(BLOB_TO_KZG_COMMITMENT_TESTS);
|
||||||
|
assert !testFiles.isEmpty();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (String testFile : getTestFiles(BLOB_TO_KZG_COMMITMENT_TESTS)) {
|
for (String testFile : testFiles) {
|
||||||
String data = Files.readString(Path.of(testFile));
|
String data = Files.readString(Path.of(testFile));
|
||||||
BlobToKzgCommitmentTest test = OBJECT_MAPPER.readValue(data, BlobToKzgCommitmentTest.class);
|
BlobToKzgCommitmentTest test = OBJECT_MAPPER.readValue(data, BlobToKzgCommitmentTest.class);
|
||||||
tests.add(test);
|
tests.add(test);
|
||||||
|
@ -107,9 +109,11 @@ public class TestUtils {
|
||||||
|
|
||||||
public static List<ComputeKzgProofTest> getComputeKzgProofTests() {
|
public static List<ComputeKzgProofTest> getComputeKzgProofTests() {
|
||||||
final Stream.Builder<ComputeKzgProofTest> tests = Stream.builder();
|
final Stream.Builder<ComputeKzgProofTest> tests = Stream.builder();
|
||||||
|
List<String> testFiles = getTestFiles(COMPUTE_KZG_PROOF_TESTS);
|
||||||
|
assert !testFiles.isEmpty();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (String testFile : getTestFiles(COMPUTE_KZG_PROOF_TESTS)) {
|
for (String testFile : testFiles) {
|
||||||
String jsonData = Files.readString(Path.of(testFile));
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
ComputeKzgProofTest test = OBJECT_MAPPER.readValue(jsonData, ComputeKzgProofTest.class);
|
ComputeKzgProofTest test = OBJECT_MAPPER.readValue(jsonData, ComputeKzgProofTest.class);
|
||||||
tests.add(test);
|
tests.add(test);
|
||||||
|
@ -123,9 +127,11 @@ public class TestUtils {
|
||||||
|
|
||||||
public static List<ComputeBlobKzgProofTest> getComputeBlobKzgProofTests() {
|
public static List<ComputeBlobKzgProofTest> getComputeBlobKzgProofTests() {
|
||||||
final Stream.Builder<ComputeBlobKzgProofTest> tests = Stream.builder();
|
final Stream.Builder<ComputeBlobKzgProofTest> tests = Stream.builder();
|
||||||
|
List<String> testFiles = getTestFiles(COMPUTE_BLOB_KZG_PROOF_TESTS);
|
||||||
|
assert !testFiles.isEmpty();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (String testFile : getTestFiles(COMPUTE_BLOB_KZG_PROOF_TESTS)) {
|
for (String testFile : testFiles) {
|
||||||
String jsonData = Files.readString(Path.of(testFile));
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
ComputeBlobKzgProofTest test =
|
ComputeBlobKzgProofTest test =
|
||||||
OBJECT_MAPPER.readValue(jsonData, ComputeBlobKzgProofTest.class);
|
OBJECT_MAPPER.readValue(jsonData, ComputeBlobKzgProofTest.class);
|
||||||
|
@ -140,9 +146,11 @@ public class TestUtils {
|
||||||
|
|
||||||
public static List<VerifyKzgProofTest> getVerifyKzgProofTests() {
|
public static List<VerifyKzgProofTest> getVerifyKzgProofTests() {
|
||||||
final Stream.Builder<VerifyKzgProofTest> tests = Stream.builder();
|
final Stream.Builder<VerifyKzgProofTest> tests = Stream.builder();
|
||||||
|
List<String> testFiles = getTestFiles(VERIFY_KZG_PROOF_TESTS);
|
||||||
|
assert !testFiles.isEmpty();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (String testFile : getTestFiles(VERIFY_KZG_PROOF_TESTS)) {
|
for (String testFile : testFiles) {
|
||||||
String jsonData = Files.readString(Path.of(testFile));
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
VerifyKzgProofTest test = OBJECT_MAPPER.readValue(jsonData, VerifyKzgProofTest.class);
|
VerifyKzgProofTest test = OBJECT_MAPPER.readValue(jsonData, VerifyKzgProofTest.class);
|
||||||
tests.add(test);
|
tests.add(test);
|
||||||
|
@ -156,9 +164,11 @@ public class TestUtils {
|
||||||
|
|
||||||
public static List<VerifyBlobKzgProofTest> getVerifyBlobKzgProofTests() {
|
public static List<VerifyBlobKzgProofTest> getVerifyBlobKzgProofTests() {
|
||||||
final Stream.Builder<VerifyBlobKzgProofTest> tests = Stream.builder();
|
final Stream.Builder<VerifyBlobKzgProofTest> tests = Stream.builder();
|
||||||
|
List<String> testFiles = getTestFiles(VERIFY_BLOB_KZG_PROOF_TESTS);
|
||||||
|
assert !testFiles.isEmpty();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (String testFile : getTestFiles(VERIFY_BLOB_KZG_PROOF_TESTS)) {
|
for (String testFile : testFiles) {
|
||||||
String jsonData = Files.readString(Path.of(testFile));
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
VerifyBlobKzgProofTest test =
|
VerifyBlobKzgProofTest test =
|
||||||
OBJECT_MAPPER.readValue(jsonData, VerifyBlobKzgProofTest.class);
|
OBJECT_MAPPER.readValue(jsonData, VerifyBlobKzgProofTest.class);
|
||||||
|
@ -173,9 +183,11 @@ public class TestUtils {
|
||||||
|
|
||||||
public static List<VerifyBlobKzgProofBatchTest> getVerifyBlobKzgProofBatchTests() {
|
public static List<VerifyBlobKzgProofBatchTest> getVerifyBlobKzgProofBatchTests() {
|
||||||
final Stream.Builder<VerifyBlobKzgProofBatchTest> tests = Stream.builder();
|
final Stream.Builder<VerifyBlobKzgProofBatchTest> tests = Stream.builder();
|
||||||
|
List<String> testFiles = getTestFiles(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS);
|
||||||
|
assert !testFiles.isEmpty();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (String testFile : getTestFiles(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS)) {
|
for (String testFile : testFiles) {
|
||||||
String jsonData = Files.readString(Path.of(testFile));
|
String jsonData = Files.readString(Path.of(testFile));
|
||||||
VerifyBlobKzgProofBatchTest test =
|
VerifyBlobKzgProofBatchTest test =
|
||||||
OBJECT_MAPPER.readValue(jsonData, VerifyBlobKzgProofBatchTest.class);
|
OBJECT_MAPPER.readValue(jsonData, VerifyBlobKzgProofBatchTest.class);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{.used.}
|
{.used.}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[os, strutils, streams],
|
std/[os, sequtils, strutils, streams],
|
||||||
unittest2, yaml,
|
unittest2, yaml,
|
||||||
../kzg,
|
../kzg,
|
||||||
./types
|
./types
|
||||||
|
@ -41,11 +41,13 @@ proc fromHexList(T: type, xList: YamlNode): seq[T] =
|
||||||
result.add(T.fromHex(x.content))
|
result.add(T.fromHex(x.content))
|
||||||
|
|
||||||
template runTests(folder: string, body: untyped) =
|
template runTests(folder: string, body: untyped) =
|
||||||
for filename in walkDirRec(folder):
|
let test_files = walkDirRec(folder).toSeq()
|
||||||
test toTestName(filename):
|
check test_files.len > 0
|
||||||
|
for test_file in test_files:
|
||||||
|
test toTestName(test_file):
|
||||||
# nim template is hygienic, {.inject.} will allow body to
|
# nim template is hygienic, {.inject.} will allow body to
|
||||||
# access injected symbol in current scope
|
# access injected symbol in current scope
|
||||||
let n {.inject.} = loadYaml(filename)
|
let n {.inject.} = loadYaml(test_file)
|
||||||
try:
|
try:
|
||||||
body
|
body
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
|
@ -36,7 +36,7 @@ const SETUP_FILE_PATH = resolve(
|
||||||
|
|
||||||
const MAX_TOP_BYTE = 114;
|
const MAX_TOP_BYTE = 114;
|
||||||
|
|
||||||
const TEST_DIR = "../../../tests";
|
const TEST_DIR = "../../tests";
|
||||||
type BlobToKzgCommitmentTest = TestMeta<{ blob: string }, string>;
|
type BlobToKzgCommitmentTest = TestMeta<{ blob: string }, string>;
|
||||||
const BLOB_TO_KZG_COMMITMENT_TESTS = join(
|
const BLOB_TO_KZG_COMMITMENT_TESTS = join(
|
||||||
TEST_DIR,
|
TEST_DIR,
|
||||||
|
@ -110,6 +110,8 @@ describe("C-KZG", () => {
|
||||||
describe("reference tests should pass", () => {
|
describe("reference tests should pass", () => {
|
||||||
it("reference tests for blobToKzgCommitment should pass", () => {
|
it("reference tests for blobToKzgCommitment should pass", () => {
|
||||||
let tests = globSync(BLOB_TO_KZG_COMMITMENT_TESTS);
|
let tests = globSync(BLOB_TO_KZG_COMMITMENT_TESTS);
|
||||||
|
expect(tests.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
tests.forEach((testFile: string) => {
|
tests.forEach((testFile: string) => {
|
||||||
const test: BlobToKzgCommitmentTest = yaml.load(
|
const test: BlobToKzgCommitmentTest = yaml.load(
|
||||||
readFileSync(testFile, "ascii"),
|
readFileSync(testFile, "ascii"),
|
||||||
|
@ -133,6 +135,8 @@ describe("C-KZG", () => {
|
||||||
|
|
||||||
it("reference tests for computeKzgProof should pass", () => {
|
it("reference tests for computeKzgProof should pass", () => {
|
||||||
let tests = globSync(COMPUTE_KZG_PROOF_TESTS);
|
let tests = globSync(COMPUTE_KZG_PROOF_TESTS);
|
||||||
|
expect(tests.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
tests.forEach((testFile: string) => {
|
tests.forEach((testFile: string) => {
|
||||||
const test: ComputeKzgProofTest = yaml.load(
|
const test: ComputeKzgProofTest = yaml.load(
|
||||||
readFileSync(testFile, "ascii"),
|
readFileSync(testFile, "ascii"),
|
||||||
|
@ -156,6 +160,8 @@ describe("C-KZG", () => {
|
||||||
|
|
||||||
it("reference tests for computeBlobKzgProof should pass", () => {
|
it("reference tests for computeBlobKzgProof should pass", () => {
|
||||||
let tests = globSync(COMPUTE_BLOB_KZG_PROOF_TESTS);
|
let tests = globSync(COMPUTE_BLOB_KZG_PROOF_TESTS);
|
||||||
|
expect(tests.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
tests.forEach((testFile: string) => {
|
tests.forEach((testFile: string) => {
|
||||||
const test: ComputeBlobKzgProofTest = yaml.load(
|
const test: ComputeBlobKzgProofTest = yaml.load(
|
||||||
readFileSync(testFile, "ascii"),
|
readFileSync(testFile, "ascii"),
|
||||||
|
@ -180,6 +186,8 @@ describe("C-KZG", () => {
|
||||||
|
|
||||||
it("reference tests for verifyKzgProof should pass", () => {
|
it("reference tests for verifyKzgProof should pass", () => {
|
||||||
let tests = globSync(VERIFY_KZG_PROOF_TESTS);
|
let tests = globSync(VERIFY_KZG_PROOF_TESTS);
|
||||||
|
expect(tests.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
tests.forEach((testFile: string) => {
|
tests.forEach((testFile: string) => {
|
||||||
const test: VerifyKzgProofTest = yaml.load(
|
const test: VerifyKzgProofTest = yaml.load(
|
||||||
readFileSync(testFile, "ascii"),
|
readFileSync(testFile, "ascii"),
|
||||||
|
@ -204,6 +212,8 @@ describe("C-KZG", () => {
|
||||||
|
|
||||||
it("reference tests for verifyBlobKzgProof should pass", () => {
|
it("reference tests for verifyBlobKzgProof should pass", () => {
|
||||||
let tests = globSync(VERIFY_BLOB_KZG_PROOF_TESTS);
|
let tests = globSync(VERIFY_BLOB_KZG_PROOF_TESTS);
|
||||||
|
expect(tests.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
tests.forEach((testFile: string) => {
|
tests.forEach((testFile: string) => {
|
||||||
const test: VerifyBlobKzgProofTest = yaml.load(
|
const test: VerifyBlobKzgProofTest = yaml.load(
|
||||||
readFileSync(testFile, "ascii"),
|
readFileSync(testFile, "ascii"),
|
||||||
|
@ -227,6 +237,8 @@ describe("C-KZG", () => {
|
||||||
|
|
||||||
it("reference tests for verifyBlobKzgProofBatch should pass", () => {
|
it("reference tests for verifyBlobKzgProofBatch should pass", () => {
|
||||||
let tests = globSync(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS);
|
let tests = globSync(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS);
|
||||||
|
expect(tests.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
tests.forEach((testFile: string) => {
|
tests.forEach((testFile: string) => {
|
||||||
const test: VerifyBatchKzgProofTest = yaml.load(
|
const test: VerifyBatchKzgProofTest = yaml.load(
|
||||||
readFileSync(testFile, "ascii"),
|
readFileSync(testFile, "ascii"),
|
||||||
|
|
|
@ -14,6 +14,7 @@ VERIFY_KZG_PROOF_TESTS = "../../tests/verify_kzg_proof/*/*/data.yaml"
|
||||||
VERIFY_BLOB_KZG_PROOF_TESTS = "../../tests/verify_blob_kzg_proof/*/*/data.yaml"
|
VERIFY_BLOB_KZG_PROOF_TESTS = "../../tests/verify_blob_kzg_proof/*/*/data.yaml"
|
||||||
VERIFY_BLOB_KZG_PROOF_BATCH_TESTS = "../../tests/verify_blob_kzg_proof_batch/*/*/data.yaml"
|
VERIFY_BLOB_KZG_PROOF_BATCH_TESTS = "../../tests/verify_blob_kzg_proof_batch/*/*/data.yaml"
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Helper Functions
|
# Helper Functions
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -21,12 +22,16 @@ VERIFY_BLOB_KZG_PROOF_BATCH_TESTS = "../../tests/verify_blob_kzg_proof_batch/*/*
|
||||||
def bytes_from_hex(hexstring):
|
def bytes_from_hex(hexstring):
|
||||||
return bytes.fromhex(hexstring.replace("0x", ""))
|
return bytes.fromhex(hexstring.replace("0x", ""))
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Tests
|
# Tests
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
def test_blob_to_kzg_commitment(ts):
|
def test_blob_to_kzg_commitment(ts):
|
||||||
for test_file in glob.glob(BLOB_TO_KZG_COMMITMENT_TESTS):
|
test_files = glob.glob(BLOB_TO_KZG_COMMITMENT_TESTS)
|
||||||
|
assert len(test_files) > 0
|
||||||
|
|
||||||
|
for test_file in test_files:
|
||||||
with open(test_file, "r") as f:
|
with open(test_file, "r") as f:
|
||||||
test = yaml.safe_load(f)
|
test = yaml.safe_load(f)
|
||||||
|
|
||||||
|
@ -43,7 +48,10 @@ def test_blob_to_kzg_commitment(ts):
|
||||||
|
|
||||||
|
|
||||||
def test_compute_kzg_proof(ts):
|
def test_compute_kzg_proof(ts):
|
||||||
for test_file in glob.glob(COMPUTE_KZG_PROOF_TESTS):
|
test_files = glob.glob(COMPUTE_KZG_PROOF_TESTS)
|
||||||
|
assert len(test_files) > 0
|
||||||
|
|
||||||
|
for test_file in test_files:
|
||||||
with open(test_file, "r") as f:
|
with open(test_file, "r") as f:
|
||||||
test = yaml.safe_load(f)
|
test = yaml.safe_load(f)
|
||||||
|
|
||||||
|
@ -64,7 +72,10 @@ def test_compute_kzg_proof(ts):
|
||||||
|
|
||||||
|
|
||||||
def test_compute_blob_kzg_proof(ts):
|
def test_compute_blob_kzg_proof(ts):
|
||||||
for test_file in glob.glob(COMPUTE_BLOB_KZG_PROOF_TESTS):
|
test_files = glob.glob(COMPUTE_BLOB_KZG_PROOF_TESTS)
|
||||||
|
assert len(test_files) > 0
|
||||||
|
|
||||||
|
for test_file in test_files:
|
||||||
with open(test_file, "r") as f:
|
with open(test_file, "r") as f:
|
||||||
test = yaml.safe_load(f)
|
test = yaml.safe_load(f)
|
||||||
|
|
||||||
|
@ -82,7 +93,10 @@ def test_compute_blob_kzg_proof(ts):
|
||||||
|
|
||||||
|
|
||||||
def test_verify_kzg_proof(ts):
|
def test_verify_kzg_proof(ts):
|
||||||
for test_file in glob.glob(VERIFY_KZG_PROOF_TESTS):
|
test_files = glob.glob(VERIFY_KZG_PROOF_TESTS)
|
||||||
|
assert len(test_files) > 0
|
||||||
|
|
||||||
|
for test_file in test_files:
|
||||||
with open(test_file, "r") as f:
|
with open(test_file, "r") as f:
|
||||||
test = yaml.safe_load(f)
|
test = yaml.safe_load(f)
|
||||||
|
|
||||||
|
@ -102,7 +116,10 @@ def test_verify_kzg_proof(ts):
|
||||||
|
|
||||||
|
|
||||||
def test_verify_blob_kzg_proof(ts):
|
def test_verify_blob_kzg_proof(ts):
|
||||||
for test_file in glob.glob(VERIFY_BLOB_KZG_PROOF_TESTS):
|
test_files = glob.glob(VERIFY_BLOB_KZG_PROOF_TESTS)
|
||||||
|
assert len(test_files) > 0
|
||||||
|
|
||||||
|
for test_file in test_files:
|
||||||
with open(test_file, "r") as f:
|
with open(test_file, "r") as f:
|
||||||
test = yaml.safe_load(f)
|
test = yaml.safe_load(f)
|
||||||
|
|
||||||
|
@ -121,7 +138,10 @@ def test_verify_blob_kzg_proof(ts):
|
||||||
|
|
||||||
|
|
||||||
def test_verify_blob_kzg_proof_batch(ts):
|
def test_verify_blob_kzg_proof_batch(ts):
|
||||||
for test_file in glob.glob(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS):
|
test_files = glob.glob(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS)
|
||||||
|
assert len(test_files) > 0
|
||||||
|
|
||||||
|
for test_file in test_files:
|
||||||
with open(test_file, "r") as f:
|
with open(test_file, "r") as f:
|
||||||
test = yaml.safe_load(f)
|
test = yaml.safe_load(f)
|
||||||
|
|
||||||
|
|
|
@ -493,9 +493,14 @@ mod tests {
|
||||||
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
||||||
assert!(trusted_setup_file.exists());
|
assert!(trusted_setup_file.exists());
|
||||||
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
||||||
|
let test_files: Vec<PathBuf> = glob::glob(BLOB_TO_KZG_COMMITMENT_TESTS)
|
||||||
|
.unwrap()
|
||||||
|
.map(Result::unwrap)
|
||||||
|
.collect();
|
||||||
|
assert!(!test_files.is_empty());
|
||||||
|
|
||||||
for test_file in glob::glob(BLOB_TO_KZG_COMMITMENT_TESTS).unwrap() {
|
for test_file in test_files {
|
||||||
let yaml_data = fs::read_to_string(test_file.unwrap()).unwrap();
|
let yaml_data = fs::read_to_string(test_file).unwrap();
|
||||||
let test: blob_to_kzg_commitment_test::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
let test: blob_to_kzg_commitment_test::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
||||||
let Ok(blob) = test.input.get_blob() else {
|
let Ok(blob) = test.input.get_blob() else {
|
||||||
assert!(test.get_output().is_none());
|
assert!(test.get_output().is_none());
|
||||||
|
@ -515,9 +520,14 @@ mod tests {
|
||||||
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
||||||
assert!(trusted_setup_file.exists());
|
assert!(trusted_setup_file.exists());
|
||||||
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
||||||
|
let test_files: Vec<PathBuf> = glob::glob(COMPUTE_KZG_PROOF_TESTS)
|
||||||
|
.unwrap()
|
||||||
|
.map(Result::unwrap)
|
||||||
|
.collect();
|
||||||
|
assert!(!test_files.is_empty());
|
||||||
|
|
||||||
for test_file in glob::glob(COMPUTE_KZG_PROOF_TESTS).unwrap() {
|
for test_file in test_files {
|
||||||
let yaml_data = fs::read_to_string(test_file.unwrap()).unwrap();
|
let yaml_data = fs::read_to_string(test_file).unwrap();
|
||||||
let test: compute_kzg_proof::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
let test: compute_kzg_proof::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
||||||
let (Ok(blob), Ok(z)) = (test.input.get_blob(), test.input.get_z()) else {
|
let (Ok(blob), Ok(z)) = (test.input.get_blob(), test.input.get_z()) else {
|
||||||
assert!(test.get_output().is_none());
|
assert!(test.get_output().is_none());
|
||||||
|
@ -540,9 +550,14 @@ mod tests {
|
||||||
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
||||||
assert!(trusted_setup_file.exists());
|
assert!(trusted_setup_file.exists());
|
||||||
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
||||||
|
let test_files: Vec<PathBuf> = glob::glob(COMPUTE_BLOB_KZG_PROOF_TESTS)
|
||||||
|
.unwrap()
|
||||||
|
.map(Result::unwrap)
|
||||||
|
.collect();
|
||||||
|
assert!(!test_files.is_empty());
|
||||||
|
|
||||||
for test_file in glob::glob(COMPUTE_BLOB_KZG_PROOF_TESTS).unwrap() {
|
for test_file in test_files {
|
||||||
let yaml_data = fs::read_to_string(test_file.unwrap()).unwrap();
|
let yaml_data = fs::read_to_string(test_file).unwrap();
|
||||||
let test: compute_blob_kzg_proof::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
let test: compute_blob_kzg_proof::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
||||||
let (Ok(blob), Ok(commitment)) = (
|
let (Ok(blob), Ok(commitment)) = (
|
||||||
test.input.get_blob(),
|
test.input.get_blob(),
|
||||||
|
@ -565,9 +580,14 @@ mod tests {
|
||||||
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
||||||
assert!(trusted_setup_file.exists());
|
assert!(trusted_setup_file.exists());
|
||||||
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
||||||
|
let test_files: Vec<PathBuf> = glob::glob(VERIFY_KZG_PROOF_TESTS)
|
||||||
|
.unwrap()
|
||||||
|
.map(Result::unwrap)
|
||||||
|
.collect();
|
||||||
|
assert!(!test_files.is_empty());
|
||||||
|
|
||||||
for test_file in glob::glob(VERIFY_KZG_PROOF_TESTS).unwrap() {
|
for test_file in test_files {
|
||||||
let yaml_data = fs::read_to_string(test_file.unwrap()).unwrap();
|
let yaml_data = fs::read_to_string(test_file).unwrap();
|
||||||
let test: verify_kzg_proof::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
let test: verify_kzg_proof::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
||||||
let (Ok(commitment), Ok(z), Ok(y), Ok(proof)) = (
|
let (Ok(commitment), Ok(z), Ok(y), Ok(proof)) = (
|
||||||
test.input.get_commitment(),
|
test.input.get_commitment(),
|
||||||
|
@ -592,9 +612,14 @@ mod tests {
|
||||||
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
||||||
assert!(trusted_setup_file.exists());
|
assert!(trusted_setup_file.exists());
|
||||||
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
||||||
|
let test_files: Vec<PathBuf> = glob::glob(VERIFY_BLOB_KZG_PROOF_TESTS)
|
||||||
|
.unwrap()
|
||||||
|
.map(Result::unwrap)
|
||||||
|
.collect();
|
||||||
|
assert!(!test_files.is_empty());
|
||||||
|
|
||||||
for test_file in glob::glob(VERIFY_BLOB_KZG_PROOF_TESTS).unwrap() {
|
for test_file in test_files {
|
||||||
let yaml_data = fs::read_to_string(test_file.unwrap()).unwrap();
|
let yaml_data = fs::read_to_string(test_file).unwrap();
|
||||||
let test: verify_blob_kzg_proof::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
let test: verify_blob_kzg_proof::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
||||||
let (Ok(blob), Ok(commitment), Ok(proof)) = (
|
let (Ok(blob), Ok(commitment), Ok(proof)) = (
|
||||||
test.input.get_blob(),
|
test.input.get_blob(),
|
||||||
|
@ -618,9 +643,14 @@ mod tests {
|
||||||
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
let trusted_setup_file = PathBuf::from("../../src/trusted_setup.txt");
|
||||||
assert!(trusted_setup_file.exists());
|
assert!(trusted_setup_file.exists());
|
||||||
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
|
||||||
|
let test_files: Vec<PathBuf> = glob::glob(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS)
|
||||||
|
.unwrap()
|
||||||
|
.map(Result::unwrap)
|
||||||
|
.collect();
|
||||||
|
assert!(!test_files.is_empty());
|
||||||
|
|
||||||
for test_file in glob::glob(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS).unwrap() {
|
for test_file in test_files {
|
||||||
let yaml_data = fs::read_to_string(test_file.unwrap()).unwrap();
|
let yaml_data = fs::read_to_string(test_file).unwrap();
|
||||||
let test: verify_blob_kzg_proof_batch::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
let test: verify_blob_kzg_proof_batch::Test = serde_yaml::from_str(&yaml_data).unwrap();
|
||||||
let (Ok(blobs), Ok(commitments), Ok(proofs)) = (
|
let (Ok(blobs), Ok(commitments), Ok(proofs)) = (
|
||||||
test.input.get_blobs(),
|
test.input.get_blobs(),
|
||||||
|
|
Loading…
Reference in New Issue