Skip to content

Conversation

@cashd
Copy link
Contributor

@cashd cashd commented Mar 22, 2024

Description

Creates a new testing suite called IntegrationTest that generalizes instance setups and deployments. The testing suite is an abstract contract that is implemented in instance test. The implementor overrides two virtual functions and the testing suite properly configures the forked environment. The suite then provides testing coverage for the deployment and initializing steps of the market creation process.

  • test__deployAndInitialize_asShares
  • test__deployAndInitialize_asBase

The testing suite is implemented in StETH, LsETH, rETH, and EzETH instance test. This step is the first in a series to generalize the entire instance testing process. As of now, the generalization has reduced the amount of code by about 1.5k lines 🙌

Review Checklists

Please check each item before approving the pull request. While going
through the checklist, it is recommended to leave comments on items that are
referenced in the checklist to make sure that they are reviewed. If there are
multiple reviewers, copy the checklists into sections titled ## [Reviewer Name].
If the PR doesn't touch Solidity and/or Rust, the corresponding checklist can
be removed.

@jalextowle

Solidity

  • Tokens
    • Do all approve calls use forceApprove?
    • Do all transfer calls use safeTransfer?
    • Do all transferFrom calls use msg.sender as the from address?
      • If not, is the function access restricted to prevent unauthorized
        token spend?
  • Low-level calls (call, delegatecall, staticcall, transfer, send)
    • Is the returned success boolean checked to handle failed calls?
    • If using delegatecall, are there strict access controls on the
      addresses that can be called? It shouldn't be possible to delegatecall
      arbitrary addresses, so the list of possible targets should either be
      immutable or tightly controlled by an admin.
  • Reentrancy
    • Are functions that make external calls or transfer ether marked as nonReentrant?
      • If not, is there documentation that explains why reentrancy is
        not a concern or how it's mitigated?
  • Gas Optimizations
    • Is the logic as simple as possible?
    • Are the storage values that are used repeatedly cached in stack or
      memory variables?
    • If loops are used, are there guards in place to avoid out-of-gas
      issues?
  • Visibility
    • Are all payable functions restricted to avoid stuck ether?
  • Math
    • Is all of the arithmetic checked or guarded by if-statements that will
      catch underflows?
    • If Safe functions are altered, are potential underflows and
      overflows caught so that a failure flag can be thrown?
    • Are all of the rounding directions clearly documented?
  • Testing
    • Are there new or updated unit or integration tests?
    • Do the tests cover the happy paths?
    • Do the tests cover the unhappy paths?
    • Are there an adequate number of fuzz tests to ensure that we are
      covering the full input space?

@cashd cashd force-pushed the cashd/integration-test-suite branch from 3da5a00 to dc139e9 Compare March 22, 2024 18:39
@github-actions
Copy link

github-actions bot commented Mar 22, 2024

Hyperdrive Gas Benchmark

Benchmark suite Current: 80518ad Previous: 46c834d Deviation Status
addLiquidity: min 33915 gas 1546 gas 2093.7257% 🚨
addLiquidity: avg 145503 gas 67936 gas 114.1766% 🚨
addLiquidity: max 405253 gas 293159 gas 38.2366% 🚨
checkpoint: min 29232 gas 1182 gas 2373.0964% 🚨
checkpoint: avg 104064 gas 48477 gas 114.6667% 🚨
checkpoint: max 211255 gas 191559 gas 10.2819% 🚨
closeLong: min 31428 gas 1492 gas 2006.4343% 🚨
closeLong: avg 132980 gas 29374 gas 352.7133% 🚨
closeLong: max 299537 gas 152303 gas 96.6718% 🚨
closeShort: min 31349 gas 1494 gas 1998.3266% 🚨
closeShort: avg 127856 gas 33444 gas 282.2988% 🚨
closeShort: max 201614 gas 149156 gas 35.1699% 🚨
initialize: min 31283 gas 1451 gas 2055.9614% 🚨
initialize: avg 252982 gas 213962 gas 18.2369% 🚨
initialize: max 322173 gas 253953 gas 26.8632% 🚨
openLong: min 33503 gas 1499 gas 2135.0233% 🚨
openLong: avg 167062 gas 51658 gas 223.4001% 🚨
openLong: max 252525 gas 185562 gas 36.0866% 🚨
openShort: min 33848 gas 1520 gas 2126.8421% 🚨
openShort: avg 169615 gas 51482 gas 229.4647% 🚨
openShort: max 363609 gas 181325 gas 100.5289% 🚨
redeemWithdrawalShares: min 31227 gas 1488 gas 1998.5887% 🚨
redeemWithdrawalShares: avg 63504 gas 22375 gas 183.8168% 🚨
redeemWithdrawalShares: max 161900 gas 109301 gas 48.1231% 🚨
removeLiquidity: min 31323 gas 1530 gas 1947.2549% 🚨
removeLiquidity: avg 218420 gas 151225 gas 44.4338% 🚨
removeLiquidity: max 376082 gas 325781 gas 15.4401% 🚨

This comment was automatically generated by workflow using github-action-benchmark.

@cashd cashd marked this pull request as ready for review March 22, 2024 21:09
@cashd cashd requested review from jalextowle and jrhea as code owners March 22, 2024 21:09
@cashd cashd requested a review from sentilesdal March 22, 2024 21:15
Copy link
Contributor

@jalextowle jalextowle left a comment

Choose a reason for hiding this comment

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

Looks great! Nice work @cashd! I just have one more comment about refunds, and then it looks good to go.

@cashd cashd enabled auto-merge (squash) March 26, 2024 19:37
@cashd cashd merged commit 5a15969 into main Mar 26, 2024
@cashd cashd deleted the cashd/integration-test-suite branch March 26, 2024 19:54
dpaiton pushed a commit that referenced this pull request Mar 28, 2024
Creates a new testing suite called IntegrationTest that generalizes instance setups and deployments. The testing suite is an abstract contract that is implemented in instance test. The implementor overrides two virtual functions and the testing suite properly configures the forked environment. The suite then provides testing coverage for the deployment and initializing steps of the market creation process.
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.

4 participants