Skip to content
This repository was archived by the owner on Jul 10, 2026. It is now read-only.

feat: add noir tests - #359

Merged
0xLeopoldo merged 1 commit into
feat/1155from
feat/1155-nr-tests
Jul 6, 2026
Merged

feat: add noir tests#359
0xLeopoldo merged 1 commit into
feat/1155from
feat/1155-nr-tests

Conversation

@0xLeopoldo

Copy link
Copy Markdown
Contributor

🤖 Linear

Closes AZT-855

Description

nr tests

@linear

linear Bot commented Jul 2, 2026

Copy link
Copy Markdown

AZT-855

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add Noir test suite for MultiToken contract (mint/transfer/burn + auth hook)

🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Add comprehensive Noir tests for MultiToken mint/transfer/burn flows across
 public/private/commitment paths.
• Validate ARC-403 authorization hook behavior, including selector/id integrity and rejection
 reverts.
• Introduce shared test utilities and proxy-based authwit scenarios for on-behalf calls.
Diagram

graph TD
  T["Noir tests"] --> U["test/utils.nr"] --> E["TestEnvironment"] --> M["MultiToken"]
  T --> P["GenericProxy"] --> M
  M --> A["Auth spy"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Table-driven/parameterized tests
  • ➕ Reduces repetition across very similar mint/transfer/burn success and failure cases
  • ➕ Makes it easier to expand coverage across more ids/amounts without new files
  • ➖ Noir test ergonomics may make parameterization less readable than explicit scenarios
  • ➖ Harder to attach focused comments explaining protocol caveats (e.g., ARC-403/public-to-private behavior)
2. Property-based fuzzing for amounts/ids
  • ➕ Better at discovering edge cases around note selection, recursion limits, and overflow/underflow
  • ➕ Can validate invariants (conservation, isolation per id) over many runs
  • ➖ More setup complexity (oracles, determinism) and potentially flaky runs
  • ➖ Harder to assert exact revert strings/embedded overflow expressions

Recommendation: Keep the current explicit, scenario-based tests: they match Aztec/Noir debugging needs (precise revert reasons, explicit authwit/proxy flows, and ARC-403 hook expectations). Consider incremental refactors later to parameterize repeated patterns (especially the on-behalf authwit cases) once the suite stabilizes.

Files changed (20) +2390 / -1

Tests (18) +2388 / -1
test.nrRegister MultiToken test modules +16/-0

Register MultiToken test modules

• Introduces the root test module file that wires in all scenario test modules plus a shared 'utils' module.

src/multitoken_contract/src/test.nr

authorization.nrAdd ARC-403 authorization hook tests (called, not called, and rejection) +419/-0

Add ARC-403 authorization hook tests (called, not called, and rejection)

• Adds tests asserting the authorization hook fires for relevant transfer/burn operations, does not fire for mint/commitment initialization, and causes reverts when the spy contract rejects operations. Also validates selector/from_public correctness and id integrity.

src/multitoken_contract/src/test/authorization.nr

balance_of.nrAdd balance_of view/utility tests for default and per-id behavior +81/-0

Add balance_of view/utility tests for default and per-id behavior

• Adds tests for default zero balances and validates that private balance summation only includes notes for the requested token id.

src/multitoken_contract/src/test/balance_of.nr

burn_private.nrAdd burn_private tests including proxy/authwit paths and failure modes +128/-0

Add burn_private tests including proxy/authwit paths and failure modes

• Covers burning from private balance (self and on-behalf via GenericProxy + private authwit), validates balance reductions, and asserts correct failures for over-burn and missing/incorrect authwits.

src/multitoken_contract/src/test/burn_private.nr

burn_public.nrAdd burn_public tests including authwit and underflow failure behavior +90/-0

Add burn_public tests including authwit and underflow failure behavior

• Covers successful public burns, on-behalf burns with public authwits, and expected reverts for underflow and unauthorized callers.

src/multitoken_contract/src/test/burn_public.nr

initialize_transfer_commitment.nrAdd initialize_transfer_commitment behavior tests +51/-0

Add initialize_transfer_commitment behavior tests

• Verifies commitment initialization does not fire the auth hook and demonstrates that token id binding happens at completion (mint_to_commitment) rather than during initialization.

src/multitoken_contract/src/test/initialize_transfer_commitment.nr

mint_to_commitment.nrAdd mint_to_commitment success and revert-path tests +79/-0

Add mint_to_commitment success and revert-path tests

• Covers successful commitment completion, failure as non-minter, invalid/uninitialized commitments, and the allowed id=0 case.

src/multitoken_contract/src/test/mint_to_commitment.nr

mint_to_private.nrAdd mint_to_private tests including id isolation and side effects +84/-0

Add mint_to_private tests including id isolation and side effects

• Covers successful private minting, allowed id=0, non-minter rejection, per-id isolation, and asserts no public balance side effects.

src/multitoken_contract/src/test/mint_to_private.nr

mint_to_public.nrAdd mint_to_public tests including overflow and per-id isolation +72/-0

Add mint_to_public tests including overflow and per-id isolation

• Covers successful public minting, non-minter rejection, explicit overflow behavior on public balances, and per-id isolation guarantees.

src/multitoken_contract/src/test/mint_to_public.nr

main.nrExpose last auth-hook call via view for assertions +9/-1

Expose last auth-hook call via view for assertions

• Adds a public 'get_last_call()' view entrypoint to read the most recent recorded hook invocation, enabling tests to assert selector/from/id/amount and hook variant. Imports the 'view' macro to support the new view method.

src/multitoken_contract/src/test/multitoken_authorization_contract/src/main.nr

transfer_private_to_commitment.nrAdd transfer_private_to_commitment tests including completer constraints +145/-0

Add transfer_private_to_commitment tests including completer constraints

• Covers successful private-to-commitment transfers, on-behalf transfers via proxy/authwit, and failure cases for wrong completer and insufficient balance.

src/multitoken_contract/src/test/transfer_private_to_commitment.nr

transfer_private_to_private.nrAdd transfer_private_to_private tests including recursion and authwit scenarios +353/-0

Add transfer_private_to_private tests including recursion and authwit scenarios

• Covers self and on-behalf private transfers (proxy + authwit), zero-amount behavior, change re-crediting, multi-note recursion behavior, expected failures, per-id isolation, and no public side effects.

src/multitoken_contract/src/test/transfer_private_to_private.nr

transfer_private_to_public.nrAdd transfer_private_to_public tests with proxy/authwit and failure modes +126/-0

Add transfer_private_to_public tests with proxy/authwit and failure modes

• Covers successful private-to-public transfers, on-behalf via proxy/authwit, and expected failures for insufficient private balance and missing authwits.

src/multitoken_contract/src/test/transfer_private_to_public.nr

transfer_public_to_commitment.nrAdd transfer_public_to_commitment tests including invalid commitment and underflow +92/-0

Add transfer_public_to_commitment tests including invalid commitment and underflow

• Covers successful public-to-commitment transfers (public debit then private credit) and expected failures for uninitialized commitments and public balance underflow.

src/multitoken_contract/src/test/transfer_public_to_commitment.nr

transfer_public_to_private.nrAdd transfer_public_to_private tests including proxy/authwit and underflow behavior +127/-0

Add transfer_public_to_private tests including proxy/authwit and underflow behavior

• Covers successful public-to-private transfers, on-behalf via proxy/authwit, and expected failures for public underflow and missing authwits.

src/multitoken_contract/src/test/transfer_public_to_private.nr

transfer_public_to_public.nrAdd transfer_public_to_public tests including authwit and authorization failures +193/-0

Add transfer_public_to_public tests including authwit and authorization failures

• Covers successful public transfers (including self-transfer), on-behalf via public authwit, and expected failures for underflow and unauthorized callers. Also validates per-id isolation for public balances.

src/multitoken_contract/src/test/transfer_public_to_public.nr

utils.nrIntroduce shared test harness utilities for deployment, balances, auth hook, and proxy flows +287/-0

Introduce shared test harness utilities for deployment, balances, auth hook, and proxy flows

• Adds reusable setup/deploy helpers, deterministic private minting via oracle mocking, balance read/assert helpers, and authorization spy assertions via a new 'get_last_call()' view. Includes proxy-based setup helpers to test private authwit validation when msg_sender differs from 'from'.

src/multitoken_contract/src/test/utils.nr

view.nrAdd constructor and view getter tests for stored metadata +36/-0

Add constructor and view getter tests for stored metadata

• Adds tests asserting constructor_with_minter persists name, symbol, minter, and that auth contract defaults to zero when disabled.

src/multitoken_contract/src/test/view.nr

Other (2) +2 / -0
Nargo.tomlAdd GenericProxy dependency for test forwarding scenarios +1/-0

Add GenericProxy dependency for test forwarding scenarios

• Adds a local path dependency on 'generic_proxy' so the test suite can forward private calls through a proxy and exercise authwit validation paths.

src/multitoken_contract/Nargo.toml

main.nrExpose test module from MultiToken crate +1/-0

Expose test module from MultiToken crate

• Adds 'pub mod test;' so the newly-added Noir test modules compile and can reference shared utilities under 'crate::test'.

src/multitoken_contract/src/main.nr

@qodo-code-review

qodo-code-review Bot commented Jul 2, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Qodo Logo

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 20 files

Re-trigger cubic

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Benchmark Comparison

CPU Cores RAM Arch
AMD EPYC 7763 64-Core Processor 16 63 GiB x64

Contract: escrow

🚦 Function Gates DA Gas L2 Gas Proving Time (ms)
Base PR Diff Base PR Diff Base PR Diff Base PR Diff
(partial) withdraw 536,844 536,844 1,312 1,312 495,400 495,400 6,989 6,895 -94 (-1.3%)
withdraw 536,844 536,844 736 736 483,700 483,700 6,997 6,928 -69 (-1.0%)
withdraw_nft 503,323 503,323 736 736 483,700 483,700 6,817 6,749 -68 (-1.0%)

Contract: logic

🚦 Function Gates DA Gas L2 Gas Proving Time (ms)
Base PR Diff Base PR Diff Base PR Diff Base PR Diff
get_escrow 488,339 488,339 128 128 456,000 456,000 6,688 6,622 -66 (-1.0%)
secret_key_to_public_keys 483,417 483,417 128 128 456,000 456,000 6,643 6,592 -51 (-0.8%)
share_escrow 387,745 387,745 704 704 474,500 474,500 5,883 5,797 -86 (-1.5%)

Contract: nft

🚦 Function Gates DA Gas L2 Gas Proving Time (ms)
Base PR Diff Base PR Diff Base PR Diff Base PR Diff
burn_private 422,217 422,217 416 416 661,169 661,169 6,180 6,061 -119 (-1.9%)
burn_public 308,698 308,698 448 448 670,145 670,145 5,242 5,176 -66 (-1.3%)
mint_to_private 439,895 439,895 960 960 652,042 652,042 6,259 6,184 -75 (-1.2%)
mint_to_public 308,698 308,698 448 448 670,790 670,790 5,212 5,166 -46 (-0.9%)
transfer_private_to_private 394,899 394,899 736 736 483,700 483,700 5,896 5,877 -19 (-0.3%)
transfer_private_to_public 422,293 422,293 416 416 659,249 659,249 6,127 6,058 -69 (-1.1%)
transfer_public_to_private 436,536 436,536 960 960 652,459 652,459 6,302 6,198 -104 (-1.7%)
transfer_public_to_public 308,698 308,698 384 384 633,270 633,270 5,196 5,179 -17 (-0.3%)

Contract: token

🚦 Function Gates DA Gas L2 Gas Proving Time (ms)
Base PR Diff Base PR Diff Base PR Diff Base PR Diff
burn_private 451,655 451,655 992 992 683,010 683,010 6,431 6,289 -142 (-2.2%)
burn_public 308,698 308,698 448 448 672,479 672,479 5,287 5,144 -143 (-2.7%)
initialize_transfer_commitment 371,233 371,233 704 704 474,500 474,500 5,779 5,726 -53 (-0.9%)
mint_to_private 440,787 440,787 960 960 652,048 652,048 6,361 6,234 -127 (-2.0%)
mint_to_public 308,698 308,698 448 448 672,077 672,077 5,206 5,167 -39 (-0.7%)
transfer_private_to_commitment 408,890 408,890 896 896 495,400 495,400 5,997 5,960 -37 (-0.6%)
transfer_private_to_private 428,414 428,414 1,312 1,312 495,400 495,400 6,181 6,044 -137 (-2.2%)
transfer_private_to_public 451,804 451,804 992 992 683,154 683,154 6,359 6,284 -75 (-1.2%)
transfer_private_to_public_with_commitment 455,247 455,247 1,568 1,568 716,454 716,454 6,377 6,298 -79 (-1.2%)
transfer_public_to_commitment 308,698 308,698 576 576 662,454 662,454 5,212 5,189 -23 (-0.4%)
transfer_public_to_private 442,082 442,082 960 960 652,435 652,435 6,297 6,256 -41 (-0.7%)
transfer_public_to_public 308,698 308,698 448 448 672,473 672,473 5,270 5,126 -144 (-2.7%)

Contract: vault

🚦 Function Gates DA Gas L2 Gas Proving Time (ms)
Base PR Diff Base PR Diff Base PR Diff Base PR Diff
deposit_private_to_private 861,408 861,408 1,280 1,280 846,950 846,950 9,767 9,692 -75 (-0.8%)
deposit_private_to_private_exact 970,252 970,252 1,856 1,856 883,784 883,784 10,651 10,577 -74 (-0.7%)
deposit_private_to_public 679,000 679,000 768 768 861,772 861,772 8,264 8,125 -139 (-1.7%)
deposit_public_to_private 554,293 554,293 1,344 1,344 889,542 889,542 7,221 7,107 -114 (-1.6%)
deposit_public_to_private_exact 709,509 709,509 1,920 1,920 926,538 926,538 8,473 8,507 +34 (+0.4%)
deposit_public_to_public 308,698 308,698 832 832 905,432 905,432 5,207 5,131 -76 (-1.5%)
issue_private_to_private_exact 970,252 970,252 1,856 1,856 884,441 884,441 10,608 10,554 -54 (-0.5%)
issue_private_to_public_exact 834,152 834,152 1,344 1,344 899,488 899,488 9,521 9,452 -69 (-0.7%)
issue_public_to_private 604,635 604,635 1,344 1,344 898,736 898,736 7,616 7,587 -29 (-0.4%)
issue_public_to_public 308,698 308,698 832 832 906,119 906,119 5,217 5,177 -40 (-0.8%)
redeem_private_to_private_exact 971,471 971,471 1,856 1,856 884,288 884,288 10,721 10,569 -152 (-1.4%)
redeem_private_to_public 678,850 678,850 768 768 862,210 862,210 8,201 8,164 -37 (-0.5%)
redeem_public_to_private_exact 710,879 710,879 1,920 1,920 926,862 926,862 8,516 8,418 -98 (-1.2%)
redeem_public_to_public 308,698 308,698 832 832 905,954 905,954 5,226 5,199 -27 (-0.5%)
withdraw_private_to_private 862,627 862,627 1,280 1,280 847,160 847,160 9,777 9,638 -139 (-1.4%)
withdraw_private_to_private_exact 971,471 971,471 1,856 1,856 884,237 884,237 10,661 10,604 -57 (-0.5%)
withdraw_private_to_public_exact 834,001 834,001 1,344 1,344 899,719 899,719 9,516 9,468 -48 (-0.5%)
withdraw_public_to_private 555,653 555,653 1,344 1,344 889,362 889,362 7,194 7,161 -33 (-0.5%)
withdraw_public_to_public 308,698 308,698 832 832 906,257 906,257 5,225 5,152 -73 (-1.4%)

@0xLeopoldo
0xLeopoldo merged commit f82399f into feat/1155 Jul 6, 2026
6 checks passed
@0xLeopoldo
0xLeopoldo deleted the feat/1155-nr-tests branch July 6, 2026 12:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants