@@ -330,7 +330,8 @@ test (`test_circom_e2e.sh`) hard-codes as Poseidon inputs.
330330
331331private def max128 : Nat := (2 ^ 128 ) - 1
332332
333- -- Test: transfer(to=0xdead, amount=1000) → templateIdx=1 (else branch), holes=[1000, 0, 57005]
333+ -- Test: transfer(to=0xdead, amount=1000) → templateIdx=1 (else branch), holes=[57005, 1000, 0]
334+ -- Hole order: dedup first-occurrence of [ to ] ++ [amount, to] = [to, amount] → [to, amount_lo, amount_hi]
334335#eval do
335336 let spec := erc20IntentSpec
336337 match getBinding spec 0 with
@@ -343,13 +344,14 @@ private def max128 : Nat := (2 ^ 128) - 1
343344 | some co =>
344345 unless co.templateIdx == 1 do
345346 throw (IO.userError s! "expected templateIdx=1, got { co.templateIdx} " )
346- unless co.holeValues == [1000 , 0 , 57005 ] do
347- throw (IO.userError s! "expected holeValues=[1000, 0, 57005 ], got { repr co.holeValues} " )
347+ unless co.holeValues == [57005 , 1000 , 0 ] do
348+ throw (IO.userError s! "expected holeValues=[57005, 1000, 0 ], got { repr co.holeValues} " )
348349 IO.println s! "✓ Circuit output: transfer(1000) → templateIdx={ co.templateIdx} , holes={ repr co.holeValues} "
349350 | none => throw (IO.userError "evalIntentCircuitOutput returned none" )
350351 | none => throw (IO.userError "binding not found" )
351352
352- -- Test: transfer(to=0xdead, amount=MAX) → templateIdx=0 (then branch), holes=[max128, max128, 57005]
353+ -- Test: transfer(to=0xdead, amount=MAX) → templateIdx=0 (then branch), holes=[57005, max128, max128]
354+ -- Hole order: [to, amount_lo, amount_hi]
353355#eval do
354356 let spec := erc20IntentSpec
355357 match getBinding spec 0 with
@@ -362,8 +364,8 @@ private def max128 : Nat := (2 ^ 128) - 1
362364 | some co =>
363365 unless co.templateIdx == 0 do
364366 throw (IO.userError s! "expected templateIdx=0, got { co.templateIdx} " )
365- unless co.holeValues == [max128 , max128, 57005 ] do
366- throw (IO.userError s! "expected holeValues=[max128 , max128, 57005 ], got { repr co.holeValues} " )
367+ unless co.holeValues == [57005 , max128, max128 ] do
368+ throw (IO.userError s! "expected holeValues=[57005 , max128, max128 ], got { repr co.holeValues} " )
367369 IO.println s! "✓ Circuit output: transfer(MAX) → templateIdx={ co.templateIdx} , holes match"
368370 | none => throw (IO.userError "evalIntentCircuitOutput returned none" )
369371 | none => throw (IO.userError "binding not found" )
@@ -388,9 +390,9 @@ private def max128 : Nat := (2 ^ 128) - 1
388390 | none => throw (IO.userError "binding not found" )
389391
390392-- Test: transferFrom(fromAddr=0xcafe, to=0xdead, amount=2000)
391- -- → templateIdx=1 (else branch), holes=[2000, 0, 51966, 57005 ]
392- -- Hole order: dedup of [fromAddr, to] ++ [amount, fromAddr, to] = [amount, fromAddr, to]
393- -- Values: amount_lo=2000, amount_hi=0, fromAddr=0xcafe=51966, to=0xdead=57005
393+ -- → templateIdx=1 (else branch), holes=[51966, 57005, 2000, 0 ]
394+ -- Hole order: dedup first-occurrence of [fromAddr, to] ++ [amount, fromAddr, to] = [fromAddr, to, amount ]
395+ -- Values: fromAddr=0xcafe=51966, to=0xdead=57005, amount_lo=2000, amount_hi=0
394396#eval do
395397 let spec := erc20IntentSpec
396398 match getBinding spec 2 with
@@ -404,14 +406,15 @@ private def max128 : Nat := (2 ^ 128) - 1
404406 | some co =>
405407 unless co.templateIdx == 1 do
406408 throw (IO.userError s! "expected templateIdx=1, got { co.templateIdx} " )
407- unless co.holeValues == [2000 , 0 , 51966 , 57005 ] do
408- throw (IO.userError s! "expected holeValues=[2000, 0, 51966, 57005 ], got { repr co.holeValues} " )
409+ unless co.holeValues == [51966 , 57005 , 2000 , 0 ] do
410+ throw (IO.userError s! "expected holeValues=[51966, 57005, 2000, 0 ], got { repr co.holeValues} " )
409411 IO.println s! "✓ Circuit output: transferFrom(2000) → templateIdx={ co.templateIdx} , holes={ repr co.holeValues} "
410412 | none => throw (IO.userError "evalIntentCircuitOutput returned none" )
411413 | none => throw (IO.userError "binding not found" )
412414
413415-- Test: transferFrom(fromAddr=0xcafe, to=0xdead, amount=MAX)
414- -- → templateIdx=0 (then branch), holes=[max128, max128, 51966, 57005]
416+ -- → templateIdx=0 (then branch), holes=[51966, 57005, max128, max128]
417+ -- Hole order: [fromAddr, to, amount_lo, amount_hi]
415418#eval do
416419 let spec := erc20IntentSpec
417420 match getBinding spec 2 with
@@ -425,8 +428,8 @@ private def max128 : Nat := (2 ^ 128) - 1
425428 | some co =>
426429 unless co.templateIdx == 0 do
427430 throw (IO.userError s! "expected templateIdx=0, got { co.templateIdx} " )
428- unless co.holeValues == [max128, max128, 51966 , 57005 ] do
429- throw (IO.userError s! "expected holeValues=[max128, max128, 51966, 57005 ], got { repr co.holeValues} " )
431+ unless co.holeValues == [51966 , 57005 , max128, max128 ] do
432+ throw (IO.userError s! "expected holeValues=[51966, 57005, max128, max128 ], got { repr co.holeValues} " )
430433 IO.println s! "✓ Circuit output: transferFrom(MAX) → templateIdx={ co.templateIdx} , holes match"
431434 | none => throw (IO.userError "evalIntentCircuitOutput returned none" )
432435 | none => throw (IO.userError "binding not found" )
0 commit comments