|
1 | 1 | import { expect } from "chai"; |
2 | | -import { getCircomParser, VariableContext } from "../src"; |
| 2 | +import { buildVariableContext, getCircomParser, VariableContext } from "../src"; |
3 | 3 |
|
4 | | -import { CircomFileData, Templates } from "./mocks/types"; |
| 4 | +import { CircomFileData } from "./mocks/types"; |
5 | 5 | import { CircomFilesVisitor } from "./mocks/CircomFilesVisitor"; |
6 | 6 | import { CircomTemplateInputsVisitor } from "./mocks/CircomTemplateInputsVisitor"; |
7 | 7 |
|
@@ -118,17 +118,55 @@ describe("Circom Template Inputs Visitor", () => { |
118 | 118 | expect(visitor.templateInputs.out.dimension).to.deep.equal([]); |
119 | 119 | }); |
120 | 120 |
|
121 | | - it.only("should analyse the ComplexMainComponent.circom circuit", () => { |
| 121 | + it("should analyse the ComplexMainComponent.circom circuit", () => { |
122 | 122 | const data = getData("ComplexMainComponent.circom"); |
123 | 123 |
|
124 | | - // const visitor = new CircomTemplateInputsVisitor( |
125 | | - // "MainComponent.circom", |
126 | | - // data., |
127 | | - // {}, |
128 | | - // ); |
129 | | - // |
130 | | - // visitor.startParse(); |
131 | | - // |
132 | | - // console.log(visitor.errors); |
| 124 | + const visitor = new CircomTemplateInputsVisitor( |
| 125 | + "ComplexMainComponent.circom", |
| 126 | + data.templates[data.mainComponentInfo.templateName!].context, |
| 127 | + buildVariableContext( |
| 128 | + data.templates[data.mainComponentInfo.templateName!].parameters, |
| 129 | + data.mainComponentInfo.parameters, |
| 130 | + ), |
| 131 | + ); |
| 132 | + |
| 133 | + visitor.startParse(); |
| 134 | + |
| 135 | + expect(visitor.errors.length).to.equal(0); |
| 136 | + |
| 137 | + expect(visitor.templateInputs.in1.type).to.equal("input"); |
| 138 | + expect(visitor.templateInputs.in1.dimension).to.deep.equal([]); |
| 139 | + |
| 140 | + expect(visitor.templateInputs.in2.type).to.equal("input"); |
| 141 | + expect(visitor.templateInputs.in2.dimension).to.deep.equal([3, 600]); |
| 142 | + |
| 143 | + expect(visitor.templateInputs.out.type).to.equal("output"); |
| 144 | + expect(visitor.templateInputs.out.dimension).to.deep.equal([]); |
| 145 | + }); |
| 146 | + |
| 147 | + it("should analyse the AnotherMainComponent.circom circuit", () => { |
| 148 | + const data = getData("AnotherMainComponent.circom"); |
| 149 | + |
| 150 | + const visitor = new CircomTemplateInputsVisitor( |
| 151 | + "AnotherMainComponent.circom", |
| 152 | + data.templates[data.mainComponentInfo.templateName!].context, |
| 153 | + buildVariableContext( |
| 154 | + data.templates[data.mainComponentInfo.templateName!].parameters, |
| 155 | + data.mainComponentInfo.parameters, |
| 156 | + ), |
| 157 | + ); |
| 158 | + |
| 159 | + visitor.startParse(); |
| 160 | + |
| 161 | + expect(visitor.errors.length).to.equal(0); |
| 162 | + |
| 163 | + expect(visitor.templateInputs.in1.type).to.equal("input"); |
| 164 | + expect(visitor.templateInputs.in1.dimension).to.deep.equal([]); |
| 165 | + |
| 166 | + expect(visitor.templateInputs.in2.type).to.equal("input"); |
| 167 | + expect(visitor.templateInputs.in2.dimension).to.deep.equal([15, 10]); |
| 168 | + |
| 169 | + expect(visitor.templateInputs.out.type).to.equal("output"); |
| 170 | + expect(visitor.templateInputs.out.dimension).to.deep.equal([]); |
133 | 171 | }); |
134 | 172 | }); |
0 commit comments