Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
fedealconada committed Jan 4, 2024
1 parent 1a879e5 commit e8bfeca
Show file tree
Hide file tree
Showing 14 changed files with 364 additions and 337 deletions.
80 changes: 40 additions & 40 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
DeveloperDeployTest:testUp() (gas: 24279)
ETHPriceIsRightTest:testAnyoneCanChangeGuessBeforeEnd() (gas: 131807)
ETHPriceIsRightTest:testAnyoneCanEnterGuessBeforeEnd() (gas: 127341)
ETHPriceIsRightTest:testFailCannotEnterGuessAfterTime() (gas: 11629)
ETHPriceIsRightTest:test_RevertWhen_CannotEnterGuessAfterTime() (gas: 11629)
ETHPriceIsRightTest:testGuessCalculations() (gas: 156151)
ETHPriceIsRightTest:testUp() (gas: 16852)
EngenCreditsTest:testCanBurnAfterSettingFlag() (gas: 70853)
EngenCreditsTest:testCanTransferAfterSettingFlag() (gas: 100027)
EngenCreditsTest:testFailOthersCannotUpgrade() (gas: 2102028)
EngenCreditsTest:test_RevertWhen_OthersCannotUpgrade() (gas: 2102028)
EngenCreditsTest:testNobodyCanBurn() (gas: 70679)
EngenCreditsTest:testNobodyCanTransfer() (gas: 71888)
EngenCreditsTest:testOthersCannotMint() (gas: 25978)
Expand All @@ -18,12 +18,12 @@ EngenCreditsTest:testWalletCanGetPointsWithOverride() (gas: 657489)
EngenCreditsTest:testWalletCannotGetPointsTwice() (gas: 718288)
FaucetTest:testClaim() (gas: 81023)
FaucetTest:testClaimOnBehalf() (gas: 115966)
FaucetTest:testFailIfClaimedTwice() (gas: 77198)
FaucetTest:testFailOwnerCannotStartWithoutAmount() (gas: 19407)
FaucetTest:testFailStartFaucetByOthers() (gas: 16870)
FaucetTest:test_RevertWhen_IfClaimedTwice() (gas: 77198)
FaucetTest:test_RevertWhen_OwnerCannotStartWithoutAmount() (gas: 19407)
FaucetTest:test_RevertWhen_StartFaucetByOthers() (gas: 16870)
FaucetTest:testOwnerCanStartFaucet() (gas: 42651)
FaucetTest:testUp() (gas: 6294)
KYCViewerTest:testFailOthersCannotUpgradeFactory() (gas: 1029248)
KYCViewerTest:test_RevertWhen_OthersCannotUpgradeFactory() (gas: 1029248)
KYCViewerTest:testIsKYCBothOwnerAndWallet() (gas: 82707)
KYCViewerTest:testOwnerCanUpgradeViewer() (gas: 1065414)
KYCViewerTest:testUp() (gas: 40633)
Expand All @@ -34,14 +34,14 @@ KintoIDTest:testBurnFailsWithoutMinting() (gas: 26911)
KintoIDTest:testBurnKYC() (gas: 250194)
KintoIDTest:testBurningTwiceFails() (gas: 254209)
KintoIDTest:testDappSignature() (gas: 166)
KintoIDTest:testFailOnlyProviderCanMonitor() (gas: 48382)
KintoIDTest:testFailOthersCannotUpgrade() (gas: 3885070)
KintoIDTest:testFailProviderCanAddTraitUnknownUser() (gas: 22719)
KintoIDTest:testFailTransfersAreDisabled() (gas: 297354)
KintoIDTest:testFailUserCannotAddSanction() (gas: 47795)
KintoIDTest:testFailUserCannotAddTrait() (gas: 47797)
KintoIDTest:testFailUserCannotRemoveSanction() (gas: 22608)
KintoIDTest:testFailUserCannotRemoveTrait() (gas: 326993)
KintoIDTest:test_RevertWhen_OnlyProviderCanMonitor() (gas: 48382)
KintoIDTest:test_RevertWhen_OthersCannotUpgrade() (gas: 3885070)
KintoIDTest:test_RevertWhen_ProviderCanAddTraitUnknownUser() (gas: 22719)
KintoIDTest:test_RevertWhen_TransfersAreDisabled() (gas: 297354)
KintoIDTest:test_RevertWhen_UserCannotAddSanction() (gas: 47795)
KintoIDTest:test_RevertWhen_UserCannotAddTrait() (gas: 47797)
KintoIDTest:test_RevertWhen_UserCannotRemoveSanction() (gas: 22608)
KintoIDTest:test_RevertWhen_UserCannotRemoveTrait() (gas: 326993)
KintoIDTest:testIsSanctionsMonitored() (gas: 28227)
KintoIDTest:testMintCompanyKYC() (gas: 284477)
KintoIDTest:testMintIndividualKYC() (gas: 282508)
Expand All @@ -60,9 +60,9 @@ KintoIDTest:testSettingTraitsAndSanctions() (gas: 317512)
KintoIDTest:testUp() (gas: 17956)
KintoWalletFactoryTest:testAllWalletsUpgrade() (gas: 3517833)
KintoWalletFactoryTest:testDeployCustomContract() (gas: 136473)
KintoWalletFactoryTest:testFailCreateWalletThroughDeploy() (gas: 51285)
KintoWalletFactoryTest:testFailOthersCannotUpgradeFactory() (gas: 2636897)
KintoWalletFactoryTest:testFailOthersCannotUpgradeWallets() (gas: 3498853)
KintoWalletFactoryTest:test_RevertWhen_CreateWalletThroughDeploy() (gas: 51285)
KintoWalletFactoryTest:test_RevertWhen_OthersCannotUpgradeFactory() (gas: 2636897)
KintoWalletFactoryTest:test_RevertWhen_OthersCannotUpgradeWallets() (gas: 3498853)
KintoWalletFactoryTest:testOwnerCanUpgradeFactory() (gas: 2673030)
KintoWalletFactoryTest:testRandomSignerCannotFundWallet() (gas: 77154)
KintoWalletFactoryTest:testSignerCanFundWallet() (gas: 71109)
Expand All @@ -76,26 +76,26 @@ KintoWalletTest:testApproveAndRevokeTokens() (gas: 580610)
KintoWalletTest:testApproveTokens() (gas: 530958)
KintoWalletTest:testChangingPolicyWithThreeSigners() (gas: 442028)
KintoWalletTest:testChangingPolicyWithTwoSigners() (gas: 413114)
KintoWalletTest:testFailApproveTokensWithoutWhitelist() (gas: 157159)
KintoWalletTest:testFailCallingApproveDirectly() (gas: 625818)
KintoWalletTest:testFailChangingPolicyWithoutRightSigners() (gas: 174419)
KintoWalletTest:testFailDirectCall() (gas: 65568)
KintoWalletTest:testFailMultipleTransactionsExecuteBatchPaymasterRefuses() (gas: 363188)
KintoWalletTest:testFailMultisigTransaction() (gas: 605529)
KintoWalletTest:testFailMultisigTransactionWhen2OutOf3Signers() (gas: 620528)
KintoWalletTest:testFailOthersCannotUpgrade() (gas: 3151175)
KintoWalletTest:testFailOwnerCannotUpgrade() (gas: 3467167)
KintoWalletTest:testFailRecoverNotEnoughTime() (gas: 430100)
KintoWalletTest:testFailRecoverNotRecoverer() (gas: 79216)
KintoWalletTest:testFailRecoverWithoutBurningOldOwner() (gas: 368060)
KintoWalletTest:testFailRecoverWithoutMintingNewOwner() (gas: 218345)
KintoWalletTest:testFailSendingTransactionDirectly() (gas: 184911)
KintoWalletTest:testFailSettingAppKeyNoWhitelist() (gas: 389794)
KintoWalletTest:testFailTransactionViaPaymasterNoapproval() (gas: 457146)
KintoWalletTest:testFailWithDuplicateSigner() (gas: 379042)
KintoWalletTest:testFailWithEmptyArray() (gas: 383567)
KintoWalletTest:testFailWithManyOwners() (gas: 379274)
KintoWalletTest:testFailWithoutKYCSigner() (gas: 377318)
KintoWalletTest:test_RevertWhen_ApproveTokensWithoutWhitelist() (gas: 157159)
KintoWalletTest:test_RevertWhen_CallingApproveDirectly() (gas: 625818)
KintoWalletTest:test_RevertWhen_ChangingPolicyWithoutRightSigners() (gas: 174419)
KintoWalletTest:test_RevertWhen_DirectCall() (gas: 65568)
KintoWalletTest:test_RevertWhen_MultipleTransactionsExecuteBatchPaymasterRefuses() (gas: 363188)
KintoWalletTest:test_RevertWhen_MultisigTransaction() (gas: 605529)
KintoWalletTest:test_RevertWhen_MultisigTransactionWhen2OutOf3Signers() (gas: 620528)
KintoWalletTest:test_RevertWhen_OthersCannotUpgrade() (gas: 3151175)
KintoWalletTest:test_RevertWhen_OwnerCannotUpgrade() (gas: 3467167)
KintoWalletTest:test_RevertWhen_RecoverNotEnoughTime() (gas: 430100)
KintoWalletTest:test_RevertWhen_RecoverNotRecoverer() (gas: 79216)
KintoWalletTest:test_RevertWhen_RecoverWithoutBurningOldOwner() (gas: 368060)
KintoWalletTest:test_RevertWhen_RecoverWithoutMintingNewOwner() (gas: 218345)
KintoWalletTest:test_RevertWhen_SendingTransactionDirectly() (gas: 184911)
KintoWalletTest:test_RevertWhen_SettingAppKeyNoWhitelist() (gas: 389794)
KintoWalletTest:test_RevertWhen_TransactionViaPaymasterNoapproval() (gas: 457146)
KintoWalletTest:test_RevertWhen_WithDuplicateSigner() (gas: 379042)
KintoWalletTest:test_RevertWhen_WithEmptyArray() (gas: 383567)
KintoWalletTest:test_RevertWhen_WithManyOwners() (gas: 379274)
KintoWalletTest:test_RevertWhen_WithoutKYCSigner() (gas: 377318)
KintoWalletTest:testMultipleTransactionsExecuteBatchPaymaster() (gas: 534232)
KintoWalletTest:testMultipleTransactionsViaPaymaster() (gas: 756771)
KintoWalletTest:testMultisigTransaction() (gas: 859779)
Expand All @@ -108,9 +108,9 @@ KintoWalletTest:testTransactionViaPaymaster() (gas: 694244)
KintoWalletTest:testUp() (gas: 32038)
KintoWalletTest:testWalletOwnersAreWhitelisted() (gas: 39988)
SponsorPaymasterExploitTest:testExploit() (gas: 283756)
SponsorPaymasterTest:testFailOthersCannotUpgrade() (gas: 2205926)
SponsorPaymasterTest:testFailUserCanDepositStakeAndWithdrawWithoutRoll() (gas: 129377)
SponsorPaymasterTest:testFailUserCanWithdrawAllInEmergency() (gas: 137198)
SponsorPaymasterTest:test_RevertWhen_OthersCannotUpgrade() (gas: 2205926)
SponsorPaymasterTest:test_RevertWhen_UserCanDepositStakeAndWithdrawWithoutRoll() (gas: 129377)
SponsorPaymasterTest:test_RevertWhen_UserCanWithdrawAllInEmergency() (gas: 137198)
SponsorPaymasterTest:testOwnerCanDepositStakeAndWithdraw() (gas: 95286)
SponsorPaymasterTest:testOwnerCanUpgrade() (gas: 2242110)
SponsorPaymasterTest:testOwnerCanWithdrawAllInEmergency() (gas: 123988)
Expand Down
2 changes: 1 addition & 1 deletion test/DeployTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract DeveloperDeployTest is Create2Helper, UserOp, AATestScaffolding {
vm.startPrank(address(1));
_owner.transfer(1e18);
vm.stopPrank();
deployAAScaffolding(_owner, _kycProvider, _recoverer);
deployAAScaffolding(_owner, 1, _kycProvider, _recoverer);
vm.startPrank(_owner);

address created = _walletFactory.deployContract(0, abi.encodePacked(type(Counter).creationCode), bytes32(0));
Expand Down
4 changes: 3 additions & 1 deletion test/ETHPriceIsRight.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ contract ETHPriceIsRightTest is Test {
assertEq(_priceIsRight.avgGuess(), 3000 ether);
}

function testFailCannotEnterGuessAfterTime() public {
function test_RevertWhen_CannotEnterGuessAfterTime() public {
vm.startPrank(_user);
vm.warp(_priceIsRight.END_ENTER_TIMESTAMP() + 1);

vm.expectRevert("You cannot enter guesses anymore");
_priceIsRight.enterGuess(2000 ether);
vm.stopPrank();
}
Expand Down
18 changes: 8 additions & 10 deletions test/EngenCredits.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ contract EngenCreditsTest is Create2Helper, UserOp, AATestScaffolding {
vm.startPrank(address(1));
_owner.transfer(1e18);
vm.stopPrank();
deployAAScaffolding(_owner, _kycProvider, _recoverer);
_setPaymasterForContract(address(_engenCredits));
_setPaymasterForContract(address(_kintoWalletv1));
deployAAScaffolding(_owner, 1, _kycProvider, _recoverer);
_fundPaymasterForContract(address(_engenCredits));
_fundPaymasterForContract(address(_kintoWalletv1));
}

function testUp() public {
Expand All @@ -52,20 +52,18 @@ contract EngenCreditsTest is Create2Helper, UserOp, AATestScaffolding {
vm.startPrank(_owner);
EngenCreditsV2 _implementationV2 = new EngenCreditsV2();
_engenCredits.upgradeTo(address(_implementationV2));
// re-wrap the _proxy

// ensure that the implementation has been upgraded
_engenCreditsV2 = EngenCreditsV2(address(_engenCredits));
assertEq(_engenCreditsV2.newFunction(), 1);
vm.stopPrank();
}

function testFailOthersCannotUpgrade() public {
vm.startPrank(_recoverer);
function test_RevertWhen_OthersCannotUpgrade() public {
EngenCreditsV2 _implementationV2 = new EngenCreditsV2();

vm.expectRevert("Ownable: caller is not the owner");
_engenCredits.upgradeTo(address(_implementationV2));
// re-wrap the _proxy
_engenCreditsV2 = EngenCreditsV2(address(_engenCredits));
assertEq(_engenCreditsV2.newFunction(), 1);
vm.stopPrank();
}

/* ============ Token Tests ============ */
Expand Down
6 changes: 3 additions & 3 deletions test/Faucet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ contract FaucetTest is Test {
vm.stopPrank();
}

function testFailOwnerCannotStartWithoutAmount() public {
function test_RevertWhen_OwnerCannotStartWithoutAmount() public {
vm.startPrank(_owner);
_faucet.startFaucet{value: 0.1 ether}();
vm.stopPrank();
}

function testFailStartFaucetByOthers() public {
function test_RevertWhen_StartFaucetByOthers() public {
vm.startPrank(_user);
_faucet.startFaucet{value: 1 ether}();
vm.stopPrank();
Expand All @@ -78,7 +78,7 @@ contract FaucetTest is Test {
vm.stopPrank();
}

function testFailIfClaimedTwice() public {
function test_RevertWhen_IfClaimedTwice() public {
vm.startPrank(_owner);
_faucet.startFaucet{value: 1 ether}();
vm.stopPrank();
Expand Down
4 changes: 2 additions & 2 deletions test/KYCViewer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ contract KYCViewerTest is Create2Helper, UserOp, AATestScaffolding {
vm.startPrank(address(1));
_owner.transfer(1e18);
vm.stopPrank();
deployAAScaffolding(_owner, _kycProvider, _recoverer);
deployAAScaffolding(_owner, 1, _kycProvider, _recoverer);
vm.startPrank(_owner);
_implkycViewer = new KYCViewer{salt: 0}(address(_walletFactory));
// deploy _proxy contract and point it to _implementation
Expand Down Expand Up @@ -90,7 +90,7 @@ contract KYCViewerTest is Create2Helper, UserOp, AATestScaffolding {
vm.stopPrank();
}

function testFailOthersCannotUpgradeFactory() public {
function test_RevertWhen_OthersCannotUpgradeFactory() public {
KYCViewerV2 _implementationV2 = new KYCViewerV2(address(_walletFactory));
_kycViewer.upgradeTo(address(_implementationV2));
// re-wrap the _proxy
Expand Down
2 changes: 1 addition & 1 deletion test/KintoEntryPoint.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract KintoEntryPointTest is AATestScaffolding, UserOp {
vm.startPrank(address(1));
_owner.transfer(1e18);
vm.stopPrank();
deployAAScaffolding(_owner, _kycProvider, _recoverer);
deployAAScaffolding(_owner, 1, _kycProvider, _recoverer);
}

function testUp() public {
Expand Down
31 changes: 19 additions & 12 deletions test/KintoID.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

import "forge-std/Test.sol";
import "forge-std/console.sol";
Expand Down Expand Up @@ -63,18 +64,24 @@ contract KintoIDTest is KYCSignature {
vm.startPrank(_owner);
KintoIDv2 _implementationV2 = new KintoIDv2();
_kintoIDv1.upgradeTo(address(_implementationV2));
// re-wrap the _proxy

// ensure that the _proxy is now pointing to the new implementation
_kintoIDv2 = KintoIDv2(address(_proxy));
assertEq(_kintoIDv2.newFunction(), 1);
vm.stopPrank();
}

function testFailOthersCannotUpgrade() public {
function test_RevertWhen_OthersCannotUpgrade() public {
KintoIDv2 _implementationV2 = new KintoIDv2();

bytes memory err = abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(address(this)),
" is missing role ",
Strings.toHexString(uint256(_implementationV2.UPGRADER_ROLE()), 32)
);
vm.expectRevert(err);
_kintoIDv1.upgradeTo(address(_implementationV2));
// re-wrap the _proxy
_kintoIDv2 = KintoIDv2(address(_proxy));
assertEq(_kintoIDv2.newFunction(), 1);
}

function testAuthorizedCanUpgrade() public {
Expand Down Expand Up @@ -218,7 +225,7 @@ contract KintoIDTest is KYCSignature {
assertEq(_kintoIDv1.lastMonitoredAt(), block.timestamp);
}

function testFailOnlyProviderCanMonitor() public {
function test_RevertWhen_OnlyProviderCanMonitor() public {
vm.startPrank(_user);
_kintoIDv1.monitor(new address[](0), new IKintoID.MonitorUpdateData[][](0));
}
Expand Down Expand Up @@ -261,13 +268,13 @@ contract KintoIDTest is KYCSignature {
assertEq(_kintoIDv1.lastMonitoredAt(), block.timestamp);
}

function testFailProviderCanAddTraitUnknownUser() public {
function test_RevertWhen_ProviderCanAddTraitUnknownUser() public {
vm.startPrank(_kycProvider);
_kintoIDv1.addTrait(_user, 1);
assertEq(_kintoIDv1.hasTrait(_user, 1), true);
}

function testFailUserCannotAddTrait() public {
function test_RevertWhen_UserCannotAddTrait() public {
vm.startPrank(_user);
IKintoID.SignatureData memory sigdata = _auxCreateSignature(_kintoIDv1, _user, _user, 3, block.timestamp + 1000);
uint8[] memory traits = new uint8[](1);
Expand All @@ -289,7 +296,7 @@ contract KintoIDTest is KYCSignature {
assertEq(_kintoIDv1.lastMonitoredAt(), block.timestamp);
}

function testFailUserCannotRemoveTrait() public {
function test_RevertWhen_UserCannotRemoveTrait() public {
vm.startPrank(_kycProvider);
IKintoID.SignatureData memory sigdata = _auxCreateSignature(_kintoIDv1, _user, _user, 3, block.timestamp + 1000);
uint8[] memory traits = new uint8[](1);
Expand Down Expand Up @@ -329,7 +336,7 @@ contract KintoIDTest is KYCSignature {
assertEq(_kintoIDv1.lastMonitoredAt(), block.timestamp);
}

function testFailUserCannotAddSanction() public {
function test_RevertWhen_UserCannotAddSanction() public {
vm.startPrank(_user);
IKintoID.SignatureData memory sigdata = _auxCreateSignature(_kintoIDv1, _user, _user, 3, block.timestamp + 1000);
uint8[] memory traits = new uint8[](1);
Expand All @@ -338,7 +345,7 @@ contract KintoIDTest is KYCSignature {
_kintoIDv1.addSanction(_user2, 1);
}

function testFailUserCannotRemoveSanction() public {
function test_RevertWhen_UserCannotRemoveSanction() public {
vm.startPrank(_kycProvider);
_kintoIDv1.addSanction(_user, 1);
assertEq(_kintoIDv1.isSanctionsSafeIn(_user, 1), false);
Expand All @@ -349,7 +356,7 @@ contract KintoIDTest is KYCSignature {

// Transfer

function testFailTransfersAreDisabled() public {
function test_RevertWhen_TransfersAreDisabled() public {
IKintoID.SignatureData memory sigdata = _auxCreateSignature(_kintoIDv1, _user, _user, 3, block.timestamp + 1000);
uint8[] memory traits = new uint8[](1);
traits[0] = 1;
Expand Down
Loading

0 comments on commit e8bfeca

Please sign in to comment.