chore(KarmaNFT): use deploy script in tests

This commit is contained in:
Andrea Franz
2025-03-05 16:29:02 +01:00
committed by r4bbit
parent 96e50c6818
commit 32bb2356dc
4 changed files with 185 additions and 157 deletions

View File

@@ -10,7 +10,7 @@
|-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------|
| fallback | 746 | 133008 | 190833 | 190869 | 502 |
| fallback | 5307 | 133939 | 190833 | 190869 | 502 |
╰-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------╯
╭-----------------------------------------------------+-----------------+---------+---------+---------+---------╮
@@ -27,6 +27,20 @@
| run | 4074161 | 4074161 | 4074161 | 4074161 | 105 |
╰-----------------------------------------------------+-----------------+---------+---------+---------+---------╯
╭-----------------------------------------------------------+-----------------+---------+---------+---------+---------╮
| script/DeployKarmaNFT.s.sol:DeployKarmaNFTScript Contract | | | | | |
+=====================================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|-----------------------------------------------------------+-----------------+---------+---------+---------+---------|
| 4437296 | 21560 | | | | |
|-----------------------------------------------------------+-----------------+---------+---------+---------+---------|
| | | | | | |
|-----------------------------------------------------------+-----------------+---------+---------+---------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-----------------------------------------------------------+-----------------+---------+---------+---------+---------|
| runForTest | 3591100 | 3591100 | 3591100 | 3591100 | 10 |
╰-----------------------------------------------------------+-----------------+---------+---------+---------+---------╯
╭-----------------------------------------------------------------------------+-----------------+---------+---------+---------+---------╮
| script/DeployRewardsStreamerMP.s.sol:DeployRewardsStreamerMPScript Contract | | | | | |
+=======================================================================================================================================+
@@ -41,19 +55,19 @@
| run | 7449061 | 7449061 | 7449061 | 7449061 | 77 |
╰-----------------------------------------------------------------------------+-----------------+---------+---------+---------+---------╯
╭---------------------------------------------------------+-----------------+-----+--------+-----+---------╮
| script/DeploymentConfig.s.sol:DeploymentConfig Contract | | | | | |
+==========================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| 0 | 9183 | | | | |
|---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| | | | | | |
|---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| activeNetworkConfig | 597 | 597 | 597 | 597 | 289 |
╰---------------------------------------------------------+-----------------+-----+--------+-----+---------╯
╭---------------------------------------------------------+-----------------+------+--------+------+---------╮
| script/DeploymentConfig.s.sol:DeploymentConfig Contract | | | | | |
+============================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|---------------------------------------------------------+-----------------+------+--------+------+---------|
| 0 | 9183 | | | | |
|---------------------------------------------------------+-----------------+------+--------+------+---------|
| | | | | | |
|---------------------------------------------------------+-----------------+------+--------+------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|---------------------------------------------------------+-----------------+------+--------+------+---------|
| activeNetworkConfig | 597 | 2744 | 597 | 6597 | 299 |
╰---------------------------------------------------------+-----------------+------+--------+------+---------╯
╭-------------------------------------------------------------------------------+-----------------+---------+---------+---------+---------╮
| script/UpgradeRewardsStreamerMP.s.sol:UpgradeRewardsStreamerMPScript Contract | | | | | |
@@ -88,23 +102,23 @@
|------------------------------+-----------------+--------+--------+--------+---------|
| approve | 419 | 419 | 419 | 419 | 3 |
|------------------------------+-----------------+--------+--------+--------+---------|
| balanceOf | 4019 | 11685 | 10019 | 21019 | 9 |
| balanceOf | 21019 | 21019 | 21019 | 21019 | 9 |
|------------------------------+-----------------+--------+--------+--------+---------|
| getRewardDistributors | 1140 | 3384 | 3384 | 5628 | 6 |
| getRewardDistributors | 5140 | 7384 | 7384 | 9628 | 6 |
|------------------------------+-----------------+--------+--------+--------+---------|
| initialize | 98237 | 98237 | 98237 | 98237 | 105 |
|------------------------------+-----------------+--------+--------+--------+---------|
| mint | 2654 | 58515 | 74916 | 74916 | 18 |
|------------------------------+-----------------+--------+--------+--------+---------|
| mintAllowance | 7286 | 7322 | 7322 | 7359 | 2 |
| mintAllowance | 28286 | 28322 | 28322 | 28359 | 2 |
|------------------------------+-----------------+--------+--------+--------+---------|
| owner | 363 | 1029 | 363 | 2363 | 3 |
| owner | 2363 | 2363 | 2363 | 2363 | 3 |
|------------------------------+-----------------+--------+--------+--------+---------|
| removeRewardDistributor | 2632 | 12148 | 4824 | 28990 | 9 |
|------------------------------+-----------------+--------+--------+--------+---------|
| setReward | 21947 | 151921 | 164145 | 164145 | 289 |
|------------------------------+-----------------+--------+--------+--------+---------|
| totalSupply | 3827 | 6008 | 3827 | 11827 | 11 |
| totalSupply | 24827 | 24827 | 24827 | 24827 | 11 |
|------------------------------+-----------------+--------+--------+--------+---------|
| transfer | 417 | 417 | 417 | 417 | 3 |
|------------------------------+-----------------+--------+--------+--------+---------|
@@ -130,7 +144,7 @@
|-------------------------------------------------+-----------------+-------+--------+-------+---------|
| isApprovedForAll | 510 | 510 | 510 | 510 | 1 |
|-------------------------------------------------+-----------------+-------+--------+-------+---------|
| metadataGenerator | 325 | 325 | 325 | 325 | 1 |
| metadataGenerator | 2325 | 2325 | 2325 | 2325 | 1 |
|-------------------------------------------------+-----------------+-------+--------+-------+---------|
| safeTransferFrom(address,address,uint256) | 485 | 485 | 485 | 485 | 1 |
|-------------------------------------------------+-----------------+-------+--------+-------+---------|
@@ -138,7 +152,7 @@
|-------------------------------------------------+-----------------+-------+--------+-------+---------|
| setApprovalForAll | 475 | 475 | 475 | 475 | 1 |
|-------------------------------------------------+-----------------+-------+--------+-------+---------|
| setMetadataGenerator | 24036 | 26509 | 26509 | 28983 | 2 |
| setMetadataGenerator | 24036 | 27334 | 28983 | 28983 | 3 |
|-------------------------------------------------+-----------------+-------+--------+-------+---------|
| tokenURI | 75449 | 75449 | 75449 | 75449 | 1 |
|-------------------------------------------------+-----------------+-------+--------+-------+---------|
@@ -168,19 +182,19 @@
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| enableEmergencyMode | 2543 | 25291 | 25457 | 25457 | 264 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| getAccountTotalMaxMP | 3191 | 3191 | 3191 | 3191 | 1 |
| getAccountTotalMaxMP | 21191 | 21191 | 21191 | 21191 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| getAccountTotalStakedBalance | 15170 | 15170 | 15170 | 15170 | 1 |
| getAccountTotalStakedBalance | 21170 | 21170 | 21170 | 21170 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| getAccountVaults | 5230 | 5230 | 5230 | 5230 | 4 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| getStakedBalance | 2643 | 2643 | 2643 | 2643 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| getVault | 1970 | 1970 | 1970 | 1970 | 1100 |
| getVault | 17970 | 17970 | 17970 | 17970 | 1100 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| initialize | 94886 | 94886 | 94886 | 94886 | 77 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| lastRewardTime | 407 | 1407 | 1407 | 2407 | 2 |
| lastRewardTime | 2407 | 2407 | 2407 | 2407 | 2 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| leave | 90373 | 90373 | 90373 | 90373 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -188,21 +202,21 @@
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| migrateToVault | 13570 | 72264 | 15777 | 187446 | 3 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| mpBalanceOf | 917 | 2361 | 2316 | 7063 | 12 |
| mpBalanceOf | 4917 | 8695 | 10316 | 10316 | 12 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| mpBalanceOfAccount | 10356 | 10356 | 10356 | 10356 | 1 |
| mpBalanceOfAccount | 32356 | 32356 | 32356 | 32356 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| mpStakedOf | 606 | 759 | 606 | 2606 | 13 |
| mpStakedOf | 2606 | 2606 | 2606 | 2606 | 13 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| proxiableUUID | 342 | 342 | 342 | 342 | 3 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| registerVault | 2539 | 74457 | 74970 | 74970 | 308 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| rewardEndTime | 385 | 1385 | 1385 | 2385 | 2 |
| rewardEndTime | 2385 | 2385 | 2385 | 2385 | 2 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| rewardStartTime | 430 | 1430 | 1430 | 2430 | 2 |
| rewardStartTime | 2430 | 2430 | 2430 | 2430 | 2 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| rewardsBalanceOf | 2340 | 3556 | 3953 | 6340 | 268 |
| rewardsBalanceOf | 20340 | 24496 | 25953 | 26174 | 268 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| setReward | 2508 | 105559 | 107076 | 107076 | 264 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -212,21 +226,21 @@
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| stake | 2703 | 232062 | 224911 | 245989 | 1607 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMP | 805 | 1257 | 1257 | 1710 | 6 |
| totalMP | 6805 | 8257 | 8257 | 9710 | 6 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMPAccrued | 385 | 385 | 385 | 385 | 1108 |
| totalMPAccrued | 2385 | 2385 | 2385 | 2385 | 1108 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMPStaked | 429 | 429 | 429 | 429 | 1111 |
| totalMPStaked | 2429 | 2429 | 2429 | 2429 | 1111 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMaxMP | 407 | 407 | 407 | 407 | 1108 |
| totalMaxMP | 2407 | 2407 | 2407 | 2407 | 1108 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalRewardsAccrued | 407 | 407 | 407 | 407 | 3 |
| totalRewardsAccrued | 2407 | 2407 | 2407 | 2407 | 3 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalRewardsSupply | 998 | 1629 | 1792 | 6737 | 290 |
| totalRewardsSupply | 6737 | 11078 | 11792 | 11903 | 290 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalShares | 662 | 662 | 662 | 662 | 6 |
| totalShares | 4662 | 4662 | 4662 | 4662 | 6 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| totalStaked | 408 | 408 | 408 | 408 | 1115 |
| totalStaked | 2408 | 2408 | 2408 | 2408 | 1115 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| unstake | 50925 | 75961 | 75829 | 83197 | 269 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -238,7 +252,7 @@
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| upgradeToAndCall | 3228 | 3228 | 3228 | 3228 | 1 |
|------------------------------------------------------+-----------------+--------+--------+--------+---------|
| vaultShares | 893 | 1059 | 893 | 2893 | 12 |
| vaultShares | 4893 | 4893 | 4893 | 4893 | 12 |
╰------------------------------------------------------+-----------------+--------+--------+--------+---------╯
╭----------------------------------------+-----------------+--------+--------+--------+---------╮
@@ -258,7 +272,7 @@
|----------------------------------------+-----------------+--------+--------+--------+---------|
| initialize | 99781 | 99781 | 99781 | 99781 | 308 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
| leave | 12161 | 126893 | 67285 | 360844 | 4 |
| leave | 12161 | 126893 | 67285 | 360841 | 4 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
| lock | 12091 | 62406 | 62533 | 104037 | 261 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
@@ -279,21 +293,21 @@
| withdraw | 20754 | 20754 | 20754 | 20754 | 1 |
╰----------------------------------------+-----------------+--------+--------+--------+---------╯
╭----------------------------------------------------+-----------------+------+--------+--------+---------╮
| src/TransparentProxy.sol:TransparentProxy Contract | | | | | |
+=========================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|----------------------------------------------------+-----------------+------+--------+--------+---------|
| 0 | 1520 | | | | |
|----------------------------------------------------+-----------------+------+--------+--------+---------|
| | | | | | |
|----------------------------------------------------+-----------------+------+--------+--------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|----------------------------------------------------+-----------------+------+--------+--------+---------|
| fallback | 708 | 8143 | 874 | 142390 | 7358 |
|----------------------------------------------------+-----------------+------+--------+--------+---------|
| implementation | 346 | 2345 | 2346 | 2346 | 2455 |
╰----------------------------------------------------+-----------------+------+--------+--------+---------╯
╭----------------------------------------------------+-----------------+-------+--------+--------+---------╮
| src/TransparentProxy.sol:TransparentProxy Contract | | | | | |
+==========================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|----------------------------------------------------+-----------------+-------+--------+--------+---------|
| 0 | 1520 | | | | |
|----------------------------------------------------+-----------------+-------+--------+--------+---------|
| | | | | | |
|----------------------------------------------------+-----------------+-------+--------+--------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|----------------------------------------------------+-----------------+-------+--------+--------+---------|
| fallback | 5208 | 16690 | 7374 | 142390 | 7358 |
|----------------------------------------------------+-----------------+-------+--------+--------+---------|
| implementation | 2346 | 2346 | 2346 | 2346 | 2455 |
╰----------------------------------------------------+-----------------+-------+--------+--------+---------╯
╭--------------------------------------------+-----------------+--------+--------+--------+---------╮
| src/VaultFactory.sol:VaultFactory Contract | | | | | |
@@ -322,9 +336,9 @@
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| generate | 54036 | 54036 | 54036 | 54036 | 1 |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| imagePrefix | 1183 | 2183 | 2183 | 3183 | 2 |
| imagePrefix | 3183 | 3183 | 3183 | 3183 | 2 |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| imageSuffix | 1227 | 2227 | 2227 | 3227 | 2 |
| imageSuffix | 3227 | 3227 | 3227 | 3227 | 2 |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| setImageStrings | 25295 | 30634 | 30634 | 35974 | 2 |
╰------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------╯
@@ -344,9 +358,9 @@
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| setURLStrings | 25463 | 30802 | 30802 | 36142 | 2 |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| urlPrefix | 1184 | 1184 | 1184 | 1184 | 1 |
| urlPrefix | 3184 | 3184 | 3184 | 3184 | 1 |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| urlSuffix | 1228 | 1228 | 1228 | 1228 | 1 |
| urlSuffix | 3228 | 3228 | 3228 | 3228 | 1 |
╰------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------╯
╭-------------------------------------------------------------------+-----------------+-------+--------+-------+---------╮
@@ -360,13 +374,13 @@
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| rewardsBalanceOfAccount | 549 | 1882 | 2549 | 2549 | 18 |
| rewardsBalanceOfAccount | 2549 | 2549 | 2549 | 2549 | 18 |
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| setTotalKarmaShares | 43589 | 43589 | 43589 | 43589 | 26 |
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| setUserKarmaShare | 44194 | 44194 | 44194 | 44194 | 6 |
|-------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| totalRewardsSupply | 324 | 990 | 324 | 2324 | 90 |
| totalRewardsSupply | 324 | 1568 | 2324 | 2324 | 90 |
╰-------------------------------------------------------------------+-----------------+-------+--------+-------+---------╯
╭---------------------------------------------------------------------+-----------------+-------+--------+-------+---------╮
@@ -396,7 +410,7 @@
|---------------------------------------------+-----------------+-------+--------+-------+---------|
| approve | 29075 | 32521 | 29267 | 46259 | 1586 |
|---------------------------------------------+-----------------+-------+--------+-------+---------|
| balanceOf | 561 | 1121 | 561 | 2561 | 1900 |
| balanceOf | 2561 | 2561 | 2561 | 2561 | 1900 |
|---------------------------------------------+-----------------+-------+--------+-------+---------|
| mint | 33964 | 38508 | 34156 | 68248 | 1598 |
╰---------------------------------------------+-----------------+-------+--------+-------+---------╯
@@ -412,7 +426,7 @@
|-----------------------------------------------------------------------------+-----------------+--------+--------+--------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-----------------------------------------------------------------------------+-----------------+--------+--------+--------+---------|
| leave | 237 | 164473 | 164473 | 328813 | 333 |
| leave | 234 | 164470 | 164470 | 328810 | 333 |
|-----------------------------------------------------------------------------+-----------------+--------+--------+--------+---------|
| proxiableUUID | 330 | 330 | 330 | 330 | 1 |
╰-----------------------------------------------------------------------------+-----------------+--------+--------+--------+---------╯

