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

Migrate TickBitmap tests from HardHat to Foundry #320

Merged
merged 23 commits into from
Aug 7, 2023

Conversation

gitcoindev
Copy link
Contributor

Related Issue

This pull request migrates TickBitmap tests from HardHat to Foundry (35 test cases), a part of #315 .

Description of changes

  • migrated 35 TickBitmap tests to Foundry
  • removed HardHat implementation after migration
Running 35 tests for test/foundry-tests/TickBitmap.t.sol:TickBitmapTestTest
[PASS] test_flipTick_flipsOnlyTheSpecifiedTick() (gas: 37394)
[PASS] test_flipTick_gasCostOfFlippingATickThatResultsInDeletingAWord() (gas: 19391)
[PASS] test_flipTick_gasCostOfFlippingFirstTickInWordToInitialized() (gas: 28230)
[PASS] test_flipTick_gasCostOfFlippingSecondTickInWordToInitialized() (gas: 29492)
[PASS] test_flipTick_revertsOnlyItself() (gas: 83555)
[PASS] test_isInitialized_isFalseAtFirst() (gas: 8323)
[PASS] test_isInitialized_isFlippedBackByFlapTick() (gas: 20466)
[PASS] test_isInitialized_isFlippedByFlapTick() (gas: 29793)
[PASS] test_isInitialized_isNotChangedByAnotherFlipToADifferentTick() (gas: 29549)
[PASS] test_isInitialized_isNotChangedByAnotherFlipToADifferentTickOnAnotherWord() (gas: 33421)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_doesNotExceedBoundary() (gas: 65229)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_gasCostForEntireWord() (gas: 65074)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_gasCostJustBelowBoundary() (gas: 63073)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_gasCostOnBoundary() (gas: 65074)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_returnsTheNextInitializedTickFromTheNextWord() (gas: 86853)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_returnsTheNextWordsInitializedTickIfOnTheRightBoundary() (gas: 65242)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_returnsTheNextWordsInitializedTickIfOnTheRightBoundary2() (gas: 63663)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_returnsTheTickDirectlyToTheRight() (gas: 63610)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_returnsTheTickDirectlyToTheRight2() (gas: 63700)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_returnsTickToRightIfAtInitializedTick() (gas: 63641)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_returnsTickToRightIfAtInitializedTick2() (gas: 63681)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_skipsEntireWord() (gas: 65240)
[PASS] test_nextInitializedTickWithinOneWord_lteFalse_skipsHalfWord() (gas: 65208)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_atTheWordBoundary() (gas: 65226)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_boundaryIsInitialized() (gas: 86703)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_entireEmptyWord() (gas: 65203)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_gasCostForEntireWord() (gas: 65081)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_gasCostJustBelowBoundary() (gas: 63379)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_gasCostOnBoundary() (gas: 65070)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_halfwayThroughEmptyWord() (gas: 65214)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_returnsSameTickIfInitialized() (gas: 63512)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_returnsTickDirectlyToTheLeftOfInputTickIfNotInitialized() (gas: 63503)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_willNotExceedTheWordBoundary() (gas: 65216)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_wordBoundary() (gas: 65256)
[PASS] test_nextInitializedTickWithinOneWord_lteTrue_wordBoundaryLess1nextInitializedTickInNextWord() (gas: 63506)
Test result: ok. 35 passed; 0 failed; finished in 7.48ms

Copy link
Contributor

@nagrarohit nagrarohit left a comment

Choose a reason for hiding this comment

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

  • function test_isInitialized_isFlippedByFlapTick()**
  • function test_isInitialized_isFlippedBackByFlapTick()**
  • I think the name should be Flip instead of Flap.

@gitcoindev
Copy link
Contributor Author

  • function test_isInitialized_isFlippedByFlapTick()**
  • function test_isInitialized_isFlippedBackByFlapTick()**
  • I think the name should be Flip instead of Flap.

good catch!

@gitcoindev gitcoindev force-pushed the feature/migrate_TickBitmap_toFoundry branch from b9fbe79 to 287ffd8 Compare July 30, 2023 19:14
@gitcoindev
Copy link
Contributor Author

gitcoindev commented Jul 30, 2023

@ewilz I fixed typos and refactored tests to use forge-gas-snapshot, PR is ready for the review.

@gitcoindev
Copy link
Contributor Author

The PR needs the same changes as #317 , in progress...

@gitcoindev
Copy link
Contributor Author

Hi @ewilz this PR is ready for another review round

@gitcoindev gitcoindev force-pushed the feature/migrate_TickBitmap_toFoundry branch from 726eba1 to 11beab3 Compare July 31, 2023 21:48
Copy link
Contributor

@nagrarohit nagrarohit left a comment

Choose a reason for hiding this comment

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

LGTM. But i missed the following comments :-
// #isInitialized
// #flipTick
// #nextInitializedTickWithinOneWord

@ewilz
Copy link
Member

ewilz commented Aug 7, 2023

hardhat snapshots need to be deleted

@ewilz
Copy link
Member

ewilz commented Aug 7, 2023

Can delete TickBitmapTest.sol and rename foundry test TickBitmapTest hence getting rid of the extra "Test" on there

@ewilz
Copy link
Member

ewilz commented Aug 7, 2023

test migration looks good, not sure if you've ever written forge fuzz tests, with the recently committed FullMath conversion for instance, we took the echidna fuzz tests and converted them to forge fuzz tests, need to convert checkNextInitializedTickWithinOneWordInvariants Happy to merge without that though and just do it later..

@gitcoindev
Copy link
Contributor Author

Hi @ewilz thank you for the review, I already pushed changes. I can have a look at fuzzing later this week after merging.

@gitcoindev gitcoindev requested a review from ewilz August 7, 2023 20:29
@ewilz
Copy link
Member

ewilz commented Aug 7, 2023

woops sorry didn't think I had write access to your branch

@ewilz ewilz merged commit 3b72450 into Uniswap:main Aug 7, 2023
3 checks passed
@gitcoindev
Copy link
Contributor Author

Yes I enabled write access, thanks for merging!

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