Pandora-Labs-Org / erc404

396 stars 185 forks source link

Migrate Hardhat tests to Foundry #6

Closed mathdroid closed 8 months ago

mathdroid commented 9 months ago
mathdroid commented 9 months ago

Continuing from #8 @caldereth

mathdroid commented 9 months ago
[⠢] Compiling...
[⠑] Compiling 1 files with 0.8.20
[⠔] Solc 0.8.20 finished in 7.38s
Compiler run successful!

Running 2 tests for test/ERC404.t.sol:Erc404RetrieveOrMint721Test
[PASS] test_balanceGtZero_mintFull20And721() (gas: 278033)
[PASS] test_balanceZero_mintFull20And721() (gas: 161652)
Test result: ok. 2 passed; 0 failed; finished in 1.15ms

Running 1 test for test/ERC404.t.sol:Erc404Erc20BalanceOfTest
[PASS] test_balanceOf() (gas: 149513)
Test result: ok. 1 passed; 0 failed; finished in 572.23µs

Running 1 test for test/ERC404.t.sol:ERC404TransferTest
[PASS] test_revert_transfer_toZero() (gas: 14985)
Test result: ok. 1 passed; 0 failed; finished in 720.28µs

Running 3 tests for test/ERC404.t.sol:Erc404Erc721BalanceOfTest
[PASS] test_0_9_balance() (gas: 51867)
[PASS] test_1_1_balance() (gas: 144054)
[PASS] test_exactly1Balance() (gas: 143917)
Test result: ok. 3 passed; 0 failed; finished in 1.04ms

Running 4 tests for test/ERC404.t.sol:ERC404TransferLogicTest
[PASS] test_erc20TransferTriggering721Transfer_allCasesAtOnce() (gas: 286606)
[PASS] test_erc20TransferTriggering721Transfer_fractional_receiverGain() (gas: 156550)
[PASS] test_erc20TransferTriggering721Transfer_fractional_senderLose() (gas: 120151)
[PASS] test_erc20TransferTriggering721Transfer_whole_noFractionalImpact() (gas: 155886)
Test result: ok. 4 passed; 0 failed; finished in 3.64ms

Running 4 tests for test/ERC404.t.sol:Erc404PermitTest
[PASS] test_revert_deadlineExpired() (gas: 34469)
[PASS] test_revert_permit20AddressZero() (gas: 28548)
[PASS] test_revert_permit721() (gas: 29014)
[PASS] test_setApprovalFromPermit() (gas: 86411)
Test result: ok. 4 passed; 0 failed; finished in 3.54ms

Running 1 test for test/ERC404.t.sol:Erc404E2ETest
[PASS] test_mintFull_transfer20_transfer721_bankRetrieve_setRemoveWhitelist() (gas: 5621985)
Test result: ok. 1 passed; 0 failed; finished in 5.86ms

Running 5 tests for test/ERC404.t.sol:Erc404SetApprovalForAllTest
[PASS] test_approvalOperator_removeOperatorApprovalForAll(address) (runs: 256, μ: 31309, ~: 31296)
[PASS] test_approvalOperator_setApprovalForAll(address) (runs: 256, μ: 39176, ~: 39176)
[PASS] test_approvalSelf_all721() (gas: 37851)
[PASS] test_approvalSelf_removeApproval() (gas: 30332)
[PASS] test_reverts_approvalZero() (gas: 13114)
Test result: ok. 5 passed; 0 failed; finished in 31.28ms

Running 5 tests for test/ERC404.t.sol:Erc404SetApprovalTest
[PASS] test_grant20Approval() (gas: 45996)
[PASS] test_grantSpecific721Approval(address) (runs: 256, μ: 48662, ~: 48662)
[PASS] test_operatorGrantSpecificAfterApprovalForAll() (gas: 67760)
[PASS] test_reverts_grantAddressZeroAllowance() (gas: 14154)
[PASS] test_revokeSpecific721Approval(address) (runs: 256, μ: 39000, ~: 38987)
Test result: ok. 5 passed; 0 failed; finished in 38.71ms

Running 2 tests for test/ERC404.t.sol:Erc404SetWhitelistTest
[PASS] test_revert_setWhitelist_removeAddressWithErc20Balance(address) (runs: 256, μ: 177747, ~: 177747)
[PASS] test_setWhitelist_ownerAddAndRemove(address) (runs: 256, μ: 33519, ~: 33506)
Test result: ok. 2 passed; 0 failed; finished in 40.52ms

