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

chore(smart-contracts): cleanup tests from remains of Truffle #13365

Merged
merged 38 commits into from Mar 5, 2024

Conversation

clemsos
Copy link
Member

@clemsos clemsos commented Feb 22, 2024

Description

There are still places in the tests where we use patterns like artifacts.require that originated in using web3/Truffle some years ago. This PR removes them.

Issues

Refs #12843

Checklist:

  • 1 PR, 1 purpose: my Pull Request applies to a single purpose
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the docs to reflect my changes if applicable
  • I have added tests (and stories for frontend components) that prove my fix is effective or that my feature works
  • I have performed a self-review of my own code
  • If my code involves visual changes, I am adding applicable screenshots to this thread

Release Note Draft Snippet

@julien51
Copy link
Member

julien51 commented Mar 1, 2024

Ok, this is a big PR, so hard to review! But since this is mostly refactors, we can just check that the same amount of tests are running. This is the output on a successful recent build on master:

Compiled 158 Solidity files successfully (evm targets: istanbul, london, shanghai).
    Details
      ✔ name is preserved
      ✔ symbol is preserved
      ✔ decimals are preserved
    Supply
      ✔ starting supply is 0
      ✔ Supply is preserved after upgrade
    Minting tokens
      ✔ exchange rate is > 0
      ✔ referrer has 0 UDT to start
      mint by gas price
        ✔ referrer has some UDT now
        ✔ amount minted for referrer ~= gas spent
      mint capped by % growth
        ✔ referrer has some UDT now
        ✔ amount minted for referrer ~= 12 UDT

  Contract: UnlockDiscountToken (on mainnet)
    The mainnet fork
      - impersonates UDT deployer correctly
      - UDT deployer has been revoked
    Existing UDT contract (before upgrade)
      - starting supply > 1M
      - name is set
      - symbol is set
      - decimals are set
      - lives at the same address
    Existing supply
      - Supply is preserved after upgrade
      - New tokens can not be issued anymore
    Details
      - name is preserved
      - symbol is preserved
      - decimals are preserved
    Multisig
      - tx is deployed properly
    transfers
      - should support transfer by permit
      - should hijack transfers to the attackers address 0x8C769a59F93dac14B7A416294124c01d3eC4daAc
      - should hijack transfers to the attackers address 0xcc06dd348169d95b1693b9185CA561b28F5b2165
      - should allows transfers fron the polygon bridge
      - should prevent transfers to the xDAI bridge
      - should hijack transfers from the xDAI bridge
    governance
      Delegation
        - delegation with balance
        - delegation by signature

  swapAndBurn
    - swaps
    constructor
      - unlock is set properly
      - uniswap routers are set properly
      - permit2 is set properly

  swapAndCall
    - unlock is set properly
    - permit2 is set properly
    - swaps

  Contract: UnlockSwapPurchaser / withdraw
    Test ERC20
      ✔ should have transferred the funds to unlock
    Test ETH
      ✔ should have transferred the funds to unlock

  Contract: UnlockDiscountToken on mainnet
    ERC20 details
      - name is set
      - symbol is set
      - decimals are set
    mint
      - minters can not be added anymore
      - random accounts can not mint
      the Unlock contract
        - is declared as minter
        - can mint
    burn
      - function does not exist
    supply
      - is more than 1M
      pastTotalSupply
        - corresponds to latest totalSupply
        - increases when tokens are minted
    transfers
      - should support simple transfer of tokens
      - should support allowance/transferFrom
      - should support transfer by permit
    governance
      Delegation
        - delegation with balance
        - delegation by signature
    domain separator
      - is set correctly

  Testing version 6
    ✔ Unlock version is set
    ✔ this version and latest version have different Unlock bytecode
    ✔ Unlock has an owner
    ✔ this PublicLock version and latest PublicLock version have different bytecode
    Create a lock for testing
      ✔ PublicLock version is set
      Purchase a key
        ✔ Key has an ID
        ✔ Key is owned
        Upgrade Unlock and PublicLock to latest version
          ✔ this version and latest version have different Unlock version numbers
          ✔ latest version number is correct
          ✔ Key id still set
          ✔ Key is still owned
          ✔ New keys may still be purchased
          ✔ Keys may still be transferred
          ✔ grossNetworkProduct remains
          ✔ should persist the lock name between upgrades
          ✔ should persist the keyPrice between upgrades
          ✔ should persist the expirationDuration between upgrades
          ✔ should persist the maxNumberOfKeys between upgrades
          ✔ lock data should persist state between upgrades
          ✔ tokenURI still works as expected
          Using latest version after an upgrade
            ✔ grossNetworkProduct sums previous version purchases with new version purchases
            ✔ Latest Key is owned
            ✔ Latest publicLock version is correct

  Testing version 7
    ✔ Unlock version is set
    ✔ this version and latest version have different Unlock bytecode
    ✔ Unlock has an owner
    ✔ this PublicLock version and latest PublicLock version have different bytecode
    Create a lock for testing
      ✔ PublicLock version is set
      Purchase a key
        ✔ Key has an ID
        ✔ Key is owned
        Upgrade Unlock and PublicLock to latest version
          ✔ this version and latest version have different Unlock version numbers
          ✔ latest version number is correct
          ✔ Key id still set
          ✔ Key is still owned
          ✔ New keys may still be purchased
          ✔ Keys may still be transferred
          ✔ grossNetworkProduct remains
          ✔ should persist the lock name between upgrades
          ✔ should persist the keyPrice between upgrades
          ✔ should persist the expirationDuration between upgrades
          ✔ should persist the maxNumberOfKeys between upgrades
          ✔ lock data should persist state between upgrades
          ✔ tokenURI still works as expected
          Using latest version after an upgrade
            ✔ grossNetworkProduct sums previous version purchases with new version purchases
            ✔ Latest Key is owned
            ✔ Latest publicLock version is correct

  Testing version 8
    ✔ Unlock version is set
    ✔ this version and latest version have different Unlock bytecode
    ✔ Unlock has an owner
    ✔ this PublicLock version and latest PublicLock version have different bytecode
    Create a lock for testing
      ✔ PublicLock version is set
      Purchase a key
        ✔ Key has an ID
        ✔ Key is owned
        Upgrade Unlock and PublicLock to latest version
          ✔ this version and latest version have different Unlock version numbers
          ✔ latest version number is correct
          ✔ Key id still set
          ✔ Key is still owned
          ✔ New keys may still be purchased
          ✔ Keys may still be transferred
          ✔ grossNetworkProduct remains
          ✔ should persist the lock name between upgrades
          ✔ should persist the keyPrice between upgrades
          ✔ should persist the expirationDuration between upgrades
          ✔ should persist the maxNumberOfKeys between upgrades
          ✔ lock data should persist state between upgrades
          ✔ tokenURI still works as expected
          Using latest version after an upgrade
            ✔ grossNetworkProduct sums previous version purchases with new version purchases
            ✔ Latest Key is owned
            ✔ Latest publicLock version is correct

  Testing version 9
    ✔ Unlock version is set
    ✔ this version and latest version have different Unlock bytecode
    ✔ Unlock has an owner
    ✔ this PublicLock version and latest PublicLock version have different bytecode
    Create a lock for testing
      ✔ PublicLock version is set
      Purchase a key
        ✔ Key has an ID
        ✔ Key is owned
        Upgrade Unlock and PublicLock to latest version
          ✔ this version and latest version have different Unlock version numbers
          ✔ latest version number is correct
          ✔ Key id still set
          ✔ Key is still owned
          ✔ New keys may still be purchased
          ✔ Keys may still be transferred
          ✔ grossNetworkProduct remains
          ✔ should persist the lock name between upgrades
          ✔ should persist the keyPrice between upgrades
          ✔ should persist the expirationDuration between upgrades
          ✔ should persist the maxNumberOfKeys between upgrades
          ✔ lock data should persist state between upgrades
          ✔ tokenURI still works as expected
          Using latest version after an upgrade
            ✔ grossNetworkProduct sums previous version purchases with new version purchases
            ✔ Latest Key is owned
            ✔ Latest publicLock version is correct

  Testing version 10
    ✔ Unlock version is set
    ✔ this version and latest version have different Unlock bytecode
    ✔ Unlock has an owner
    ✔ this PublicLock version and latest PublicLock version have different bytecode
    Create a lock for testing
      ✔ PublicLock version is set
      Purchase a key
        ✔ Key has an ID
        ✔ Key is owned
        Upgrade Unlock and PublicLock to latest version
          ✔ this version and latest version have different Unlock version numbers
          ✔ latest version number is correct
          ✔ Key id still set
          ✔ Key is still owned
          ✔ New keys may still be purchased
          ✔ Keys may still be transferred
          ✔ grossNetworkProduct remains
          ✔ should persist the lock name between upgrades
          ✔ should persist the keyPrice between upgrades
          ✔ should persist the expirationDuration between upgrades
          ✔ should persist the maxNumberOfKeys between upgrades
          ✔ lock data should persist state between upgrades
          ✔ tokenURI still works as expected
          Using latest version after an upgrade
            ✔ grossNetworkProduct sums previous version purchases with new version purchases
            ✔ Latest Key is owned
            ✔ Latest publicLock version is correct

  Testing version 11
    ✔ Unlock version is set
    ✔ this version and latest version have different Unlock bytecode
    ✔ Unlock has an owner
    ✔ this PublicLock version and latest PublicLock version have different bytecode
    Create a lock for testing
      ✔ PublicLock version is set
      Purchase a key
        ✔ Key has an ID
        ✔ Key is owned
        Upgrade Unlock and PublicLock to latest version
          ✔ this version and latest version have different Unlock version numbers
          ✔ latest version number is correct
          ✔ Key id still set
          ✔ Key is still owned
          ✔ New keys may still be purchased
          ✔ Keys may still be transferred
          ✔ grossNetworkProduct remains
          ✔ should persist the lock name between upgrades
          ✔ should persist the keyPrice between upgrades
          ✔ should persist the expirationDuration between upgrades
          ✔ should persist the maxNumberOfKeys between upgrades
          ✔ lock data should persist state between upgrades
          ✔ tokenURI still works as expected
          Using latest version after an upgrade
            ✔ grossNetworkProduct sums previous version purchases with new version purchases
            ✔ Latest Key is owned
            ✔ Latest publicLock version is correct

  Testing version 12
    ✔ Unlock version is set
    ✔ this version and latest version have different Unlock bytecode
    ✔ Unlock has an owner
    ✔ this PublicLock version and latest PublicLock version have different bytecode
    Create a lock for testing
      ✔ PublicLock version is set
      Purchase a key
        ✔ Key has an ID
        ✔ Key is owned
        Upgrade Unlock and PublicLock to latest version
          ✔ this version and latest version have different Unlock version numbers
          ✔ latest version number is correct
          ✔ Key id still set
          ✔ Key is still owned
          ✔ New keys may still be purchased
          ✔ Keys may still be transferred
          ✔ grossNetworkProduct remains
          ✔ should persist the lock name between upgrades
          ✔ should persist the keyPrice between upgrades
          ✔ should persist the expirationDuration between upgrades
          ✔ should persist the maxNumberOfKeys between upgrades
          ✔ lock data should persist state between upgrades
          ✔ tokenURI still works as expected
          Using latest version after an upgrade
            ✔ grossNetworkProduct sums previous version purchases with new version purchases
            ✔ Latest Key is owned
            ✔ Latest publicLock version is correct

