Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add univ3 svg generation test #1292

Merged
merged 5 commits into from
Jul 25, 2024
Merged

tests: add univ3 svg generation test #1292

merged 5 commits into from
Jul 25, 2024

Conversation

enitrat
Copy link
Collaborator

@enitrat enitrat commented Jul 19, 2024

Time spent on this PR: 1d

Adds Mock UniswapV3 contracts that allow querying a dynamically generated on-chain SVG representing a position.
The values are mocked, and due to some issues, the base64 encoding of the image crashes with a stack underflow error (tbd).

However, the encoding of the rest takes ~27M steps

Also: Because NFTDescriptor is a library with an external function, it must be deployed and called with its address. When referring to this library, the compiler will add a placehold in form __$HASH_OF_PATH$__ in the compiled bytecode. Thus, I implemented a way of linking a library in the deployments scripts - we can deploy the contract providing a set of required libraries, that are deployed, hashed, and their address replaces the hash in the compiled bytecode.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Resolves #

What is the new behavior?


This change is Reviewable

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.90%. Comparing base (f17bd94) to head (80a8a43).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1292      +/-   ##
==========================================
+ Coverage   64.37%   67.90%   +3.53%     
==========================================
  Files          50       46       -4     
  Lines        8541     6868    -1673     
==========================================
- Hits         5498     4664     -834     
+ Misses       3043     2204     -839     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@enitrat enitrat force-pushed the tests/univ3 branch 2 times, most recently from 2d4d48d to 7f4402e Compare July 22, 2024 13:23
@enitrat enitrat marked this pull request as ready for review July 22, 2024 13:30
@enitrat
Copy link
Collaborator Author

enitrat commented Jul 22, 2024

good to merge, can ignore the trunk check

Copy link
Member

@ClementWalter ClementWalter left a comment

Choose a reason for hiding this comment

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

I'd revert the changes made to deploy and use the foundry file to get if there are some

    "linkReferences": {
      "solidity_contracts/src/UniswapV3/NFTDescriptor.sol": {
        "NFTDescriptor": [{ "start": 3038, "length": 20 }]
      }
    }

and if so, then deploy them first, and replace. Even the compute_library_identifier doesn't seem required

@ClementWalter ClementWalter changed the title (wip)tests: add univ3 svg generation test tests: add univ3 svg generation test Jul 23, 2024
@@ -33,7 +33,7 @@ library UniswapV2Library {
hex"ff",
factory,
keccak256(abi.encodePacked(token0, token1)),
hex"666a5b78ea0b660c426b08cb5b7427447e909408067de1a5519c772ee9a3c032" // init code hash
hex"0f5b822a8dffa6ce589a2c240d78a6a2b38a51835a97ceab40c1f301e46ba30b" // init code hash
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

run forge build, open UniswapV2Library.json and take the keccak hash of the bytecode hexstring

@enitrat enitrat merged commit a41fe3b into main Jul 25, 2024
9 checks passed
@enitrat enitrat deleted the tests/univ3 branch July 25, 2024 20:41
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.

3 participants