Running 4 tests for test/ERC404.t.sol:Erc404Test
[PASS] test_initialMint() (gas: 25572)
[PASS] test_initialWhitelist() (gas: 9987)
[PASS] test_initializeSimple() (gas: 28090)
[PASS] test_tokenTransfer(uint8,address) (runs: 256, μ: 1316684, ~: 558655)
Test result: ok. 4 passed; 0 failed; finished in 288.79ms

Running 6 tests for test/ERC404.t.sol:Erc404MintingStorageAndRetrievalTest
[PASS] test_erc721Storage_mintFrom0(uint8,address) (runs: 256, μ: 942514, ~: 277104)
[PASS] test_erc721Storage_retrieveFromBank(uint8,address,address) (runs: 256, μ: 1494676, ~: 664272)
[PASS] test_erc721Storage_storeInBankOnBurn(uint8,address,address) (runs: 256, μ: 1332343, ~: 703220)
[PASS] test_initializeMinimal() (gas: 28106)
[PASS] test_mintFullSupply_20(address) (runs: 256, μ: 66997, ~: 66997)
[PASS] test_mintFullSupply_20_721(address) (runs: 256, μ: 4950353, ~: 4950353)
Test result: ok. 6 passed; 0 failed; finished in 288.21ms

Running 7 tests for test/ERC404.t.sol:ERC404TransferFromTest
[PASS] test_mintFullSupply_20_721(address) (runs: 256, μ: 4950284, ~: 4950284)
[PASS] test_revert_transferFrom_ToAndFromZero() (gas: 11401)
[PASS] test_revert_transferFrom_fromZero() (gas: 13571)
[PASS] test_revert_transferFrom_toZero() (gas: 13590)
[PASS] test_revert_transferNotOwnedByAlice() (gas: 4958466)
[PASS] test_revert_transferNotOwnedByOperator() (gas: 4959873)
[PASS] test_transferOwnedByOperator() (gas: 5013292)
Test result: ok. 7 passed; 0 failed; finished in 296.21ms
| src/examples/ExampleERC404.sol:ExampleERC404 contract |                 |         |        |         |         |
|-------------------------------------------------------|-----------------|---------|--------|---------|---------|
| Deployment Cost                                       | Deployment Size |         |        |         |         |
| 2090842                                               | 13434           |         |        |         |         |
| Function Name                                         | min             | avg     | median | max     | # calls |
| balanceOf                                             | 653             | 1278    | 653    | 2653    | 16      |
| decimals                                              | 250             | 250     | 250    | 250     | 1       |
| erc20BalanceOf                                        | 606             | 606     | 606    | 606     | 6       |
| erc20TotalSupply                                      | 425             | 425     | 425    | 425     | 2       |
| erc721BalanceOf                                       | 648             | 1348    | 648    | 2648    | 20      |
| erc721TotalSupply                                     | 337             | 1337    | 1337   | 2337    | 2       |
| erc721TransferExempt                                  | 610             | 1276    | 610    | 2610    | 9       |
| isApprovedForAll                                      | 760             | 1760    | 1760   | 2760    | 8       |
| name                                                  | 3277            | 3277    | 3277   | 3277    | 1       |
| owned                                                 | 2895            | 2895    | 2895   | 2895    | 1       |
| owner                                                 | 2399            | 2399    | 2399   | 2399    | 1       |
| ownerOf                                               | 805             | 997     | 805    | 2734    | 20      |
| setApprovalForAll                                     | 572             | 12021   | 12429  | 22654   | 8       |
| setERC721TransferExempt                               | 914             | 18818   | 25110  | 25110   | 8       |
| symbol                                                | 3276            | 3276    | 3276   | 3276    | 1       |
| totalSupply                                           | 2407            | 2407    | 2407   | 2407    | 2       |
| transfer                                              | 469             | 1140664 | 122882 | 4891597 | 19      |
| transferFrom                                          | 637             | 648     | 637    | 672     | 3       |