View File

@@ -1,123 +1,123 @@
CompoundTest:test_RevertWhenInsufficientMPBalance() (gas: 382543)
EmergencyExitTest:test_CannotEnableEmergencyModeTwice() (gas: 93554)
EmergencyExitTest:test_CannotLeaveBeforeEmergencyMode() (gas: 355447)
EmergencyExitTest:test_EmergencyExitBasic() (gas: 448158)
EmergencyExitTest:test_EmergencyExitMultipleUsers() (gas: 771752)
EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 453687)
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 450608)
EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 438644)
EmergencyExitTest:test_EmergencyExitBasic() (gas: 549158)
EmergencyExitTest:test_EmergencyExitMultipleUsers() (gas: 986752)
EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 503687)
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 469608)
EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 504144)
EmergencyExitTest:test_OnlyOwnerCanEnableEmergencyMode() (gas: 39133)
FuzzTests:testFuzz_AccrueMP(uint256,uint256,uint16) (runs: 1000, μ: 524183, ~: 518482)
FuzzTests:testFuzz_EmergencyExit(uint256,uint256) (runs: 1000, μ: 513711, ~: 505167)
FuzzTests:testFuzz_Rewards(uint256,uint256,uint256,uint16,uint16) (runs: 1000, μ: 612169, ~: 613434)
FuzzTests:testFuzz_Stake(uint256,uint256) (runs: 1000, μ: 407065, ~: 398521)
FuzzTests:testFuzz_Unstake(uint256,uint256,uint16,uint256) (runs: 1000, μ: 533831, ~: 533495)
IntegrationTest:testStakeFoo() (gas: 1424855)
KarmaMintAllowanceTest:testAddKarmaDistributorOnlyOwner() (gas: 364780)
KarmaMintAllowanceTest:testBalanceOf() (gas: 443836)
KarmaMintAllowanceTest:testBalanceOfWithNoSystemTotalKarma() (gas: 49501)
KarmaMintAllowanceTest:testMintAllowance_Available() (gas: 355546)
KarmaMintAllowanceTest:testMintAllowance_NotAvailable() (gas: 355551)
KarmaMintAllowanceTest:testMintOnlyOwner() (gas: 397793)
KarmaMintAllowanceTest:testMint_Ok() (gas: 425459)
FuzzTests:testFuzz_AccrueMP(uint256,uint256,uint16) (runs: 1000, μ: 604183, ~: 598482)
FuzzTests:testFuzz_EmergencyExit(uint256,uint256) (runs: 1000, μ: 608711, ~: 600167)
FuzzTests:testFuzz_Rewards(uint256,uint256,uint256,uint16,uint16) (runs: 1000, μ: 662753, ~: 665434)
FuzzTests:testFuzz_Stake(uint256,uint256) (runs: 1000, μ: 487065, ~: 478521)
FuzzTests:testFuzz_Unstake(uint256,uint256,uint16,uint256) (runs: 1000, μ: 613831, ~: 613495)
IntegrationTest:testStakeFoo() (gas: 2474855)
KarmaMintAllowanceTest:testAddKarmaDistributorOnlyOwner() (gas: 373280)
KarmaMintAllowanceTest:testBalanceOf() (gas: 467836)
KarmaMintAllowanceTest:testBalanceOfWithNoSystemTotalKarma() (gas: 69501)
KarmaMintAllowanceTest:testMintAllowance_Available() (gas: 383546)
KarmaMintAllowanceTest:testMintAllowance_NotAvailable() (gas: 383551)
KarmaMintAllowanceTest:testMintOnlyOwner() (gas: 449793)
KarmaMintAllowanceTest:testMint_Ok() (gas: 485459)
KarmaMintAllowanceTest:testMint_RevertWithAllowanceExceeded() (gas: 405516)
KarmaMintAllowanceTest:testRemoveKarmaDistributorOnlyOwner() (gas: 88855)
KarmaMintAllowanceTest:testRemoveKarmaDistributorOnlyOwner() (gas: 97355)
KarmaMintAllowanceTest:testRemoveUnknownKarmaDistributor() (gas: 41416)
KarmaMintAllowanceTest:testTotalSupply() (gas: 352013)
KarmaMintAllowanceTest:testTransfersNotAllowed() (gas: 40219)
KarmaMintAllowanceTest:testTotalSupply() (gas: 380013)
KarmaMintAllowanceTest:testTransfersNotAllowed() (gas: 61719)
KarmaNFTTest:testApproveNotAllowed() (gas: 10507)
KarmaNFTTest:testGetApproved() (gas: 10531)
KarmaNFTTest:testIsApprovedForAll() (gas: 10705)
KarmaNFTTest:testSafeTransferNotAllowed() (gas: 10688)
KarmaNFTTest:testSafeTransferWithDataNotAllowed() (gas: 10884)
KarmaNFTTest:testSetApprovalForAllNotAllowed() (gas: 8519)
KarmaNFTTest:testSetMetadataGenerator() (gas: 984525)
KarmaNFTTest:testSetMetadataGenerator() (gas: 986525)
KarmaNFTTest:testSetMetadataGeneratorRevert() (gas: 981085)
KarmaNFTTest:testTokenURI() (gas: 110636)
KarmaNFTTest:testTokenURI() (gas: 1086310)
KarmaNFTTest:testTransferNotAllowed() (gas: 10701)
KarmaOwnershipTest:testAddKarmaDistributorOnlyOwner() (gas: 364768)
KarmaOwnershipTest:testBalanceOf() (gas: 443806)
KarmaOwnershipTest:testBalanceOfWithNoSystemTotalKarma() (gas: 49479)
KarmaOwnershipTest:testAddKarmaDistributorOnlyOwner() (gas: 373268)
KarmaOwnershipTest:testBalanceOf() (gas: 467806)
KarmaOwnershipTest:testBalanceOfWithNoSystemTotalKarma() (gas: 69479)
KarmaOwnershipTest:testInitialOwner() (gas: 17601)
KarmaOwnershipTest:testMintOnlyOwner() (gas: 397757)
KarmaOwnershipTest:testOwnershipTransfer() (gas: 98047)
KarmaOwnershipTest:testRemoveKarmaDistributorOnlyOwner() (gas: 88820)
KarmaOwnershipTest:testMintOnlyOwner() (gas: 449757)
KarmaOwnershipTest:testOwnershipTransfer() (gas: 124047)
KarmaOwnershipTest:testRemoveKarmaDistributorOnlyOwner() (gas: 97320)
KarmaOwnershipTest:testRemoveUnknownKarmaDistributor() (gas: 41398)
KarmaOwnershipTest:testTotalSupply() (gas: 351983)
KarmaOwnershipTest:testTransfersNotAllowed() (gas: 40196)
KarmaTest:testAddKarmaDistributorOnlyOwner() (gas: 364768)
KarmaTest:testBalanceOf() (gas: 443806)
KarmaTest:testBalanceOfWithNoSystemTotalKarma() (gas: 49545)
KarmaTest:testMintOnlyOwner() (gas: 397757)
KarmaTest:testRemoveKarmaDistributorOnlyOwner() (gas: 88798)
KarmaOwnershipTest:testTotalSupply() (gas: 379983)
KarmaOwnershipTest:testTransfersNotAllowed() (gas: 61696)
KarmaTest:testAddKarmaDistributorOnlyOwner() (gas: 373268)
KarmaTest:testBalanceOf() (gas: 467806)
KarmaTest:testBalanceOfWithNoSystemTotalKarma() (gas: 69545)
KarmaTest:testMintOnlyOwner() (gas: 449757)
KarmaTest:testRemoveKarmaDistributorOnlyOwner() (gas: 97298)
KarmaTest:testRemoveUnknownKarmaDistributor() (gas: 41398)
KarmaTest:testTotalSupply() (gas: 351983)
KarmaTest:testTransfersNotAllowed() (gas: 40241)
LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 9745239)
KarmaTest:testTotalSupply() (gas: 379983)
KarmaTest:testTransfersNotAllowed() (gas: 61741)
LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 9895239)
LeaveTest:test_RevertWhenStakeManagerIsTrusted() (gas: 352541)
LeaveTest:test_TrustNewStakeManager() (gas: 9799393)
LeaveTest:test_TrustNewStakeManager() (gas: 9810393)
LockTest:test_LockFailsWithInvalidPeriod(uint256) (runs: 1000, μ: 404121, ~: 404145)
LockTest:test_LockFailsWithNoStake() (gas: 109576)
LockTest:test_LockFailsWithZero() (gas: 364791)
LockTest:test_LockWithoutPriorLock() (gas: 468897)
LockTest:test_LockWithoutPriorLock() (gas: 552397)
LockTest:test_RevertWhenVaultToLockIsEmpty() (gas: 109534)
MaliciousUpgradeTest:test_UpgradeStackOverflowStakeManager() (gas: 2077682)
MaliciousUpgradeTest:test_UpgradeStackOverflowStakeManager() (gas: 2139179)
MathTest:test_CalcAbsoluteMaxTotalMP() (gas: 5196)
MathTest:test_CalcAccrueMP() (gas: 8511)
MathTest:test_CalcBonusMP() (gas: 19112)
MathTest:test_CalcBonusMP() (gas: 30612)
MathTest:test_CalcInitialMP() (gas: 5728)
MathTest:test_CalcMaxAccruedMP() (gas: 4842)
MathTest:test_CalcMaxTotalMP() (gas: 19852)
MultipleVaultsStakeTest:test_StakeMultipleVaults() (gas: 860093)
MathTest:test_CalcMaxTotalMP() (gas: 31352)
MultipleVaultsStakeTest:test_StakeMultipleVaults() (gas: 977093)
NFTMetadataGeneratorSVGTest:testGenerateMetadata() (gas: 91375)
NFTMetadataGeneratorSVGTest:testSetImageStrings() (gas: 60081)
NFTMetadataGeneratorSVGTest:testSetImageStrings() (gas: 77581)
NFTMetadataGeneratorSVGTest:testSetImageStringsRevert() (gas: 35891)
NFTMetadataGeneratorURLTest:testGenerateMetadata() (gas: 108068)
NFTMetadataGeneratorURLTest:testSetBaseURL() (gas: 50631)
NFTMetadataGeneratorURLTest:testSetBaseURL() (gas: 59131)
NFTMetadataGeneratorURLTest:testSetBaseURLRevert() (gas: 36066)
RewardsStreamerMP_RewardsTest:testRewardsBalanceOf() (gas: 1325610)
RewardsStreamerMP_RewardsTest:testSetRewards() (gas: 224584)
RewardsStreamerMP_RewardsTest:testRewardsBalanceOf() (gas: 2769110)
RewardsStreamerMP_RewardsTest:testSetRewards() (gas: 275584)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadAmount() (gas: 61186)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsBadDuration() (gas: 100963)
RewardsStreamerMP_RewardsTest:testSetRewards_RevertsNotAuthorized() (gas: 39344)
RewardsStreamerMP_RewardsTest:testTotalRewardsSupply() (gas: 760524)
StakeTest:test_StakeMultipleAccounts() (gas: 597152)
StakeTest:test_StakeMultipleAccountsAndRewards() (gas: 605600)
StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 1033544)
StakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 607698)
StakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 629708)
StakeTest:test_StakeOneAccount() (gas: 336772)
StakeTest:test_StakeOneAccountAndRewards() (gas: 345216)
StakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 612127)
StakeTest:test_StakeOneAccountReachingMPLimit() (gas: 600194)
StakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 354799)
StakeTest:test_StakeOneAccountWithMinLockUp() (gas: 355373)
StakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 355462)
StakeVaultMigrationTest:testMigrateToVault() (gas: 953396)
RewardsStreamerMP_RewardsTest:testTotalRewardsSupply() (gas: 1295024)
StakeTest:test_StakeMultipleAccounts() (gas: 715652)
StakeTest:test_StakeMultipleAccountsAndRewards() (gas: 770600)
StakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 1439544)
StakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 651698)
StakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 680208)
StakeTest:test_StakeOneAccount() (gas: 414772)
StakeTest:test_StakeOneAccountAndRewards() (gas: 469716)
StakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 828627)
StakeTest:test_StakeOneAccountReachingMPLimit() (gas: 819194)
StakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 398799)
StakeTest:test_StakeOneAccountWithMinLockUp() (gas: 399373)
StakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 399462)
StakeVaultMigrationTest:testMigrateToVault() (gas: 1241396)
StakeVaultMigrationTest:test_RevertWhenMigrationVaultNotEmpty() (gas: 650773)
StakeVaultMigrationTest:test_RevertWhenNotOwnerOfMigrationVault() (gas: 68131)
StakingTokenTest:testStakeToken() (gas: 13144)
TrustedCodehashAccessTest:test_RevertWhenProxyCloneCodehashNotTrusted() (gas: 2095134)
UnstakeTest:test_StakeMultipleAccounts() (gas: 597196)
UnstakeTest:test_StakeMultipleAccountsAndRewards() (gas: 605644)
UnstakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 1033521)
UnstakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 607675)
UnstakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 629685)
UnstakeTest:test_StakeOneAccount() (gas: 336772)
UnstakeTest:test_StakeOneAccountAndRewards() (gas: 345260)
UnstakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 612104)
UnstakeTest:test_StakeOneAccountReachingMPLimit() (gas: 600238)
UnstakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 354821)
UnstakeTest:test_StakeOneAccountWithMinLockUp() (gas: 355395)
UnstakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 355440)
UnstakeTest:test_UnstakeBonusMPAndAccuredMP() (gas: 639714)
UnstakeTest:test_UnstakeMultipleAccounts() (gas: 837652)
UnstakeTest:test_UnstakeMultipleAccountsAndRewards() (gas: 951261)
UnstakeTest:test_UnstakeOneAccount() (gas: 572477)
UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 597636)
UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 493714)
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 627336)
UnstakeTest:test_StakeMultipleAccounts() (gas: 715696)
UnstakeTest:test_StakeMultipleAccountsAndRewards() (gas: 770644)
UnstakeTest:test_StakeMultipleAccountsMPIncreasesMaxMPDoesNotChange() (gas: 1439521)
UnstakeTest:test_StakeMultipleAccountsWithMinLockUp() (gas: 651675)
UnstakeTest:test_StakeMultipleAccountsWithRandomLockUp() (gas: 680185)
UnstakeTest:test_StakeOneAccount() (gas: 414772)
UnstakeTest:test_StakeOneAccountAndRewards() (gas: 469760)
UnstakeTest:test_StakeOneAccountMPIncreasesMaxMPDoesNotChange() (gas: 828604)
UnstakeTest:test_StakeOneAccountReachingMPLimit() (gas: 819238)
UnstakeTest:test_StakeOneAccountWithMaxLockUp() (gas: 398821)
UnstakeTest:test_StakeOneAccountWithMinLockUp() (gas: 399395)
UnstakeTest:test_StakeOneAccountWithRandomLockUp() (gas: 399440)
UnstakeTest:test_UnstakeBonusMPAndAccuredMP() (gas: 824214)
UnstakeTest:test_UnstakeMultipleAccounts() (gas: 1094152)
UnstakeTest:test_UnstakeMultipleAccountsAndRewards() (gas: 1386761)
UnstakeTest:test_UnstakeOneAccount() (gas: 794477)
UnstakeTest:test_UnstakeOneAccountAndAccruedMP() (gas: 776636)
UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 706714)
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 778836)
UpgradeTest:test_RevertWhenNotOwner() (gas: 3629043)
UpgradeTest:test_UpgradeStakeManager() (gas: 9635364)
VaultRegistrationTest:test_VaultRegistration() (gas: 62962)
WithdrawTest:test_CannotWithdrawStakedFunds() (gas: 368251)
UpgradeTest:test_UpgradeStakeManager() (gas: 9721364)
VaultRegistrationTest:test_VaultRegistration() (gas: 89962)
WithdrawTest:test_CannotWithdrawStakedFunds() (gas: 392751)

