Skip to content

test: AMM TXE tests#16458

Merged
benesjan merged 1 commit intonextfrom
08-19-test_amm_noir_tests
Aug 26, 2025
Merged

test: AMM TXE tests#16458
benesjan merged 1 commit intonextfrom
08-19-test_amm_noir_tests

Conversation

@benesjan
Copy link
Copy Markdown
Contributor

@benesjan benesjan commented Aug 19, 2025

Fixes #10289

Just like my other recent PR decided to add TXE tests for AMM.

On using AI here

The only thing I did manually here is to merge a few test cases because they were too long-running as setting up the initial state is costly. I also told it to not have precise ratio in the second call to add_liquidity to test the refund. Other than this AI pretty much managed to nail it.

Update on AI

Code quality was not great and had to redo quite a lot of stuff. That could be improved though if we had a proper reference (plenty of the style issues were present in the rest of our codebase).

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@benesjan benesjan marked this pull request as ready for review August 19, 2025 11:37
@benesjan benesjan changed the title test: AMM Noir tests test: AMM TXE tests Aug 19, 2025
@benesjan benesjan requested review from Thunkar and nventuro August 19, 2025 12:05
Comment thread noir-projects/noir-contracts/contracts/app/amm_contract/src/test.nr Outdated
Comment thread noir-projects/noir-contracts/contracts/app/amm_contract/src/test.nr Outdated
Comment thread noir-projects/noir-contracts/contracts/app/amm_contract/src/test.nr Outdated
Comment thread noir-projects/noir-contracts/contracts/app/amm_contract/src/test.nr Outdated
Comment on lines +113 to +114
// Note: All these tests are quite long-running so I decided to create larger tests (e.g. testing add and remove
// liquidity happy path just in 1 test case)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How long running? Given they run in parallel it's not the end of the world to have long tests, I'm not sure we should take this path so early.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not too bad but it also makes the tests quite boilerplatey. I would say the result is quite ok but can create a separate test case only for adding liquidity if you would prefer.

Comment thread noir-projects/noir-contracts/contracts/app/amm_contract/src/test.nr Outdated
Comment thread noir-projects/noir-contracts/contracts/app/amm_contract/src/test.nr Outdated
Comment thread noir-projects/noir-contracts/contracts/app/amm_contract/src/test.nr Outdated
@benesjan benesjan marked this pull request as draft August 25, 2025 12:43
@benesjan benesjan force-pushed the 08-19-test_amm_noir_tests branch 2 times, most recently from 5aaa202 to ae80a49 Compare August 25, 2025 15:28
@benesjan benesjan marked this pull request as ready for review August 25, 2025 15:28
Copy link
Copy Markdown
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

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

These look much better, thanks. It's still a bit annoying to write these, we'll need to iterate on the style a bit more. Perhaps a struct with scenario config, idk. The fact that we can't return the contract types from functions or put them in structs is very annoying.

Comment on lines +12 to +14
// Note: Ideally this test would be split into 2 separate test cases - one for order creation and one for order
// fulfillment, with the second test running on the state from the first test. Since this feature is not currently
// supported, combining them into a single comprehensive test is the best approach.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you mean by this? What feature?

Copy link
Copy Markdown
Contributor Author

@benesjan benesjan Aug 25, 2025

Choose a reason for hiding this comment

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

I was thinking that it would be cool if you could run test case on state of a previous test case. Since here re-running the add liquidity for the test that would test liquidity removal takes what feels like a lot of resources.

Can nuke the comment if you prefer as I don't care.

Comment thread noir-projects/noir-contracts/contracts/app/amm_contract/src/test/test.nr Outdated
Fixes #10289

Just like my [other recent PR](#16451) decided to add TXE tests for AMM.

## On using AI here
The only thing I did manually here is to merge a few test cases because they were too long-running as setting up the initial state is costly. I also told it to not have precise ratio in the second call to `add_liquidity` to test the refund. Other than this AI pretty much managed to nail it.

### Update on AI
Code quality was not great and had to redo quite a lot of stuff. That could be improved though if we had a proper reference (plenty of the style issues were present in the rest of our codebase).
@AztecBot AztecBot force-pushed the 08-19-test_amm_noir_tests branch from 96e84c8 to 077fdb4 Compare August 26, 2025 07:00
@benesjan benesjan added this pull request to the merge queue Aug 26, 2025
Merged via the queue into next with commit f78e8d1 Aug 26, 2025
15 checks passed
@benesjan benesjan deleted the 08-19-test_amm_noir_tests branch August 26, 2025 07:44
ludamad pushed a commit that referenced this pull request Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write AMM TXE tests

3 participants