| src/mocks/MinimalERC404.sol:MinimalERC404 contract |                 |         |         |         |         |
|----------------------------------------------------|-----------------|---------|---------|---------|---------|
| Deployment Cost                                    | Deployment Size |         |         |         |         |
| 1828441                                            | 10792           |         |         |         |         |
| Function Name                                      | min             | avg     | median  | max     | # calls |
| DOMAIN_SEPARATOR                                   | 324             | 324     | 324     | 324     | 4       |
| allowance                                          | 781             | 2281    | 2781    | 2781    | 4       |
| approve                                            | 597             | 16790   | 23704   | 25267   | 6       |
| balanceOf                                          | 608             | 2008    | 2608    | 2608    | 10      |
| decimals                                           | 272             | 272     | 272     | 272     | 1       |
| erc20BalanceOf                                     | 606             | 606     | 606     | 606     | 17      |
| erc20TotalSupply                                   | 360             | 360     | 360     | 360     | 7       |
| erc721BalanceOf                                    | 582             | 962     | 582     | 2582    | 21      |
| erc721TokensBankedInQueue                          | 463             | 1463    | 1463    | 2463    | 8       |
| erc721TotalSupply                                  | 381             | 1158    | 381     | 2381    | 18      |
| erc721TransferExempt                               | 2610            | 2610    | 2610    | 2610    | 4       |
| getApproved                                        | 590             | 990     | 590     | 2590    | 5       |
| mintERC20                                          | 3358            | 3427170 | 4930358 | 4932358 | 23      |
| name                                               | 3277            | 3277    | 3277    | 3277    | 1       |
| owner                                              | 2421            | 2421    | 2421    | 2421    | 1       |
| ownerOf                                            | 715             | 875     | 760     | 4760    | 239     |
| permit                                             | 684             | 13316   | 844     | 50895   | 4       |
| setApprovalForAll                                  | 24617           | 24617   | 24617   | 24617   | 1       |
| symbol                                             | 3298            | 3298    | 3298    | 3298    | 1       |
| totalSupply                                        | 407             | 407     | 407     | 407     | 8       |
| transfer                                           | 28502           | 66080   | 60204   | 160526  | 9       |
| transferFrom                                       | 928             | 30805   | 30198   | 61898   | 4       |

| test/ERC404.t.sol:SigUtils contract |                 |      |        |      |         |
|-------------------------------------|-----------------|------|--------|------|---------|
| Deployment Cost                     | Deployment Size |      |        |      |         |
| 132196                              | 676             |      |        |      |         |
| Function Name                       | min             | avg  | median | max  | # calls |
| getTypedDataHash                    | 3307            | 3307 | 3307   | 3307 | 4       |
mathdroid commented 8 months ago
Running 1 test for test/ERC404.t.sol:ERC404TransferTest
[PASS] test_revert_transfer_toZero() (gas: 14985)
Test result: ok. 1 passed; 0 failed; finished in 592.80µs

Running 1 test for test/ERC404.t.sol:Erc404Erc20BalanceOfTest
[PASS] test_balanceOf() (gas: 149513)
Test result: ok. 1 passed; 0 failed; finished in 810.43µs

Running 4 tests for test/ERC404.t.sol:ERC404TransferLogicTest
[PASS] test_erc20TransferTriggering721Transfer_allCasesAtOnce() (gas: 286606)
[PASS] test_erc20TransferTriggering721Transfer_fractional_receiverGain() (gas: 156550)
[PASS] test_erc20TransferTriggering721Transfer_fractional_senderLose() (gas: 120151)
[PASS] test_erc20TransferTriggering721Transfer_whole_noFractionalImpact() (gas: 155886)
Test result: ok. 4 passed; 0 failed; finished in 3.76ms

Running 4 tests for test/ERC404.t.sol:Erc404PermitTest
[PASS] test_revert_deadlineExpired() (gas: 34469)
[PASS] test_revert_permit20AddressZero() (gas: 28548)
[PASS] test_revert_permit721() (gas: 29014)
[PASS] test_setApprovalFromPermit() (gas: 86411)
Test result: ok. 4 passed; 0 failed; finished in 3.78ms

Running 3 tests for test/ERC404.t.sol:Erc404Erc721BalanceOfTest
[PASS] test_0_9_balance() (gas: 51867)
[PASS] test_1_1_balance() (gas: 144054)
[PASS] test_exactly1Balance() (gas: 143917)
Test result: ok. 3 passed; 0 failed; finished in 1.19ms

Running 1 test for test/ERC404.t.sol:Erc404E2ETest
[PASS] test_mintFull_transfer20_transfer721_bankRetrieve_setRemoveWhitelist() (gas: 5622427)
Test result: ok. 1 passed; 0 failed; finished in 5.03ms

Running 5 tests for test/ERC404.t.sol:Erc404SetApprovalForAllTest
[PASS] test_approvalOperator_removeOperatorApprovalForAll(address) (runs: 256, μ: 31308, ~: 31296)
[PASS] test_approvalOperator_setApprovalForAll(address) (runs: 256, μ: 39176, ~: 39176)
[PASS] test_approvalSelf_all721() (gas: 37851)
[PASS] test_approvalSelf_removeApproval() (gas: 30332)
[PASS] test_reverts_approvalZero() (gas: 13114)
Test result: ok. 5 passed; 0 failed; finished in 30.52ms

Running 5 tests for test/ERC404.t.sol:Erc404SetApprovalTest
[PASS] test_grant20Approval() (gas: 45996)
[PASS] test_grantSpecific721Approval(address) (runs: 256, μ: 48662, ~: 48662)
[PASS] test_operatorGrantSpecificAfterApprovalForAll() (gas: 67760)
[PASS] test_reverts_grantAddressZeroAllowance() (gas: 14154)
[PASS] test_revokeSpecific721Approval(address) (runs: 256, μ: 38996, ~: 38987)
Test result: ok. 5 passed; 0 failed; finished in 34.75ms

Running 2 tests for test/ERC404.t.sol:Erc404SetWhitelistTest
[PASS] test_revert_setWhitelist_removeAddressWithErc20Balance(address) (runs: 256, μ: 177747, ~: 177747)
[PASS] test_setWhitelist_ownerAddAndRemove(address) (runs: 256, μ: 33520, ~: 33506)
Test result: ok. 2 passed; 0 failed; finished in 52.63ms

Running 2 tests for test/ERC404.t.sol:Erc404RetrieveOrMint721Test
[PASS] test_balanceGtZero_mintFull20And721() (gas: 282901)
[PASS] test_balanceZero_mintFull20And721() (gas: 163873)
Test result: ok. 2 passed; 0 failed; finished in 134.45ms

Running 4 tests for test/ERC404.t.sol:Erc404Test
[PASS] test_initialMint() (gas: 25572)
[PASS] test_initialWhitelist() (gas: 9987)
[PASS] test_initializeSimple() (gas: 28090)
[PASS] test_tokenTransfer(uint8,address) (runs: 256, μ: 1001248, ~: 258960)
Test result: ok. 4 passed; 0 failed; finished in 282.69ms

Running 7 tests for test/ERC404.t.sol:Erc404MintingStorageAndRetrievalTest
[PASS] test_erc721Storage_mintFrom0(uint8,address) (runs: 256, μ: 1060691, ~: 279325)
[PASS] test_erc721Storage_retrieveFromBank(uint8,address,address) (runs: 256, μ: 1417874, ~: 712867)
[PASS] test_erc721Storage_storeInBankOnBurn(uint8,address,address) (runs: 256, μ: 1397628, ~: 558319)
[PASS] test_initializeMinimal() (gas: 28106)
[PASS] test_mintFullSupply_20(address) (runs: 256, μ: 67017, ~: 67017)
[PASS] test_mintFullSupply_20_721(address) (runs: 256, μ: 4952574, ~: 4952574)
[PASS] test_mintFullSupply_20_721_whitelistedRecipient(address) (runs: 256, μ: 92584, ~: 92584)
Test result: ok. 7 passed; 0 failed; finished in 282.03ms

Running 7 tests for test/ERC404.t.sol:ERC404TransferFromTest
[PASS] test_mintFullSupply_20_721(address) (runs: 256, μ: 4952505, ~: 4952505)
[PASS] test_revert_transferFrom_ToAndFromZero() (gas: 11401)
[PASS] test_revert_transferFrom_fromZero() (gas: 13571)
[PASS] test_revert_transferFrom_toZero() (gas: 13590)
[PASS] test_revert_transferNotOwnedByAlice() (gas: 4960687)
[PASS] test_revert_transferNotOwnedByOperator() (gas: 4962094)
[PASS] test_transferOwnedByOperator() (gas: 5017939)
Test result: ok. 7 passed; 0 failed; finished in 301.00ms
| src/examples/ExampleERC404.sol:ExampleERC404 contract |                 |         |        |         |         |
|-------------------------------------------------------|-----------------|---------|--------|---------|---------|
| Deployment Cost                                       | Deployment Size |         |        |         |         |
| 2121498                                               | 13625           |         |        |         |         |
| Function Name                                         | min             | avg     | median | max     | # calls |
| balanceOf                                             | 653             | 1278    | 653    | 2653    | 16      |
| decimals                                              | 250             | 250     | 250    | 250     | 1       |
| erc20BalanceOf                                        | 606             | 606     | 606    | 606     | 6       |
| erc20TotalSupply                                      | 425             | 425     | 425    | 425     | 2       |
| erc721BalanceOf                                       | 648             | 1348    | 648    | 2648    | 20      |
| erc721TotalSupply                                     | 2337            | 2337    | 2337   | 2337    | 2       |
| erc721TransferExempt                                  | 610             | 1276    | 610    | 2610    | 9       |
| isApprovedForAll                                      | 760             | 1760    | 1760   | 2760    | 8       |
| name                                                  | 3277            | 3277    | 3277   | 3277    | 1       |
| owned                                                 | 2895            | 2895    | 2895   | 2895    | 1       |
| owner                                                 | 2399            | 2399    | 2399   | 2399    | 1       |
| ownerOf                                               | 2726            | 2730    | 2730   | 2734    | 2       |
| setApprovalForAll                                     | 572             | 12021   | 12429  | 22654   | 8       |
| setERC721TransferExempt                               | 914             | 18818   | 25110  | 25110   | 8       |
| symbol                                                | 3276            | 3276    | 3276   | 3276    | 1       |
| totalSupply                                           | 2407            | 2407    | 2407   | 2407    | 2       |
| transfer                                              | 469             | 1091231 | 98571  | 4891597 | 19      |
| transferFrom                                          | 637             | 648     | 637    | 672     | 3       |

| src/mocks/MinimalERC404.sol:MinimalERC404 contract |                 |         |         |         |         |
|----------------------------------------------------|-----------------|---------|---------|---------|---------|
| Deployment Cost                                    | Deployment Size |         |         |         |         |
| 1859077                                            | 10945           |         |         |         |         |
| Function Name                                      | min             | avg     | median  | max     | # calls |
| DOMAIN_SEPARATOR                                   | 324             | 324     | 324     | 324     | 4       |
| allowance                                          | 781             | 2281    | 2781    | 2781    | 4       |
| approve                                            | 597             | 16790   | 23704   | 25267   | 6       |
| balanceOf                                          | 608             | 2008    | 2608    | 2608    | 10      |
| decimals                                           | 272             | 272     | 272     | 272     | 1       |
| erc20BalanceOf                                     | 606             | 606     | 606     | 606     | 17      |
| erc20TotalSupply                                   | 360             | 360     | 360     | 360     | 8       |
| erc721BalanceOf                                    | 582             | 962     | 582     | 2582    | 21      |
| erc721TokensBankedInQueue                          | 463             | 1463    | 1463    | 2463    | 8       |
| erc721TotalSupply                                  | 381             | 1223    | 381     | 2381    | 19      |
| erc721TransferExempt                               | 2610            | 2610    | 2610    | 2610    | 5       |
| getApproved                                        | 590             | 990     | 590     | 2590    | 5       |
| mintERC20                                          | 3579            | 3233540 | 4932579 | 4934579 | 24      |
| name                                               | 3277            | 3277    | 3277    | 3277    | 1       |
| owner                                              | 2421            | 2421    | 2421    | 2421    | 1       |
| ownerOf                                            | 715             | 875     | 760     | 4760    | 239     |
| permit                                             | 684             | 13316   | 844     | 50895   | 4       |
| setApprovalForAll                                  | 24617           | 24617   | 24617   | 24617   | 1       |
| setERC721TransferExempt                            | 25184           | 25184   | 25184   | 25184   | 1       |
| symbol                                             | 3298            | 3298    | 3298    | 3298    | 1       |
| totalSupply                                        | 407             | 407     | 407     | 407     | 9       |
| transfer                                           | 28502           | 67671   | 60204   | 158926  | 9       |
| transferFrom                                       | 928             | 31776   | 31169   | 63839   | 4       |

| test/ERC404.t.sol:SigUtils contract |                 |      |        |      |         |
|-------------------------------------|-----------------|------|--------|------|---------|
| Deployment Cost                     | Deployment Size |      |        |      |         |
| 132196                              | 676             |      |        |      |         |
| Function Name                       | min             | avg  | median | max  | # calls |
| getTypedDataHash                    | 3307            | 3307 | 3307   | 3307 | 4       |
mathdroid commented 8 months ago

@caldereth @0xacme