Skip to content

Commit 621991d

Browse files
committed
fix test
1 parent 8db98a7 commit 621991d

File tree

2 files changed

+92
-36
lines changed

2 files changed

+92
-36
lines changed

circuits/test/json/extraction.test.ts

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,59 @@ describe("JSON Extraction", () => {
603603
BigInt("3259012130809677133330262640542695849256518265822971433624635410535031074847"), BigInt("1"),
604604
BigInt("0"), BigInt("0"),
605605
];
606-
let states = [state, state2];
606+
let state3 = [BigInt("1"), BigInt("1"),
607+
BigInt("1"), BigInt("1"),
608+
BigInt("1"), BigInt("1"),
609+
BigInt("1"), BigInt("1"),
610+
BigInt("1"), BigInt("1"),
611+
BigInt("2"), BigInt("1"),
612+
BigInt("1"), BigInt("1"),
613+
BigInt("1"), BigInt("1"),
614+
BigInt("1"), BigInt("1"),
615+
BigInt("1"), BigInt("1"),
616+
BigInt("2"), BigInt("2"),
617+
BigInt("1"), BigInt("1"),
618+
BigInt("21114443489864049154001762655191180301122514770016290267650674674192767465697"), BigInt("0"),
619+
BigInt("6831575284631332314047141597015456944409870082618779346385457763507373982298"), BigInt("0"),
620+
BigInt("11807992475950612596410595977851585466077166903715611787715431816169278988645"), BigInt("0"),
621+
BigInt("6780061509483589239421291947946885432473743248352401215903845935894912933796"), BigInt("0"),
622+
BigInt("8399802325731199225013812405787143556786329551153905411468626346744193582661"), BigInt("0"),
623+
BigInt("0"), BigInt("0"),
624+
BigInt("21114443489864049154001762655191180301122514770016290267650674674192767465697"), BigInt("0"),
625+
BigInt("20657103927053063591983067049524250022245139000924954731087186169764759392836"), BigInt("0"),
626+
BigInt("18211997483052406977396736902181255088105290584316186088813516197303012472272"), BigInt("0"),
627+
BigInt("10946756681378220817082917740365178789699667719578097414130696820612396982453"), BigInt("0"),
628+
BigInt("0"), BigInt("0"),
629+
BigInt("1670561198430172148681353801331385832385430133942816907683484425076474887655"), BigInt("16572438045525961943251465619605168041221082178875908327386397278381398802869"),
630+
BigInt("17071743095618934420079457007323118272072062312285404774051893513653887087610"), BigInt("1"),
631+
BigInt("0"), BigInt("0"),];
632+
let state4 = [BigInt("1"), BigInt("1"),
633+
BigInt("1"), BigInt("1"),
634+
BigInt("1"), BigInt("1"),
635+
BigInt("1"), BigInt("1"),
636+
BigInt("1"), BigInt("1"),
637+
BigInt("2"), BigInt("3"),
638+
BigInt("1"), BigInt("0"),
639+
BigInt("0"), BigInt("0"),
640+
BigInt("0"), BigInt("0"),
641+
BigInt("0"), BigInt("0"),
642+
BigInt("0"), BigInt("0"),
643+
BigInt("0"), BigInt("0"),
644+
BigInt("21114443489864049154001762655191180301122514770016290267650674674192767465697"), BigInt("0"),
645+
BigInt("6831575284631332314047141597015456944409870082618779346385457763507373982298"), BigInt("0"),
646+
BigInt("11807992475950612596410595977851585466077166903715611787715431816169278988645"), BigInt("0"),
647+
BigInt("6780061509483589239421291947946885432473743248352401215903845935894912933796"), BigInt("0"),
648+
BigInt("8399802325731199225013812405787143556786329551153905411468626346744193582661"), BigInt("0"),
649+
BigInt("0"), BigInt("0"),
650+
BigInt("21114443489864049154001762655191180301122514770016290267650674674192767465697"), BigInt("0"),
651+
BigInt("0"), BigInt("0"),
652+
BigInt("0"), BigInt("0"),
653+
BigInt("0"), BigInt("0"),
654+
BigInt("0"), BigInt("0"),
655+
BigInt("0"), BigInt("0"),
656+
BigInt("16831674487885313515168509902646763923398513124794098473399128205752230500967"), BigInt("1"),
657+
BigInt("0"), BigInt("0"),];
658+
let states = [state, state2, state3, state4];
607659
let state_digest = PolynomialDigest(state, mock_ct_digest, BigInt(0));
608660
const step_in = [data_digest, 0, 0, 0, 0, 0, 0, 1, state_digest, sequence_digest_hashed, 0];
609661

witness-generator/src/json/parser.rs

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ pub fn parse<const MAX_STACK_HEIGHT: usize>(
153153
let mut ctr = 0;
154154
for char in bytes {
155155
// Update the machine
156-
println!("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
157-
println!("char: {}, ctr: {}", *char as char, ctr);
156+
// println!("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
157+
// println!("char: {}, ctr: {}", *char as char, ctr);
158158
match *char {
159159
START_BRACE => match (machine.clone().status, machine.current_location()) {
160160
(Status::None, Location::None | Location::ObjectValue | Location::ArrayIndex(_)) => {
@@ -274,41 +274,41 @@ pub fn parse<const MAX_STACK_HEIGHT: usize>(
274274
}
275275
machine.write_to_label_stack();
276276
output.push(machine.clone());
277-
let raw_state = RawJsonMachine::from(machine.clone());
278-
let raw_stack = raw_state
279-
.stack
280-
.into_iter()
281-
.map(|f| (BigUint::from_bytes_le(&f.0.to_bytes()), BigUint::from_bytes_le(&f.1.to_bytes())))
282-
.collect::<Vec<(BigUint, BigUint)>>();
283-
let raw_tree_hash = raw_state
284-
.tree_hash
285-
.into_iter()
286-
.map(|f| (BigUint::from_bytes_le(&f.0.to_bytes()), BigUint::from_bytes_le(&f.1.to_bytes())))
287-
.collect::<Vec<(BigUint, BigUint)>>();
277+
// let raw_state = RawJsonMachine::from(machine.clone());
278+
// let raw_stack = raw_state
279+
// .stack
280+
// .into_iter()
281+
// .map(|f| (BigUint::from_bytes_le(&f.0.to_bytes()),
282+
// BigUint::from_bytes_le(&f.1.to_bytes()))) .collect::<Vec<(BigUint, BigUint)>>();
283+
// let raw_tree_hash = raw_state
284+
// .tree_hash
285+
// .into_iter()
286+
// .map(|f| (BigUint::from_bytes_le(&f.0.to_bytes()),
287+
// BigUint::from_bytes_le(&f.1.to_bytes()))) .collect::<Vec<(BigUint, BigUint)>>();
288288
// Debuggin'
289289

290-
for (i, (a, b)) in raw_stack.iter().enumerate() {
291-
println!("state[ {ctr:?} ].stack[{:2} ] = [ {} ][ {} ]", i, a, b);
292-
}
293-
for (i, (a, b)) in raw_tree_hash.iter().enumerate() {
294-
println!("state[ {ctr:?} ].tree_hash[{:2} ] = [ {} ][ {} ]", i, a, b);
295-
}
296-
println!(
297-
"state[ {ctr:?} ].monomial = {:?}",
298-
BigUint::from_bytes_le(&raw_state.monomial.to_bytes())
299-
);
300-
println!(
301-
"state[ {ctr:?} ].parsing_string = {:?}",
302-
BigUint::from_bytes_le(&raw_state.parsing_string.to_bytes())
303-
);
304-
println!(
305-
"state[ {ctr:?} ].parsing_primitive = {:?}",
306-
BigUint::from_bytes_le(&raw_state.parsing_primitive.to_bytes())
307-
);
308-
println!(
309-
"state[ {ctr:?} ].escaped = {:?}",
310-
BigUint::from_bytes_le(&raw_state.escaped.to_bytes())
311-
);
290+
// for (i, (a, b)) in raw_stack.iter().enumerate() {
291+
// println!("state[ {ctr:?} ].stack[{:2} ] = [ {} ][ {} ]", i, a, b);
292+
// }
293+
// for (i, (a, b)) in raw_tree_hash.iter().enumerate() {
294+
// println!("state[ {ctr:?} ].tree_hash[{:2} ] = [ {} ][ {} ]", i, a, b);
295+
// }
296+
// println!(
297+
// "state[ {ctr:?} ].monomial = {:?}",
298+
// BigUint::from_bytes_le(&raw_state.monomial.to_bytes())
299+
// );
300+
// println!(
301+
// "state[ {ctr:?} ].parsing_string = {:?}",
302+
// BigUint::from_bytes_le(&raw_state.parsing_string.to_bytes())
303+
// );
304+
// println!(
305+
// "state[ {ctr:?} ].parsing_primitive = {:?}",
306+
// BigUint::from_bytes_le(&raw_state.parsing_primitive.to_bytes())
307+
// );
308+
// println!(
309+
// "state[ {ctr:?} ].escaped = {:?}",
310+
// BigUint::from_bytes_le(&raw_state.escaped.to_bytes())
311+
// );
312312
ctr += 1;
313313
// dbg!(&RawJsonMachine::from(machine.clone()));
314314
}
@@ -453,6 +453,10 @@ mod tests {
453453
pretty_print(raw_states[1 * 512 - 1].clone());
454454
println!("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
455455
pretty_print(raw_states[2 * 512 - 1].clone());
456+
println!("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
457+
pretty_print(raw_states[3 * 512 - 1].clone());
458+
// println!("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
459+
// pretty_print(raw_states[4 * 512 - 1].clone());
456460

457461
verify_final_state(raw_states.last().unwrap());
458462
}

0 commit comments

Comments
 (0)