View File

@@ -8,15 +8,24 @@ import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy
import { KarmaNFT } from "../src/KarmaNFT.sol";
import { NFTMetadataGeneratorSVG } from "../src/nft-metadata-generators/NFTMetadataGeneratorSVG.sol";
import { INFTMetadataGenerator } from "../src/interfaces/INFTMetadataGenerator.sol";
contract DeployKarmaNFTScript is BaseScript {
function run() public returns (KarmaNFT, DeploymentConfig) {
DeploymentConfig deploymentConfig = new DeploymentConfig(broadcaster);
(address deployer,,) = deploymentConfig.activeNetworkConfig();
function run() public returns (KarmaNFT, INFTMetadataGenerator, DeploymentConfig) {
address karmaAddress = vm.envAddress("KARMA_ADDRESS");
require(karmaAddress != address(0), "KARMA_ADDRESS is not set");
return _run(karmaAddress);
}
function runForTest(address karmaAddress) public returns (KarmaNFT, INFTMetadataGenerator, DeploymentConfig) {
return _run(karmaAddress);
}
function _run(address karmaAddress) public returns (KarmaNFT, INFTMetadataGenerator, DeploymentConfig) {
DeploymentConfig deploymentConfig = new DeploymentConfig(broadcaster);
(address deployer,,) = deploymentConfig.activeNetworkConfig();
vm.startBroadcast(deployer);
// Deploy NFT metadata generator
@@ -27,6 +36,6 @@ contract DeployKarmaNFTScript is BaseScript {
vm.stopBroadcast();
return (karmaNFT, deploymentConfig);
return (karmaNFT, INFTMetadataGenerator(metadataGenerator), deploymentConfig);
}
}

View File

@@ -6,18 +6,20 @@ import { Base64 } from "@openzeppelin/contracts/utils/Base64.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { MockToken } from "./mocks/MockToken.sol";
import { KarmaNFT } from "../src/KarmaNFT.sol";
import { DeployKarmaNFTScript } from "../script/DeployKarmaNFT.s.sol";
import { INFTMetadataGenerator } from "../src/interfaces/INFTMetadataGenerator.sol";
import { MockMetadataGenerator } from "./mocks/MockMetadataGenerator.sol";
contract KarmaNFTTest is Test {
MockToken public erc20Token;
MockMetadataGenerator public metadataGenerator;
INFTMetadataGenerator public metadataGenerator;
KarmaNFT public nft;
address public alice = makeAddr("alice");
function setUp() public {
erc20Token = new MockToken("Test", "TEST");
metadataGenerator = new MockMetadataGenerator("https://test.local/");
((nft, metadataGenerator,)) = new DeployKarmaNFTScript().runForTest(address(erc20Token));
nft = new KarmaNFT(address(erc20Token), address(metadataGenerator));
address[1] memory users = [alice];
@@ -30,7 +32,10 @@ contract KarmaNFTTest is Test {
return uint256(uint160(addr));
}
function testTokenURI() public view {
function testTokenURI() public {
INFTMetadataGenerator generator = new MockMetadataGenerator("https://test.local/");
nft.setMetadataGenerator(address(generator));
bytes memory expectedMetadata = abi.encodePacked(
"{\"name\":\"KarmaNFT 0x328809bc894f92807417d2dad6b7c998c1afdac6\",",
// solhint-disable-next-line