From 4c9dec637eddc0a39d22dd1668781353e02f1499 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Wed, 22 May 2024 12:44:27 -0400 Subject: [PATCH 01/13] linting --- .../governance/voting/ReleaseGold.t.sol | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol b/packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol index 1d60e8265e5..8afc8fac899 100644 --- a/packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol +++ b/packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol @@ -37,14 +37,6 @@ contract ReleaseGoldTest is Test, ECDSAHelper { ReleaseGold releaseGold; ReleaseGold releaseGold2; - event ReleaseGoldInstanceCreated(address indexed beneficiary, address indexed atAddress); - event ReleaseScheduleRevoked(uint256 revokeTimestamp, uint256 releasedBalanceAtRevoke); - event ReleaseGoldInstanceDestroyed(address indexed beneficiary, address indexed atAddress); - event DistributionLimitSet(address indexed beneficiary, uint256 maxDistribution); - event LiquidityProvisionSet(address indexed beneficiary); - event CanExpireSet(bool canExpire); - event BeneficiarySet(address indexed beneficiary); - address owner = address(this); address beneficiary; uint256 beneficiaryPrivateKey; @@ -65,6 +57,14 @@ contract ReleaseGoldTest is Test, ECDSAHelper { ReleaseGoldMockTunnel.InitParams initParams; ReleaseGoldMockTunnel.InitParams2 initParams2; + event ReleaseGoldInstanceCreated(address indexed beneficiary, address indexed atAddress); + event ReleaseScheduleRevoked(uint256 revokeTimestamp, uint256 releasedBalanceAtRevoke); + event ReleaseGoldInstanceDestroyed(address indexed beneficiary, address indexed atAddress); + event DistributionLimitSet(address indexed beneficiary, uint256 maxDistribution); + event LiquidityProvisionSet(address indexed beneficiary); + event CanExpireSet(bool canExpire); + event BeneficiarySet(address indexed beneficiary); + function newReleaseGold(bool prefund, bool startReleasing) internal returns (ReleaseGold) { releaseGold = new ReleaseGold(true); @@ -149,7 +149,7 @@ contract ReleaseGoldTest is Test, ECDSAHelper { } } -contract ReleaseGoldInitialize is ReleaseGoldTest { +contract ReleaseGoldTest_ReleaseGoldInitialize is ReleaseGoldTest { function setUp() public { super.setUp(); } @@ -165,7 +165,7 @@ contract ReleaseGoldInitialize is ReleaseGoldTest { } } -contract Payable is ReleaseGoldTest { +contract ReleaseGoldTest_Payable is ReleaseGoldTest { function setUp() public { super.setUp(); } @@ -204,7 +204,7 @@ contract Payable is ReleaseGoldTest { } } -contract Transfer is ReleaseGoldTest { +contract ReleaseGoldTest_Transfer is ReleaseGoldTest { address receiver = actor("receiver"); uint256 transferAmount = 10; @@ -222,7 +222,7 @@ contract Transfer is ReleaseGoldTest { } } -contract GenericTransfer is ReleaseGoldTest { +contract ReleaseGoldTest_GenericTransfer is ReleaseGoldTest { address receiver = actor("receiver"); uint256 transferAmount = 10; @@ -255,7 +255,7 @@ contract GenericTransfer is ReleaseGoldTest { } } -contract Creation is ReleaseGoldTest { +contract ReleaseGoldTest_Creation is ReleaseGoldTest { uint256 public maxUint256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; function setUp() public { @@ -380,7 +380,7 @@ contract Creation is ReleaseGoldTest { } } -contract SetBeneficiary is ReleaseGoldTest { +contract ReleaseGoldTest_SetBeneficiary is ReleaseGoldTest { function setUp() public { super.setUp(); newReleaseGold(true, false); @@ -404,7 +404,7 @@ contract SetBeneficiary is ReleaseGoldTest { } } -contract CreateAccount is ReleaseGoldTest { +contract ReleaseGoldTest_CreateAccount is ReleaseGoldTest { function setUp() public { super.setUp(); newReleaseGold(true, false); @@ -478,7 +478,7 @@ contract SetAccount is ReleaseGoldTest { } } -contract SetAccountName is ReleaseGoldTest { +contract ReleaseGoldTest_SetAccountName is ReleaseGoldTest { function setUp() public { super.setUp(); newReleaseGold(true, false); @@ -519,7 +519,7 @@ contract SetAccountName is ReleaseGoldTest { } } -contract SetAccountWalletAddress is ReleaseGoldTest { +contract ReleaseGoldTest_SetAccountWalletAddress is ReleaseGoldTest { uint8 v; bytes32 r; bytes32 s; @@ -577,7 +577,7 @@ contract SetAccountWalletAddress is ReleaseGoldTest { } } -contract SetAccountMetadataURL is ReleaseGoldTest { +contract ReleaseGoldTest_SetAccountMetadataURL is ReleaseGoldTest { function setUp() public { super.setUp(); newReleaseGold(true, false); @@ -622,7 +622,7 @@ contract SetAccountMetadataURL is ReleaseGoldTest { } } -contract SetAccountDataEncryptionKey is ReleaseGoldTest { +contract ReleaseGoldTest_SetAccountDataEncryptionKey is ReleaseGoldTest { bytes dataEncryptionKey = hex"02f2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e01611111111"; bytes longDataEncryptionKey = hex"04f2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0161111111102f2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e01611111111"; @@ -672,7 +672,7 @@ contract SetAccountDataEncryptionKey is ReleaseGoldTest { } } -contract SetMaxDistribution is ReleaseGoldTest { +contract ReleaseGoldTest_SetMaxDistribution is ReleaseGoldTest { function setUp() public { super.setUp(); initParams2.initialDistributionRatio = 0; @@ -702,7 +702,7 @@ contract SetMaxDistribution is ReleaseGoldTest { } } -contract AuthorizationTests is ReleaseGoldTest { +contract ReleaseGoldTest_AuthorizationTests is ReleaseGoldTest { uint256 initialReleaseGoldAmount; uint8 v; @@ -1021,7 +1021,7 @@ contract AuthorizationTests is ReleaseGoldTest { } } -contract AuthorizeWithPublicKeys is ReleaseGoldTest { +contract ReleaseGoldTest_AuthorizeWithPublicKeys is ReleaseGoldTest { uint8 v; bytes32 r; bytes32 s; @@ -1108,7 +1108,7 @@ contract AuthorizeWithPublicKeys is ReleaseGoldTest { } } -contract Revoke is ReleaseGoldTest { +contract ReleaseGoldTest_Revoke is ReleaseGoldTest { function setUp() public { super.setUp(); } @@ -1150,7 +1150,7 @@ contract Revoke is ReleaseGoldTest { } } -contract Expire is ReleaseGoldTest { +contract ReleaseGoldTest_Expire is ReleaseGoldTest { function setUp() public { super.setUp(); newReleaseGold(true, false); @@ -1285,7 +1285,7 @@ contract Expire is ReleaseGoldTest { } } -contract RefundAndFinalize is ReleaseGoldTest { +contract ReleaseGoldTest_RefundAndFinalize is ReleaseGoldTest { function setUp() public { super.setUp(); newReleaseGold(true, false); @@ -1341,7 +1341,7 @@ contract RefundAndFinalize is ReleaseGoldTest { } } -contract ExpireSelfDestructTest is ReleaseGoldTest { +contract ReleaseGoldTest_ExpireSelfDestructTest is ReleaseGoldTest { function setUp() public { super.setUp(); newReleaseGold(true, false); @@ -1361,7 +1361,7 @@ contract ExpireSelfDestructTest is ReleaseGoldTest { } } -contract LockGold is ReleaseGoldTest { +contract ReleaseGoldTest_LockGold is ReleaseGoldTest { uint256 lockAmount; function setUp() public { super.setUp(); @@ -1403,7 +1403,7 @@ contract LockGold is ReleaseGoldTest { } } -contract UnlockGold is ReleaseGoldTest { +contract ReleaseGoldTest_UnlockGold is ReleaseGoldTest { uint256 lockAmount; function setUp() public { super.setUp(); @@ -1466,7 +1466,7 @@ contract UnlockGold is ReleaseGoldTest { } } -contract WithdrawLockedGold is ReleaseGoldTest { +contract ReleaseGoldTest_WithdrawLockedGold is ReleaseGoldTest { uint256 value = 1000; uint256 index = 0; @@ -1536,7 +1536,7 @@ contract WithdrawLockedGold is ReleaseGoldTest { } } -contract RelockGold is ReleaseGoldTest { +contract ReleaseGoldTest_RelockGold is ReleaseGoldTest { uint256 pendingWithdrawalValue = 1000; uint256 index = 0; @@ -1642,7 +1642,7 @@ contract RelockGold is ReleaseGoldTest { } } -contract Withdraw is ReleaseGoldTest { +contract ReleaseGoldTest_Withdraw is ReleaseGoldTest { uint256 initialReleaseGoldAmount; function setUp() public { @@ -1938,7 +1938,7 @@ contract Withdraw is ReleaseGoldTest { } } -contract WithdrawSelfDestruct_WhenNotRevoked is ReleaseGoldTest { +contract ReleaseGoldTest_WithdrawSelfDestruct_WhenNotRevoked is ReleaseGoldTest { uint256 initialReleaseGoldAmount; function setUp() public { @@ -1964,7 +1964,7 @@ contract WithdrawSelfDestruct_WhenNotRevoked is ReleaseGoldTest { } } -contract WithdrawSelfDestruct_WhenRevoked is ReleaseGoldTest { +contract ReleaseGoldTest_WithdrawSelfDestruct_WhenRevoked is ReleaseGoldTest { uint256 initialReleaseGoldAmount; function setUp() public { @@ -1992,7 +1992,7 @@ contract WithdrawSelfDestruct_WhenRevoked is ReleaseGoldTest { } } -contract GetCurrentReleasedTotalAmount is ReleaseGoldTest { +contract ReleaseGoldTest_GetCurrentReleasedTotalAmount is ReleaseGoldTest { uint256 initialReleaseGoldAmount; function setUp() public { @@ -2035,7 +2035,7 @@ contract GetCurrentReleasedTotalAmount is ReleaseGoldTest { } } -contract GetWithdrawableAmount is ReleaseGoldTest { +contract ReleaseGoldTest_GetWithdrawableAmount is ReleaseGoldTest { uint256 initialReleaseGoldAmount; function setUp() public { From f62e0d0a67859473ba03647f301d70ea86869f87 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Wed, 22 May 2024 13:37:59 -0400 Subject: [PATCH 02/13] updated to test L2 functionality and deployment --- .../contracts/governance/ReleaseGold.sol | 2 + .../governance/test/MockValidators.sol | 17 +- .../governance/voting/ReleaseGold.t.sol | 228 +++++++++++++++++- 3 files changed, 242 insertions(+), 5 deletions(-) diff --git a/packages/protocol/contracts/governance/ReleaseGold.sol b/packages/protocol/contracts/governance/ReleaseGold.sol index e7ea00edc50..469e93274b3 100644 --- a/packages/protocol/contracts/governance/ReleaseGold.sol +++ b/packages/protocol/contracts/governance/ReleaseGold.sol @@ -451,6 +451,7 @@ contract ReleaseGold is UsingRegistry, ReentrancyGuard, IReleaseGold, Initializa * @param ecdsaPublicKey The ECDSA public key corresponding to `signer`. * @dev The v,r and s signature should be signed by the authorized signer * key, with the ReleaseGold contract address as the message. + * @dev Function is deprecated on L2. */ function authorizeValidatorSignerWithPublicKey( address payable signer, @@ -479,6 +480,7 @@ contract ReleaseGold is UsingRegistry, ReentrancyGuard, IReleaseGold, Initializa * account address. 48 bytes. * @dev The v,r and s signature should be signed by the authorized signer * key, with the ReleaseGold contract address as the message. + * @dev Function is deprecated on L2. */ function authorizeValidatorSignerWithKeys( address payable signer, diff --git a/packages/protocol/contracts/governance/test/MockValidators.sol b/packages/protocol/contracts/governance/test/MockValidators.sol index 178d5a8a5fd..97cf017a9a3 100644 --- a/packages/protocol/contracts/governance/test/MockValidators.sol +++ b/packages/protocol/contracts/governance/test/MockValidators.sol @@ -2,10 +2,12 @@ pragma solidity ^0.5.13; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "../../../contracts-0.8/common/IsL2Check.sol"; + /** * @title Holds a list of addresses of validators */ -contract MockValidators { +contract MockValidators is IsL2Check { using SafeMath for uint256; uint256 private constant FIXED1_UINT = 1000000000000000000000000; @@ -20,6 +22,7 @@ contract MockValidators { uint256 private numRegisteredValidators; function updateEcdsaPublicKey(address, address, bytes calldata) external returns (bool) { + allowOnlyL1(); return true; } @@ -30,6 +33,7 @@ contract MockValidators { bytes calldata, bytes calldata ) external returns (bool) { + allowOnlyL1(); return true; } @@ -42,6 +46,7 @@ contract MockValidators { } function affiliate(address group) external returns (bool) { + allowOnlyL1(); affiliations[msg.sender] = group; return true; } @@ -62,9 +67,13 @@ contract MockValidators { lockedGoldRequirements[account] = value; } - function halveSlashingMultiplier(address) external {} + function halveSlashingMultiplier(address) external { + allowOnlyL1(); + } - function forceDeaffiliateIfValidator(address validator) external {} + function forceDeaffiliateIfValidator(address validator) external { + allowOnlyL1(); + } function getTopGroupValidators( address group, @@ -79,6 +88,7 @@ contract MockValidators { } function getValidatorGroupSlashingMultiplier(address) external view returns (uint256) { + allowOnlyL1(); return FIXED1_UINT; } @@ -107,6 +117,7 @@ contract MockValidators { } function groupMembershipInEpoch(address addr, uint256, uint256) external view returns (address) { + allowOnlyL1(); return affiliations[addr]; } diff --git a/packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol b/packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol index 8afc8fac899..bd76502b832 100644 --- a/packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol +++ b/packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol @@ -65,6 +65,24 @@ contract ReleaseGoldTest is Test, ECDSAHelper { event CanExpireSet(bool canExpire); event BeneficiarySet(address indexed beneficiary); + address constant proxyAdminAddress = 0x4200000000000000000000000000000000000018; + function _whenL2() public { + deployCodeTo("Registry.sol", abi.encode(false), proxyAdminAddress); + registry = Registry(proxyAdminAddress); + registry.setAddressFor("Accounts", address(accounts)); + registry.setAddressFor("Election", address(election)); + registry.setAddressFor("Freezer", address(freezer)); + registry.setAddressFor("GoldToken", address(goldToken)); + registry.setAddressFor("Governance", address(governance)); + registry.setAddressFor("LockedGold", address(lockedGold)); + registry.setAddressFor("Validators", address(validators)); + registry.setAddressFor("StableToken", address(stableToken)); + + lockedGold.setRegistry(proxyAdminAddress); + goldToken.setRegistry(proxyAdminAddress); + accounts.setRegistry(proxyAdminAddress); + } + function newReleaseGold(bool prefund, bool startReleasing) internal returns (ReleaseGold) { releaseGold = new ReleaseGold(true); @@ -149,7 +167,7 @@ contract ReleaseGoldTest is Test, ECDSAHelper { } } -contract ReleaseGoldTest_ReleaseGoldInitialize is ReleaseGoldTest { +contract ReleaseGoldTest_Initialize is ReleaseGoldTest { function setUp() public { super.setUp(); } @@ -1106,6 +1124,50 @@ contract ReleaseGoldTest_AuthorizeWithPublicKeys is ReleaseGoldTest { assertEq(accounts.getValidatorSigner(address(releaseGold)), authorized); assertEq(accounts.validatorSignerToAccount(authorized), address(releaseGold)); } + + function test_Reverts_WhenAuthorizeValidatorSignerWithPublicKeyCalledOnL2() public { + _whenL2(); + vm.expectRevert("This method is no longer supported in L2."); + vm.prank(beneficiary); + releaseGold.authorizeValidatorSignerWithPublicKey( + address(uint160(authorized)), + v, + r, + s, + ecdsaPublicKey + ); + } + + function test_Reverts_WhenAuthorizeValidatorSignerWithKeysCalledOnL2() public { + _whenL2(); + bytes32 newBlsPublicKeyPart1 = _randomBytes32(); + bytes32 newBlsPublicKeyPart2 = _randomBytes32(); + bytes32 newBlsPublicKeyPart3 = _randomBytes32(); + bytes memory newBlsPublicKey = abi.encodePacked( + newBlsPublicKeyPart1, + newBlsPublicKeyPart2, + newBlsPublicKeyPart3 + ); + newBlsPublicKey = _truncateBytes(newBlsPublicKey, 96); + + bytes32 newBlsPoPPart1 = _randomBytes32(); + bytes32 newBlsPoPPart2 = _randomBytes32(); + bytes memory newBlsPoP = abi.encodePacked(newBlsPoPPart1, newBlsPoPPart2); + newBlsPoP = _truncateBytes(newBlsPoP, 48); + + vm.expectRevert("This method is no longer supported in L2."); + + vm.prank(beneficiary); + releaseGold.authorizeValidatorSignerWithKeys( + address(uint160(authorized)), + v, + r, + s, + ecdsaPublicKey, + newBlsPublicKey, + newBlsPoP + ); + } } contract ReleaseGoldTest_Revoke is ReleaseGoldTest { @@ -2067,7 +2129,33 @@ contract ReleaseGoldTest_GetWithdrawableAmount is ReleaseGoldTest { assertEq(releaseGold.getWithdrawableAmount(), initialReleaseGoldAmount / 4); } - function test_ShouldReturnOnlyUpToItsOwnBalance() public { + function test_ShouldReturnOnlyUpToItsOwnBalanceWhenValidatorSignerAuthorizedWitoutKey() public { + vm.prank(releaseOwner); + releaseGold.setMaxDistribution(1000); + + vm.prank(beneficiary); + releaseGold.createAccount(); + + vm.warp(block.timestamp + 6 * MONTH + 1 * DAY); + + uint256 signerFund = 1 ether; + uint256 expectedWithdrawalAmount = (initialReleaseGoldAmount - signerFund) / 2; + + (address authorized, uint256 authorizedPK) = actorWithPK("authorized"); + (uint8 v, bytes32 r, bytes32 s) = getParsedSignatureOfAddress( + address(releaseGold), + authorizedPK + ); + + vm.prank(beneficiary); + releaseGold.authorizeValidatorSigner(address(uint160(authorized)), v, r, s); + + assertEq(releaseGold.getWithdrawableAmount(), expectedWithdrawalAmount); + } + + function test_ShouldReturnOnlyUpToItsOwnBalanceWhenValidatorSignerAuthorizedWithPublicKey() + public + { vm.prank(releaseOwner); releaseGold.setMaxDistribution(1000); @@ -2111,3 +2199,139 @@ contract ReleaseGoldTest_GetWithdrawableAmount is ReleaseGoldTest { assertEq(releaseGold.getWithdrawableAmount(), initialReleaseGoldAmount / 4); } } + +contract ReleaseGoldTest_DeployAndInitializeOnL2 is ReleaseGoldTest { + uint256 public maxUint256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; + function setUp() public { + super.setUp(); + _whenL2(); + initParams2.registryAddress = proxyAdminAddress; + } + + function test_ShouldIndicateIsFundedIfDeploymentIsPrefunded() public { + newReleaseGold(true, false); + assertTrue(releaseGold.isFunded()); + } + + function test_ShouldNotIndicateFundedAndNotRevertIfDeploymentIsNotPrefunded() public { + newReleaseGold(false, false); + assertFalse(releaseGold.isFunded()); + } + + function test_ShouldHaveAssociatedFundsWithAScheduleUponCreation() public { + newReleaseGold(true, false); + assertEq( + goldToken.balanceOf(address(releaseGold)), + initParams.numReleasePeriods * initParams.amountReleasedPerPeriod + ); + } + + function test_ShouldSetABeneficiaryToReleaseGoldInstance() public { + newReleaseGold(true, false); + assertEq(releaseGold.beneficiary(), initParams._beneficiary); + } + + function test_ShouldSetAReleaseOwnerToReleaseGoldInstance() public { + newReleaseGold(true, false); + assertEq(releaseGold.releaseOwner(), initParams2._releaseOwner); + } + + function test_ShouldSetReleaseGoldNumberOfPeriods() public { + newReleaseGold(true, false); + (, , uint256 releaseGoldNumPeriods, , ) = releaseGold.releaseSchedule(); + assertEq(releaseGoldNumPeriods, initParams.numReleasePeriods); + } + + function test_ShouldSetReleaseGoldAmountPerPeriod() public { + newReleaseGold(true, false); + (, , , , uint256 releaseGoldAmountPerPeriod) = releaseGold.releaseSchedule(); + assertEq(releaseGoldAmountPerPeriod, initParams.amountReleasedPerPeriod); + } + + function test_ShouldSetReleaseGoldPeriod() public { + newReleaseGold(true, false); + (, , , uint256 releaseGoldPeriod, ) = releaseGold.releaseSchedule(); + assertEq(releaseGoldPeriod, initParams.releasePeriod); + } + + function test_ShouldSetReleaseGoldStartTime() public { + newReleaseGold(true, false); + (uint256 releaseGoldStartTime, , , , ) = releaseGold.releaseSchedule(); + assertEq(releaseGoldStartTime, initParams.releaseStartTime); + } + + function test_ShouldSetReleaseGoldCliffTime() public { + newReleaseGold(true, false); + (, uint256 releaseGoldCliffTime, , , ) = releaseGold.releaseSchedule(); + uint256 expectedCliffTime = initParams.releaseStartTime + initParams.releaseCliffTime; + assertEq(releaseGoldCliffTime, expectedCliffTime); + } + + function test_ShouldSetRevocableFlagToReleaseGoldInstance() public { + newReleaseGold(true, false); + (bool revocable, , , ) = releaseGold.revocationInfo(); + assertEq(revocable, initParams.revocable); + } + + function test_ShouldSetReleaseOwnerToReleaseGoldInstance() public { + newReleaseGold(true, false); + assertEq(releaseGold.releaseOwner(), initParams2._releaseOwner); + } + + function test_ShouldSetLiquidityProvisionMetToTrue() public { + newReleaseGold(true, false); + assertEq(releaseGold.liquidityProvisionMet(), true); + } + + function test_ShouldHaveZeroTotalWithdrawnOnInit() public { + newReleaseGold(true, false); + assertEq(releaseGold.totalWithdrawn(), 0); + } + + function test_ShouldBeUnrevokedOnInitAndHaveRevokeTimeEqualZero() public { + newReleaseGold(true, false); + (, , , uint256 revokeTime) = releaseGold.revocationInfo(); + assertEq(revokeTime, 0); + assertEq(releaseGold.isRevoked(), false); + } + + function test_ShouldHaveReleaseGoldBalanceAtRevokeOnInitEqualToZero() public { + newReleaseGold(true, false); + (, , uint256 releasedBalanceAtRevoke, ) = releaseGold.revocationInfo(); + assertEq(releasedBalanceAtRevoke, 0); + } + + function test_ShouldRevertWhenReleaseGoldBeneficiaryIsTheNullAddress() public { + releaseGold = new ReleaseGold(true); + initParams._beneficiary = address(0); + ReleaseGoldMockTunnel tunnel = new ReleaseGoldMockTunnel(address(releaseGold)); + vm.expectRevert("unsuccessful tunnel call"); + tunnel.MockInitialize(owner, initParams, initParams2); + } + + function test_ShouldRevertWhenReleaseGoldPeriodsAreZero() public { + releaseGold2 = new ReleaseGold(true); + initParams.numReleasePeriods = 0; + ReleaseGoldMockTunnel tunnel = new ReleaseGoldMockTunnel(address(releaseGold2)); + vm.expectRevert("unsuccessful tunnel call"); + tunnel.MockInitialize(owner, initParams, initParams2); + } + + function test_ShouldRevertWhenReleasedAmountPerPeriodIsZero() public { + releaseGold2 = new ReleaseGold(true); + initParams.amountReleasedPerPeriod = 0; + ReleaseGoldMockTunnel tunnel = new ReleaseGoldMockTunnel(address(releaseGold2)); + vm.expectRevert("unsuccessful tunnel call"); + tunnel.MockInitialize(owner, initParams, initParams2); + } + + function test_ShouldOverflowForVeryLargeCombinationsOdReleasePeriodsAndAmountPerTime() public { + releaseGold = new ReleaseGold(true); + initParams.numReleasePeriods = maxUint256; + initParams.amountReleasedPerPeriod = maxUint256; + initParams2.initialDistributionRatio = 999; + ReleaseGoldMockTunnel tunnel = new ReleaseGoldMockTunnel(address(releaseGold)); + vm.expectRevert("unsuccessful tunnel call"); + tunnel.MockInitialize(owner, initParams, initParams2); + } +} From 414dc9b3cca25651d5167fae195b2d72f3a35ea3 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Thu, 23 May 2024 14:05:48 -0400 Subject: [PATCH 03/13] debugging --- .github/workflows/protocol_tests.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index f2c02e22780..72f22d0c06d 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -50,7 +50,7 @@ jobs: - name: Run tests common # can't use gas limit because some setUp function use more than the limit - run: forge test -vvv --match-path "test-sol/common/*" # --block-gas-limit 50000000 + run: forge test -vvv --match-path "test-sol/common/*" # --block-gas-limit 50000000 - name: Run tests governance/network if: success() || failure() @@ -59,7 +59,7 @@ jobs: - name: Run tests governance/validators if: success() || failure() run: forge test -vvv --block-gas-limit 50000000 --match-path "test-sol/governance/validators/*" - + - name: Run tests governance/voting # can't use gas limit because some setUp function use more than the limit if: success() || failure() @@ -80,7 +80,8 @@ jobs: echo "All tests should be in a folder" exit 1 fi - + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 - name: Run Everything just in case something was missed # can't use gas limit because some setUp function use more than the limit run: forge test -vvv #TODO this should ignore integration tests From 64eb09980fd3a0d41a8e1bc328089db3b7f26bee Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Thu, 23 May 2024 14:30:09 -0400 Subject: [PATCH 04/13] force cache re building --- .github/workflows/protocol_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 72f22d0c06d..1b49ab37cc2 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -3,7 +3,7 @@ on: [push, pull_request] env: # Increment these to force cache rebuilding - FOUNDRY_CACHE_KEY: 1 + FOUNDRY_CACHE_KEY: 2 jobs: check: From 8a79459437583ac7a9e78dc3feddafa1baf55fd8 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Thu, 23 May 2024 16:44:58 -0400 Subject: [PATCH 05/13] run on self hosted --- .github/workflows/protocol_tests.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 1b49ab37cc2..012a857b0e9 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -11,7 +11,8 @@ jobs: run: working-directory: packages/protocol name: Run tests - runs-on: ubuntu-latest + # runs-on: ubuntu-latest + runs-on: ['self-hosted', 'monorepo-node18'] steps: - uses: actions/checkout@v4 with: @@ -80,8 +81,6 @@ jobs: echo "All tests should be in a folder" exit 1 fi - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - name: Run Everything just in case something was missed # can't use gas limit because some setUp function use more than the limit run: forge test -vvv #TODO this should ignore integration tests From 901144109a937acc187f3c50b3fcfd8b8de62416 Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Fri, 24 May 2024 09:17:33 +0200 Subject: [PATCH 06/13] Only run Protocol tests on PRs and push to master (to avoid double execution) --- .github/workflows/protocol_tests.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 012a857b0e9..41059ff0173 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -1,5 +1,12 @@ name: Protocol Foundry tests -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + branches: + - master + - 'release/**' env: # Increment these to force cache rebuilding From 59567923b987c3db2db9ec13152f3496f4822bd9 Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Fri, 24 May 2024 10:05:17 +0200 Subject: [PATCH 07/13] Debug with tmate --- .github/workflows/protocol_tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 41059ff0173..af43f2a14cd 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -88,6 +88,12 @@ jobs: echo "All tests should be in a folder" exit 1 fi + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 15 + with: + limit-access-to-actor: true + - name: Run Everything just in case something was missed # can't use gas limit because some setUp function use more than the limit run: forge test -vvv #TODO this should ignore integration tests From 0f0431cdc8a72f9d9cc5fc58282c90dd9433a612 Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Fri, 24 May 2024 10:16:00 +0200 Subject: [PATCH 08/13] Rerun tests --- .github/workflows/protocol_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index af43f2a14cd..3a97a577479 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -90,7 +90,7 @@ jobs: fi - name: Setup tmate session uses: mxschmitt/action-tmate@v3 - timeout-minutes: 15 + timeout-minutes: 30 with: limit-access-to-actor: true From 6dfe8c6bcbb4844d1c806c91cc0a67e38e7d1358 Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Fri, 24 May 2024 10:23:18 +0200 Subject: [PATCH 09/13] Test with a different OS --- .github/workflows/protocol_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 3a97a577479..78043ddcd11 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -18,8 +18,8 @@ jobs: run: working-directory: packages/protocol name: Run tests - # runs-on: ubuntu-latest - runs-on: ['self-hosted', 'monorepo-node18'] + runs-on: ubuntu-20.04 + # runs-on: ['self-hosted', 'monorepo-node18'] steps: - uses: actions/checkout@v4 with: From 62815d484782913a4d9046046baa54cf32741acf Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Fri, 24 May 2024 10:32:34 +0200 Subject: [PATCH 10/13] Use ubuntu 20.04 --- .github/workflows/protocol_tests.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 78043ddcd11..6784f7678ba 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -19,7 +19,6 @@ jobs: working-directory: packages/protocol name: Run tests runs-on: ubuntu-20.04 - # runs-on: ['self-hosted', 'monorepo-node18'] steps: - uses: actions/checkout@v4 with: @@ -88,11 +87,6 @@ jobs: echo "All tests should be in a folder" exit 1 fi - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - timeout-minutes: 30 - with: - limit-access-to-actor: true - name: Run Everything just in case something was missed # can't use gas limit because some setUp function use more than the limit From 75d8c194548191c355fb6f321258043b7770b209 Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Fri, 24 May 2024 10:43:19 +0200 Subject: [PATCH 11/13] Increase swapspace --- .github/workflows/protocol_tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 6784f7678ba..d0863042004 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -20,6 +20,10 @@ jobs: name: Run tests runs-on: ubuntu-20.04 steps: + - name: Set Swap Space + uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c + with: + swap-size-gb: 16 - uses: actions/checkout@v4 with: submodules: recursive From bdccdfe39a9cde82d6fa2ef7e9d51978e83205cd Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Fri, 24 May 2024 11:02:05 +0200 Subject: [PATCH 12/13] mor mem --- .github/workflows/protocol_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index d0863042004..0a96c322c33 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -23,7 +23,7 @@ jobs: - name: Set Swap Space uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c with: - swap-size-gb: 16 + swap-size-gb: 32 - uses: actions/checkout@v4 with: submodules: recursive From 1f467d5f1fb8f2845d4c164c13e5a4157fd7b27a Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Fri, 24 May 2024 11:14:48 +0200 Subject: [PATCH 13/13] Testing again with ubuntu-latest (22.04) --- .github/workflows/protocol_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 0a96c322c33..6d05c627da0 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -18,7 +18,7 @@ jobs: run: working-directory: packages/protocol name: Run tests - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Set Swap Space uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c