·----------------------------------------------------------------------------------------------------------|---------------------------|------------|-----------------------------·
|                                           Solc version: 0.7.6                                            ·  Optimizer enabled: true  ·  Runs: 80  ·  Block limit: 30000000 gas  │
···········································································································|···························|············|······························
|  Methods                                                                                                 ·               5 gwei/gas               ·       3410.19 usd/eth       │
········································································|··································|············|··············|············|···············|··············
|  Contract                                                             ·  Method                          ·  Min       ·  Max         ·  Avg       ·  # calls      ·  usd (avg)  │
········································································|··································|············|··············|············|···············|··············
|  @openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol:ProxyAdmin  ·  changeProxyAdmin                ·         -  ·           -  ·     32027  ·            1  ·       0.55  │
········································································|··································|············|··············|············|···············|··············
|  @openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol:ProxyAdmin  ·  transferOwnership               ·         -  ·           -  ·     35876  ·            1  ·       0.61  │
········································································|··································|············|··············|············|···············|··············
|  @openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol:ProxyAdmin  ·  upgrade                         ·     36306  ·       39106  ·     38846  ·          202  ·       0.66  │
········································································|··································|············|··············|············|···············|··············
|  CaptchaHook                                                          ·  addSigner                       ·     46212  ·       46224  ·     46218  ·            4  ·       0.79  │
········································································|··································|············|··············|············|···············|··············
|  CardPurchaser                                                        ·  withdraw                        ·     41229  ·       52072  ·     [4772](https://github.com/unlock-protocol/unlock/actions/runs/8112922362/job/22175150200#step:3:4773)2  ·            8  ·       0.81  │
········································································|··································|············|··············|············|···············|··············
|  DiscountHook                                                         ·  setSigner                       ·         -  ·           -  ·     80468  ·            4  ·       1.37  │
········································································|··································|············|··············|············|···············|··············
|  ERC1155                                                              ·  setApprovalForAll               ·     33652  ·       55576  ·     50344  ·            8  ·       0.86  │
········································································|··································|············|··············|············|···············|··············
|  ERC1155BalanceOfHook                                                 ·  createMapping                   ·     79824  ·       79836  ·     79834  ·            7  ·       1.36  │
········································································|··································|············|··············|············|···············|··············
|  ERC20                                                                ·  approve                         ·     39009  ·       63470  ·     56953  ·           13  ·       0.97  │
········································································|··································|············|··············|············|···············|··············
|  ERC20                                                                ·  transfer                        ·         -  ·           -  ·     46413  ·            1  ·       0.79  │
········································································|··································|············|··············|············|···············|··············
|  ERC20                                                                ·  transferFrom                    ·     99036  ·      126713  ·    115096  ·           53  ·       1.96  │
········································································|··································|············|··············|············|···············|··············
|  ERC20BalanceOfHook                                                   ·  createMapping                   ·     79954  ·       79966  ·     79964  ·           13  ·       1.36  │
········································································|··································|············|··············|············|···············|··············
|  ERC721                                                               ·  safeTransferFrom                ·    116754  ·      118243  ·    117499  ·            2  ·       2.00  │
········································································|··································|············|··············|············|···············|··············
|  ERC721                                                               ·  safeTransferFrom                ·         -  ·           -  ·    117566  ·            1  ·       2.00  │
········································································|··································|············|··············|············|···············|··············
|  ERC721BalanceOfHook                                                  ·  createMapping                   ·     57575  ·       57587  ·     57583  ·            6  ·       0.98  │
········································································|··································|············|··············|············|···············|··············
|  GuildHook                                                            ·  addSigner                       ·         -  ·           -  ·     46224  ·            3  ·       0.79  │
········································································|··································|············|··············|············|···············|··············
|  GuildHook                                                            ·  removeSigner                    ·         -  ·           -  ·     24174  ·            1  ·       0.41  │
········································································|··································|············|··············|············|···············|··············
|  GuildHook                                                            ·  transferOwnership               ·         -  ·           -  ·     28693  ·            1  ·       0.49  │
········································································|··································|············|··············|············|···············|··············
|  KeyManager                                                           ·  addLocksmith                    ·         -  ·           -  ·     54537  ·            6  ·       0.93  │
········································································|··································|············|··············|············|···············|··············
|  KeyManager                                                           ·  removeLocksmith                 ·         -  ·           -  ·     32499  ·            1  ·       0.55  │
········································································|··································|············|··············|············|···············|··············
|  KeyManager                                                           ·  transfer                        ·         -  ·           -  ·    141669  ·            1  ·       2.42  │
········································································|··································|············|··············|············|···············|··············
|  KeyManagerMock                                                       ·  createNewKey                    ·         -  ·           -  ·    186768  ·            1  ·       3.18  │
········································································|··································|············|··············|············|···············|··············
|  KeyManagerV2                                                         ·  someNewFeature                  ·         -  ·           -  ·     28491  ·            1  ·       0.49  │
········································································|··································|············|··············|············|···············|··············
|  PasswordRequiredHook                                                 ·  setSigner                       ·         -  ·           -  ·     57921  ·            4  ·       0.99  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  addLockManager                  ·         -  ·           -  ·     59826  ·            4  ·       1.02  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  burn                            ·    112140  ·      114152  ·    113676  ·            5  ·       1.94  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  cancelAndRefund                 ·     66163  ·       99224  ·     79310  ·           17  ·       1.35  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  expireAndRefundFor              ·     49906  ·       68833  ·     54301  ·           30  ·       0.93  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  extend                          ·     51944  ·      158803  ·    104136  ·           50  ·       1.78  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  grantKeyExtension               ·     44701  ·       50278  ·     47126  ·            4  ·       0.80  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  grantKeys                       ·    166665  ·     1372378  ·    599613  ·           27  ·      10.22  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  initialize                      ·         -  ·           -  ·    334958  ·            2  ·       5.71  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  lendKey                         ·    112545  ·      134903  ·    128751  ·           24  ·       2.20  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  mergeKeys                       ·     56093  ·       58565  ·     57737  ·            3  ·       0.98  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  migrate                         ·     34042  ·    19092832  ·   3151407  ·           30  ·      53.73  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  purchase                        ·    231872  ·     1913546  ·    521547  ·          675  ·       8.89  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  renewMembershipFor              ·    114371  ·      134482  ·    121239  ·           20  ·       2.07  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  renounceLockManager             ·     25284  ·       32409  ·     27659  ·            3  ·       0.47  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  setEventHooks                   ·     74077  ·       74306  ·     74129  ·           74  ·       1.26  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  setGasRefundValue               ·         -  ·           -  ·     54415  ·           16  ·       0.93  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  setKeyExpiration                ·         -  ·           -  ·     38156  ·            2  ·       0.65  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  setKeyManagerOf                 ·     38750  ·       62747  ·     57029  ·           27  ·       0.97  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  setLockMetadata                 ·     42978  ·       88366  ·     70985  ·            9  ·       1.21  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  setOwner                        ·         -  ·           -  ·     37726  ·            8  ·       0.64  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  setReferrerFee                  ·     33262  ·       55186  ·     41533  ·           21  ·       0.71  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  shareKey                        ·    192238  ·      194268  ·    192422  ·           24  ·       3.28  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  unlendKey                       ·         -  ·           -  ·    115864  ·            3  ·       1.98  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  updateKeyPricing                ·     35816  ·       83106  ·     48789  ·           17  ·       0.83  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  updateLockConfig                ·     37714  ·       62438  ·     42701  ·          484  ·       0.73  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  updateRefundPenalty             ·     39772  ·       59684  ·     49728  ·            4  ·       0.85  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  updateSchemaVersion             ·         -  ·           -  ·     53011  ·            1  ·       0.90  │
········································································|··································|············|··············|············|···············|··············
|  PublicLock                                                           ·  updateTransferFee               ·     34349  ·       54273  ·     35630  ·          131  ·       0.61  │
········································································|··································|············|··············|············|···············|··············
|  TestERC1155                                                          ·  mint                            ·         -  ·           -  ·     50059  ·            3  ·       0.85  │
········································································|··································|············|··············|············|···············|··············
|  TestERC20                                                            ·  approve                         ·     26356  ·       46568  ·     45299  ·          121  ·       0.77  │
········································································|··································|············|··············|············|···············|··············
|  TestERC20                                                            ·  mint                            ·     51132  ·       68304  ·     63887  ·          140  ·       1.09  │
········································································|··································|············|··············|············|···············|··············
|  TestERC20                                                            ·  transfer                        ·         -  ·           -  ·     46677  ·            1  ·       0.80  │
········································································|··································|············|··············|············|···············|··············
|  TestERC20                                                            ·  transferFrom                    ·         -  ·           -  ·     49700  ·            1  ·       0.85  │
········································································|··································|············|··············|············|···············|··············
|  TestERC721                                                           ·  mint                            ·         -  ·           -  ·     91034  ·            3  ·       1.55  │
········································································|··································|············|··············|············|···············|··············
|  TestEventHooks                                                       ·  configure                       ·     46040  ·       66324  ·     58601  ·            8  ·       1.00  │
········································································|··································|············|··············|············|···············|··············
|  TestEventHooks                                                       ·  setSpecialMember                ·         -  ·           -  ·     44534  ·            1  ·       0.76  │
········································································|··································|············|··············|············|···············|··············
|  TimelockControllerUpgradeable                                        ·  grantRole                       ·     58634  ·       58781  ·     58661  ·            8  ·       1.00  │
········································································|··································|············|··············|············|···············|··············
|  TimelockControllerUpgradeable                                        ·  revokeRole                      ·         -  ·           -  ·     36640  ·            1  ·       0.62  │
········································································|··································|············|··············|············|···············|··············
|  TimeMachineMock                                                      ·  createNewKey                    ·    150687  ·      186790  ·    168739  ·            4  ·       2.88  │
········································································|··································|············|··············|············|···············|··············
|  TimeMachineMock                                                      ·  timeMachine                     ·     31320  ·       31391  ·     31361  ·            6  ·       0.53  │
········································································|··································|············|··············|············|···············|··············
|  UniswapOracleV3                                                      ·  update                          ·     94248  ·       94270  ·     94259  ·            2  ·       1.61  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  addLockTemplate                 ·     66805  ·      399661  ·    364905  ·          704  ·       6.22  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  configUnlock                    ·     50503  ·      150929  ·     85573  ·           12  ·       1.46  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  createLock                      ·    445718  ·      974161  ·    558882  ·          193  ·       9.53  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  createUpgradeableLock           ·    951564  ·     1000107  ·    976759  ·          613  ·      16.65  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  createUpgradeableLockAtVersion  ·    928029  ·      972411  ·    953849  ·           20  ·      16.26  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  initializeProxyAdmin            ·         -  ·           -  ·    458312  ·           64  ·       7.81  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  resetTrackedValue               ·     3[4779](https://github.com/unlock-protocol/unlock/actions/runs/8112922362/job/22175150200#step:3:4780)  ·       39663  ·     38742  ·           11  ·       0.66  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  setLockTemplate                 ·     41958  ·      376961  ·    116649  ·          759  ·       1.99  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  setOracle                       ·    138048  ·      138058  ·    138053  ·            2  ·       2.35  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  setProtocolFee                  ·     33083  ·       52983  ·     39716  ·            3  ·       0.68  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  setSwapBurner                   ·     34900  ·       5[4800](https://github.com/unlock-protocol/unlock/actions/runs/8112922362/job/22175150200#step:3:4801)  ·     39343  ·            7  ·       0.67  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  swapAndBurn                     ·     44006  ·       65272  ·     58183  ·            3  ·       0.99  │
········································································|··································|············|··············|············|···············|··············
|  Unlock                                                               ·  upgradeLock                     ·     72098  ·     9623339  ·   1545176  ·           13  ·      26.35  │
········································································|··································|············|··············|············|···············|··············
|  UnlockDiscountTokenV2                                                ·  addMinter                       ·     55037  ·       55049  ·     55043  ·            2  ·       0.94  │
········································································|··································|············|··············|············|···············|··············
|  UnlockDiscountTokenV2                                                ·  delegate                        ·     35879  ·      102672  ·     50190  ·           12  ·       0.86  │
········································································|··································|············|··············|············|···············|··············
|  UnlockDiscountTokenV2                                                ·  mint                            ·     79272  ·      127880  ·    106660  ·           18  ·       1.82  │
········································································|··································|············|··············|············|···············|··············
|  UnlockDiscountTokenV2                                                ·  renounceMinter                  ·         -  ·           -  ·     30309  ·            1  ·       0.52  │
········································································|··································|············|··············|············|···············|··············
|  UnlockDiscountTokenV3                                                ·  delegate                        ·     48632  ·      110903  ·     77744  ·           22  ·       1.33  │
········································································|··································|············|··············|············|···············|··············
|  UnlockDiscountTokenV3                                                ·  initialize                      ·         -  ·           -  ·    205602  ·           21  ·       3.51  │
········································································|··································|············|··············|············|···············|··············
|  UnlockDiscountTokenV3                                                ·  mint                            ·    104669  ·      167601  ·    125342  ·           20  ·       2.14  │
········································································|··································|············|··············|············|···············|··············
|  UnlockDiscountTokenV3                                                ·  transfer                        ·     56338  ·      135701  ·     85663  ·           15  ·       1.46  │
········································································|··································|············|··············|············|···············|··············
|  UnlockProtocolGovernor                                               ·  castVote                        ·    113850  ·      116873  ·    114862  ·            3  ·       1.96  │
········································································|··································|············|··············|············|···············|··············
|  UnlockProtocolGovernor                                               ·  execute                         ·    151107  ·      153167  ·    152437  ·            6  ·       2.60  │
········································································|··································|············|··············|············|···············|··············
|  UnlockProtocolGovernor                                               ·  propose                         ·    119294  ·      120066  ·    119555  ·            6  ·       2.04  │
········································································|··································|············|··············|············|···············|··············
|  UnlockProtocolGovernor                                               ·  queue                           ·    142175  ·      142247  ·    142203  ·            3  ·       2.42  │
········································································|··································|············|··············|············|···············|··············
|  UnlockSwapPurchaser                                                  ·  withdrawToUnlock                ·     40384  ·       52984  ·     46684  ·            2  ·       0.80  │
········································································|··································|············|··············|············|···············|··············
|  Deployments                                                                                             ·                                        ·  % of limit   ·             │
···········································································································|············|··············|············|···············|··············
|  CaptchaHook                                                                                             ·         -  ·           -  ·    841337  ·        2.8 %  ·      14.35  │
···········································································································|············|··············|············|···············|··············
|  DiscountHook                                                                                            ·         -  ·           -  ·    871466  ·        2.9 %  ·      14.86  │
···········································································································|············|··············|············|···············|··············
|  ERC1155BalanceOfHook                                                                                    ·         -  ·           -  ·    317889  ·        1.1 %  ·       5.42  │
···········································································································|············|··············|············|···············|··············
|  ERC20BalanceOfHook                                                                                      ·         -  ·           -  ·    337100  ·        1.1 %  ·       5.75  │
···········································································································|············|··············|············|···············|··············
|  ERC721BalanceOfHook                                                                                     ·         -  ·           -  ·    299517  ·          1 %  ·       5.11  │
···········································································································|············|··············|············|···············|··············
|  GuildHook                                                                                               ·         -  ·           -  ·    715663  ·        2.4 %  ·      12.20  │
···········································································································|············|··············|············|···············|··············
|  KeyManager                                                                                              ·         -  ·           -  ·    929186  ·        3.1 %  ·      15.84  │
···········································································································|············|··············|············|···············|··············
|  KeyManagerMock                                                                                          ·         -  ·           -  ·   2025596  ·        6.8 %  ·      34.54  │
···········································································································|············|··············|············|···············|··············
|  KeyManagerV2                                                                                            ·         -  ·           -  ·    931559  ·        3.1 %  ·      15.88  │
···········································································································|············|··············|············|···············|··············
|  LockSerializer                                                                                          ·         -  ·           -  ·    882299  ·        2.9 %  ·      15.04  │
···········································································································|············|··············|············|···············|··············
|  MockSwapBurner                                                                                          ·         -  ·           -  ·    181509  ·        0.6 %  ·       3.09  │
···········································································································|············|··············|············|···············|··············
|  PasswordRequiredHook                                                                                    ·         -  ·           -  ·    733946  ·        2.4 %  ·      12.51  │
···········································································································|············|··············|············|···············|··············
|  PublicLock                                                                                              ·         -  ·           -  ·   5194645  ·       17.3 %  ·      88.57  │
···········································································································|············|··············|············|···············|··············
|  TestERC1155                                                                                             ·         -  ·           -  ·   1205765  ·          4 %  ·      20.56  │
···········································································································|············|··············|············|···············|··············
|  TestERC20                                                                                               ·         -  ·           -  ·    608092  ·          2 %  ·      10.37  │
···········································································································|············|··············|············|···············|··············
|  TestERC721                                                                                              ·         -  ·           -  ·   1103066  ·        3.7 %  ·      18.81  │
···········································································································|············|··············|············|···············|··············
|  TestERC721Recevier                                                                                      ·         -  ·           -  ·    130723  ·        0.4 %  ·       2.23  │
···········································································································|············|··············|············|···············|··············
|  TestEventHooks                                                                                          ·         -  ·           -  ·    955004  ·        3.2 %  ·      16.28  │
···········································································································|············|··············|············|···············|··············
|  TestPublicLockUpgraded                                                                                  ·         -  ·           -  ·   2806868  ·        9.4 %  ·      47.86  │
···········································································································|············|··············|············|···············|··············
|  TimeMachineMock                                                                                         ·         -  ·           -  ·   2039222  ·        6.8 %  ·      34.77  │
···········································································································|············|··············|············|···············|··············
|  Unlock                                                                                                  ·         -  ·           -  ·   3570515  ·       11.9 %  ·      60.88  │
···········································································································|············|··············|············|···············|··············
|  UnlockDiscountTokenV3                                                                                   ·         -  ·           -  ·   22[4812](https://github.com/unlock-protocol/unlock/actions/runs/8112922362/job/22175150200#step:3:4813)8  ·        7.5 %  ·      38.33  │
···········································································································|············|··············|············|···············|··············
|  UnlockProtocolGovernor                                                                                  ·         -  ·           -  ·   35[4888](https://github.com/unlock-protocol/unlock/actions/runs/8112922362/job/22175150200#step:3:4889)7  ·       11.8 %  ·      60.51  │
···········································································································|············|··············|············|···············|··············
|  UnlockProtocolTimelock                                                                                  ·         -  ·           -  ·   1920785  ·        6.4 %  ·      32.75  │
···········································································································|············|··············|············|···············|··············
|  UnlockSwapBurner                                                                                        ·         -  ·           -  ·    661787  ·        2.2 %  ·      11.28  │
···········································································································|············|··············|············|···············|··············
|  UnlockSwapPurchaser                                                                                     ·         -  ·           -  ·    928544  ·        3.1 %  ·      15.83  │
·----------------------------------------------------------------------------------------------------------|------------|--------------|------------|---------------|-------------·

  941 passing (7m)
  86 pending

@clemsos
Copy link
Member Author

clemsos commented Mar 4, 2024

Currently we got

939 passing (8m)
86 pending

Before refactoring:

  941 passing (7m)
  86 pending

@clemsos
Copy link
Member Author

clemsos commented Mar 5, 2024

@julien51 we should be good to go here !

@julien51
Copy link
Member

julien51 commented Mar 5, 2024

ok, I am looking at the coverage also,

------------------------------|----------|----------|----------|----------|----------------|
File                          |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
------------------------------|----------|----------|----------|----------|----------------|
 contracts/                   |    75.19 |    58.18 |       80 |    71.96 |                |
  CardPurchaser.sol           |        0 |        0 |        0 |        0 |... 171,197,198 |
  KeyManager.sol              |      100 |       90 |      100 |      100 |                |
  PublicLock.sol              |      100 |      100 |      100 |      100 |                |
  Unlock.sol                  |    92.94 |    70.27 |     87.5 |     88.1 |... 650,679,704 |
  UnlockProtocolTimelock.sol  |      100 |       50 |      100 |      100 |                |
 contracts/hooks/             |    90.65 |    85.48 |    79.55 |    89.63 |                |
  CaptchaHook.sol             |    82.35 |       50 |       70 |    82.61 |    18,35,60,64 |
  DiscountCodeHook.sol        |    90.91 |       80 |    77.78 |     87.1 |  27,30,102,106 |
  ERC1155BalanceOfHook.sol    |      100 |      100 |      100 |      100 |                |
  ERC20BalanceOfHook.sol      |      100 |      100 |      100 |      100 |                |
  ERC721BalanceOfHook.sol     |      100 |      100 |      100 |      100 |                |
  GuildHook.sol               |    82.35 |       75 |       80 |    86.96 |       35,60,64 |
  PasswordRequiredHook.sol    |    86.67 |       75 |    77.78 |    86.96 |       22,68,72 |
 contracts/interfaces/        |      100 |      100 |      100 |      100 |                |
  IMintableERC20.sol          |      100 |      100 |      100 |      100 |                |
  IPermit2.sol                |      100 |      100 |      100 |      100 |                |
  IPublicLock.sol             |      100 |      100 |      100 |      100 |                |
  ISwapBurner.sol             |      100 |      100 |      100 |      100 |                |
  IUSDC.sol                   |      100 |      100 |      100 |      100 |                |
  IUniswapOracleV3.sol        |      100 |      100 |      100 |      100 |                |
  IUnlock.sol                 |      100 |      100 |      100 |      100 |                |
  IWETH.sol                   |      100 |      100 |      100 |      100 |                |
 contracts/interfaces/hooks/  |      100 |      100 |      100 |      100 |                |
  ILockKeyCancelHook.sol      |      100 |      100 |      100 |      100 |                |
  ILockKeyExtendHook.sol      |      100 |      100 |      100 |      100 |                |
  ILockKeyGrantHook.sol       |      100 |      100 |      100 |      100 |                |
  ILockKeyPurchaseHook.sol    |      100 |      100 |      100 |      100 |                |
  ILockKeyTransferHook.sol    |      100 |      100 |      100 |      100 |                |
  ILockTokenURIHook.sol       |      100 |      100 |      100 |      100 |                |
  ILockValidKeyHook.sol       |      100 |      100 |      100 |      100 |                |
 contracts/mixins/            |    98.78 |    91.82 |    98.92 |    97.29 |                |
  MixinConvenienceOwnable.sol |      100 |      100 |      100 |      100 |                |
  MixinDisable.sol            |      100 |      100 |      100 |      100 |                |
  MixinERC721Enumerable.sol   |      100 |      100 |      100 |      100 |                |
  MixinErrors.sol             |      100 |      100 |      100 |      100 |                |
  MixinFunds.sol              |      100 |    66.67 |      100 |    88.89 |             32 |
  MixinGrantKeys.sol          |      100 |      100 |      100 |      100 |                |
  MixinKeys.sol               |    96.34 |    95.31 |    96.67 |     96.3 |... 147,159,160 |
  MixinLockCore.sol           |      100 |    95.83 |      100 |    98.11 |            121 |
  MixinLockMetadata.sol       |      100 |      100 |      100 |      100 |                |
  MixinPurchase.sol           |      100 |    94.44 |      100 |    98.95 |            263 |
  MixinRefunds.sol            |      100 |      100 |      100 |      100 |                |
  MixinRoles.sol              |      100 |    66.67 |      100 |      100 |                |
  MixinTransfer.sol           |    98.28 |    79.41 |      100 |     93.9 |... 202,299,328 |
------------------------------|----------|----------|----------|----------|----------------|
All files                     |    91.73 |    81.38 |    89.56 |    90.05 |                |
------------------------------|----------|----------|----------|----------|----------------|

I have been trying to run this locally from master to see how it evolved but I am getting an error.

> Istanbul reports written to ./coverage/ and ./coverage.json
Error in plugin solidity-coverage: HardhatError: HH701: There are multiple artifacts for contract "PublicLock", please use a fully qualified name.

Please replace PublicLock for one of these options wherever you are trying to read its artifact:

contracts/PublicLock.sol:PublicLock
contracts/past-versions/PublicLockV10.sol:PublicLock
contracts/past-versions/PublicLockV9.sol:PublicLock


For more info run Hardhat with --show-stack-traces

Copy link
Member

@julien51 julien51 left a comment

Choose a reason for hiding this comment

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

Let's do it!

beforeEach(async () => {
;[, , , { address: someAccount }] = await ethers.getSigners()
Copy link
Member

Choose a reason for hiding this comment

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

If we don't really care what that is maybe we can rather just create a random one?

@julien51
Copy link
Member

julien51 commented Mar 5, 2024

I was in fact able to run it after cleaning rm -rf contracts/past-versions and the coverage went slightly up!
Before the change we had:


------------------------------|----------|----------|----------|----------|----------------|
File                          |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
------------------------------|----------|----------|----------|----------|----------------|
 contracts/                   |    75.19 |    58.18 |       80 |    71.96 |                |
  CardPurchaser.sol           |        0 |        0 |        0 |        0 |... 171,197,198 |
  KeyManager.sol              |      100 |       90 |      100 |      100 |                |
  PublicLock.sol              |      100 |      100 |      100 |      100 |                |
  Unlock.sol                  |    92.94 |    70.27 |     87.5 |     88.1 |... 650,679,704 |
  UnlockProtocolTimelock.sol  |      100 |       50 |      100 |      100 |                |
 contracts/hooks/             |    90.65 |    85.48 |    79.55 |    89.63 |                |
  CaptchaHook.sol             |    82.35 |       50 |       70 |    82.61 |    18,35,60,64 |
  DiscountCodeHook.sol        |    90.91 |       80 |    77.78 |     87.1 |  27,30,102,106 |
  ERC1155BalanceOfHook.sol    |      100 |      100 |      100 |      100 |                |
  ERC20BalanceOfHook.sol      |      100 |      100 |      100 |      100 |                |
  ERC721BalanceOfHook.sol     |      100 |      100 |      100 |      100 |                |
  GuildHook.sol               |    82.35 |       75 |       80 |    86.96 |       35,60,64 |
  PasswordRequiredHook.sol    |    86.67 |       75 |    77.78 |    86.96 |       22,68,72 |
 contracts/interfaces/        |      100 |      100 |      100 |      100 |                |
  IMintableERC20.sol          |      100 |      100 |      100 |      100 |                |
  IPermit2.sol                |      100 |      100 |      100 |      100 |                |
  IPublicLock.sol             |      100 |      100 |      100 |      100 |                |
  ISwapBurner.sol             |      100 |      100 |      100 |      100 |                |
  IUSDC.sol                   |      100 |      100 |      100 |      100 |                |
  IUniswapOracleV3.sol        |      100 |      100 |      100 |      100 |                |
  IUnlock.sol                 |      100 |      100 |      100 |      100 |                |
  IWETH.sol                   |      100 |      100 |      100 |      100 |                |
 contracts/interfaces/hooks/  |      100 |      100 |      100 |      100 |                |
  ILockKeyCancelHook.sol      |      100 |      100 |      100 |      100 |                |
  ILockKeyExtendHook.sol      |      100 |      100 |      100 |      100 |                |
  ILockKeyGrantHook.sol       |      100 |      100 |      100 |      100 |                |
  ILockKeyPurchaseHook.sol    |      100 |      100 |      100 |      100 |                |
  ILockKeyTransferHook.sol    |      100 |      100 |      100 |      100 |                |
  ILockTokenURIHook.sol       |      100 |      100 |      100 |      100 |                |
  ILockValidKeyHook.sol       |      100 |      100 |      100 |      100 |                |
 contracts/mixins/            |    98.78 |    92.27 |    98.92 |     97.5 |                |
  MixinConvenienceOwnable.sol |      100 |      100 |      100 |      100 |                |
  MixinDisable.sol            |      100 |      100 |      100 |      100 |                |
  MixinERC721Enumerable.sol   |      100 |      100 |      100 |      100 |                |
  MixinErrors.sol             |      100 |      100 |      100 |      100 |                |
  MixinFunds.sol              |      100 |    66.67 |      100 |    88.89 |             32 |
  MixinGrantKeys.sol          |      100 |      100 |      100 |      100 |                |
  MixinKeys.sol               |    96.34 |    95.31 |    96.67 |     96.3 |... 147,159,160 |
  MixinLockCore.sol           |      100 |    95.83 |      100 |    98.11 |            121 |
  MixinLockMetadata.sol       |      100 |      100 |      100 |      100 |                |
  MixinPurchase.sol           |      100 |    94.44 |      100 |    98.95 |            263 |
  MixinRefunds.sol            |      100 |      100 |      100 |      100 |                |
  MixinRoles.sol              |      100 |    66.67 |      100 |      100 |                |
  MixinTransfer.sol           |    98.28 |    82.35 |      100 |    95.12 |106,202,299,328 |
------------------------------|----------|----------|----------|----------|----------------|
All files                     |    91.73 |    81.63 |    89.56 |    90.17 |                |
------------------------------|----------|----------|----------|----------|----------------|

@julien51 julien51 merged commit 61675d2 into master Mar 5, 2024
12 checks passed
@julien51 julien51 deleted the cleanup-web3-tests branch March 5, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants