Skip to content

Commit 22a456a

Browse files
committed
fix: include json test vectors in released package.
Instead of opening the file using fs, we go with include_str! macro and vomit the json inside the .rs file. very cool
1 parent 5cfb48e commit 22a456a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/tests/spec/test_vectors.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use bls12_381::G1Projective as G;
2-
use core::str;
32
use hex::FromHex;
43
use json::JsonValue;
54
use std::collections::HashMap;
6-
use std::fs;
75

86
use crate::codec::KeccakByteSchnorrCodec;
97
use crate::fiat_shamir::Nizk;
@@ -27,7 +25,7 @@ struct TestVector {
2725
#[test]
2826
fn test_spec_testvectors() {
2927
let proof_generation_rng_seed = b"proof_generation_seed";
30-
let vectors = extract_vectors_new("src/tests/spec/vectors/testSigmaProtocols.json").unwrap();
28+
let vectors = extract_vectors_new().unwrap();
3129

3230
// Define supported ciphersuites
3331
let mut supported_ciphersuites = HashMap::new();
@@ -110,11 +108,11 @@ fn test_spec_testvectors() {
110108
}
111109
}
112110

113-
fn extract_vectors_new(path: &str) -> Result<HashMap<String, TestVector>, String> {
111+
fn extract_vectors_new() -> Result<HashMap<String, TestVector>, String> {
114112
use std::collections::HashMap;
115113

116-
let content = fs::read_to_string(path).map_err(|e| format!("Unable to read JSON file: {e}"))?;
117-
let root: JsonValue = json::parse(&content).map_err(|e| format!("JSON parsing error: {e}"))?;
114+
let content = include_str!("./vectors/testSigmaProtocols.json");
115+
let root: JsonValue = json::parse(content).map_err(|e| format!("JSON parsing error: {e}"))?;
118116

119117
let mut vectors = HashMap::new();
120118

0 commit comments

Comments
 (0)