Skip to content

Commit

Permalink
fix tests again, arghhhhhhhgstgst
Browse files Browse the repository at this point in the history
  • Loading branch information
lonerapier committed Sep 12, 2024
1 parent 335a756 commit e073ed8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
20 changes: 12 additions & 8 deletions circuits/test/http/codegen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ describe("HTTP :: Codegen :: Request", async () => {
it("(valid) GET:", async () => {
let lockfile = "request.lock";
let inputfile = "get_request.http";
let circuitName = "get_request_test";

// generate extractor circuit using codegen
await executeCodegen("get_request_test", inputfile, `${lockfile}.json`);
await executeCodegen(circuitName, inputfile, `${lockfile}.json`);

const lockData = readLockFile<Request>(`${lockfile}.json`);
console.log("lockData: ", JSON.stringify(lockData));
Expand All @@ -90,7 +91,7 @@ describe("HTTP :: Codegen :: Request", async () => {


circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${lockfile}`,
file: `main/http_${circuitName}`,
template: "LockHTTPRequest",
params: params,
});
Expand All @@ -114,9 +115,10 @@ describe("HTTP :: Codegen :: Request", async () => {
it("(invalid) GET:", async () => {
let lockfile = "request.lock";
let inputfile = "get_request.http";
let circuitName = "get_request_test";

// generate extractor circuit using codegen
await executeCodegen("get_request_test", inputfile, `${lockfile}.json`);
await executeCodegen(circuitName, inputfile, `${lockfile}.json`);

const lockData = readLockFile<Request>(`${lockfile}.json`);

Expand All @@ -131,7 +133,7 @@ describe("HTTP :: Codegen :: Request", async () => {


circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${lockfile}`,
file: `main/http_${circuitName}`,
template: "LockHTTPRequest",
params: params,
});
Expand Down Expand Up @@ -160,9 +162,10 @@ describe("HTTP :: Codegen :: Response", async () => {
it("(valid) GET:", async () => {
let lockfile = "response.lock";
let inputfile = "get_response.http";
let circuitName = "get_response_test";

// generate extractor circuit using codegen
await executeCodegen("get_response_test", inputfile, `${lockfile}.json`);
await executeCodegen(circuitName, inputfile, `${lockfile}.json`);

const lockData = readLockFile<Response>(`${lockfile}.json`);
console.log("lockData: ", JSON.stringify(lockData));
Expand All @@ -180,7 +183,7 @@ describe("HTTP :: Codegen :: Response", async () => {


circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${lockfile}`,
file: `main/http_${circuitName}`,
template: "LockHTTPResponse",
params: params,
});
Expand All @@ -206,9 +209,10 @@ describe("HTTP :: Codegen :: Response", async () => {
it("(invalid) GET:", async () => {
let lockfile = "response.lock";
let inputfile = "get_response.http";
let circuitName = "get_response_test";

// generate extractor circuit using codegen
await executeCodegen("get_response_test", inputfile, `${lockfile}.json`);
await executeCodegen(circuitName, inputfile, `${lockfile}.json`);

const lockData = readLockFile<Response>(`${lockfile}.json`);

Expand All @@ -225,7 +229,7 @@ describe("HTTP :: Codegen :: Response", async () => {


circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${lockfile}`,
file: `main/http_${circuitName}`,
template: "LockHTTPResponse",
params: params,
});
Expand Down
16 changes: 8 additions & 8 deletions circuits/test/json/extractor/extractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("ExtractValue", async () => {
let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["k"]);

circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${filename}`,
file: `main/json_${filename}_test`,
template: "ExtractStringValue",
params: [input.length, 1, 1, 0, 1],
});
Expand All @@ -61,7 +61,7 @@ describe("ExtractValue", async () => {
let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["key2"]);

circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${filename}`,
file: `main/json_${filename}_test`,
template: "ExtractStringValue",
params: [input.length, 1, 4, 0, 3],
});
Expand All @@ -76,7 +76,7 @@ describe("ExtractValue", async () => {
let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["k"]);

circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${filename}`,
file: `main/json_${filename}_test`,
template: "ExtractNumValue",
params: [input.length, 1, 1, 0, 2],
});
Expand All @@ -96,7 +96,7 @@ describe("ExtractValue", async () => {
let [input, keyUnicode, output] = readJSONInputFile(inputFileName, ["b", i]);

circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${filename}`,
file: `main/json_${filename}_test`,
template: "ExtractStringValue",
params: [input.length, 2, 1, 0, i, 1, output.length],
});
Expand All @@ -116,7 +116,7 @@ describe("ExtractValue", async () => {
let [input, keyUnicode, output] = readJSONInputFile(inputFileName, ["k", i]);

circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${filename}`,
file: `main/json_${filename}_test`,
template: "ExtractNumValue",
params: [input.length, 2, 1, 0, i, 1, output.length],
});
Expand All @@ -135,7 +135,7 @@ describe("ExtractValue", async () => {
let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["a", index_0, index_1]);

circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${filename}`,
file: `main/json_${filename}_test`,
template: "ExtractNumValue",
params: [input.length, 3, 1, 0, index_0, 1, index_1, 2, 1],
});
Expand All @@ -159,7 +159,7 @@ describe("ExtractValueMultiDepth", () => {
let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["e", "e"]);

circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${filename}`,
file: `main/json_${filename}_test`,
template: "ExtractStringValue",
params: [input.length, 3, 1, 0, 1, 1, 1],
});
Expand Down Expand Up @@ -187,7 +187,7 @@ describe("ExtractValueArrayObject", () => {
let [input, keyUnicode, output] = readJSONInputFile(`${filename}.json`, ["a", index_0, "b", index_1]);

circuit = await circomkit.WitnessTester(`Extract`, {
file: `main/${filename}`,
file: `main/json_${filename}_test`,
template: "ExtractNumValue",
params: [input.length, 4, 1, 0, index_0, 1, 1, 2, index_1, 3, 1],
});
Expand Down
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ pub enum Command {
Codegen(ExtractorArgs),
}

#[derive(clap::ValueEnum, Clone, Debug)]
pub enum FileType {
Json,
Http,
}

#[derive(Parser, Debug)]
pub struct ParserWitnessArgs {
#[arg(value_enum)]
Expand Down Expand Up @@ -50,12 +56,6 @@ pub struct ExtractorWitnessArgs {
lockfile: PathBuf,
}

#[derive(clap::ValueEnum, Clone, Debug)]
pub enum FileType {
Json,
Http,
}

#[derive(Parser, Debug)]
pub struct ExtractorArgs {
#[arg(value_enum)]
Expand Down

0 comments on commit e073ed8

Please sign in to comment.