diff --git a/packages/protocol/test-sol/unit/common/Accounts.t.sol b/packages/protocol/test-sol/unit/common/Accounts.t.sol index 94ee49dac5..0723af49f7 100644 --- a/packages/protocol/test-sol/unit/common/Accounts.t.sol +++ b/packages/protocol/test-sol/unit/common/Accounts.t.sol @@ -4,16 +4,16 @@ pragma experimental ABIEncoderV2; import "celo-foundry/Test.sol"; import "@celo-contracts/common/FixidityLib.sol"; -import "@celo-contracts/common/Registry.sol"; import "@celo-contracts/common/Accounts.sol"; import "@celo-contracts/governance/test/MockValidators.sol"; import { TestConstants } from "@test-sol/constants.sol"; +import { Utils } from "@test-sol/utils.sol"; +import "@test-sol/utils/WhenL2.sol"; -contract AccountsTest is Test, TestConstants { +contract AccountsTest is Utils { using FixidityLib for FixidityLib.Fraction; - Registry registry; Accounts accounts; MockValidators validators; @@ -80,13 +80,11 @@ contract AccountsTest is Test, TestConstants { event PaymentDelegationSet(address indexed beneficiary, uint256 fraction); function setUp() public { - deployCodeTo("Registry.sol", abi.encode(false), REGISTRY_ADDRESS); + super.setUp(); accounts = new Accounts(true); validators = new MockValidators(); - registry = Registry(REGISTRY_ADDRESS); - registry.setAddressFor("Validators", address(validators)); registry.setAddressFor("Accounts", address(accounts)); @@ -97,10 +95,6 @@ contract AccountsTest is Test, TestConstants { (caller2, caller2PK) = actorWithPK("caller2"); } - function _whenL2() public { - deployCodeTo("Registry.sol", abi.encode(false), PROXY_ADMIN_ADDRESS); - } - function getParsedSignatureOfAddress( address _address, uint256 privateKey @@ -201,6 +195,8 @@ contract AccountsTest is Test, TestConstants { } } +contract AccountsTest_L2 is AccountsTest, WhenL2 {} + contract AccountsTest_createAccount is AccountsTest { function setUp() public { super.setUp(); @@ -219,6 +215,8 @@ contract AccountsTest_createAccount is AccountsTest { } } +contract AccountsTest_createAccount_L2 is AccountsTest_L2, AccountsTest_createAccount {} + contract AccountsTest_setAccountDataEncryptionKey is AccountsTest { function setUp() public { super.setUp(); @@ -254,6 +252,11 @@ contract AccountsTest_setAccountDataEncryptionKey is AccountsTest { } } +contract AccountsTest_setAccountDataEncryptionKey_L2 is + AccountsTest_L2, + AccountsTest_setAccountDataEncryptionKey +{} + contract AccountsTest_setAccount is AccountsTest { function setUp() public { super.setUp(); @@ -340,6 +343,8 @@ contract AccountsTest_setAccount is AccountsTest { } } +contract AccountsTest_setAccount_L2 is AccountsTest_L2, AccountsTest_setAccount {} + contract AccountsTest_setWalletAddress is AccountsTest { function setUp() public { super.setUp(); @@ -390,6 +395,8 @@ contract AccountsTest_setWalletAddress is AccountsTest { } } +contract AccountsTest_setWalletAddress_L2 is AccountsTest_L2, AccountsTest_setWalletAddress {} + contract AccountsTest_setMetadataURL is AccountsTest { function setUp() public { super.setUp(); @@ -414,6 +421,8 @@ contract AccountsTest_setMetadataURL is AccountsTest { } } +contract AccountsTest_setMetadataURL_L2 is AccountsTest_L2, AccountsTest_setMetadataURL {} + contract AccountsTest_batchGetMetadataURL is AccountsTest { function setUp() public { super.setUp(); @@ -464,6 +473,8 @@ contract AccountsTest_batchGetMetadataURL is AccountsTest { } } +contract AccountsTest_batchGetMetadataURL_L2 is AccountsTest_L2, AccountsTest_batchGetMetadataURL {} + contract AccountsTest_addStorageRoot is AccountsTest { function setUp() public { super.setUp(); @@ -510,6 +521,8 @@ contract AccountsTest_addStorageRoot is AccountsTest { } } +contract AccountsTest_addStorageRoot_L2 is AccountsTest_L2, AccountsTest_addStorageRoot {} + contract AccountsTest_removeStorageRoot is AccountsTest { function setUp() public { super.setUp(); @@ -586,6 +599,8 @@ contract AccountsTest_removeStorageRoot is AccountsTest { } } +contract AccountsTest_removeStorageRoot_L2 is AccountsTest_L2, AccountsTest_removeStorageRoot {} + contract AccountsTest_setPaymentDelegation is AccountsTest { address beneficiary = actor("beneficiary"); uint256 fraction = FixidityLib.newFixedFraction(2, 10).unwrap(); @@ -608,15 +623,6 @@ contract AccountsTest_setPaymentDelegation is AccountsTest { assertEq(realFraction, fraction); } - function test_ShouldSetAnAddressAndAFraction_WhenL2() public { - _whenL2(); - accounts.createAccount(); - accounts.setPaymentDelegation(beneficiary, fraction); - (address realBeneficiary, uint256 realFraction) = accounts.getPaymentDelegation(address(this)); - assertEq(realBeneficiary, beneficiary); - assertEq(realFraction, fraction); - } - function test_ShouldNotAllowFractionGreaterThan1() public { accounts.createAccount(); vm.expectRevert("Fraction must not be greater than 1"); @@ -637,6 +643,11 @@ contract AccountsTest_setPaymentDelegation is AccountsTest { } } +contract AccountsTest_setPaymentDelegation_L2 is + AccountsTest_L2, + AccountsTest_setPaymentDelegation +{} + contract AccountsTest_deletePaymentDelegation is AccountsTest { address beneficiary = actor("beneficiary"); uint256 fraction = FixidityLib.newFixedFraction(2, 10).unwrap(); @@ -667,6 +678,11 @@ contract AccountsTest_deletePaymentDelegation is AccountsTest { } } +contract AccountsTest_deletePaymentDelegation_L2 is + AccountsTest_L2, + AccountsTest_deletePaymentDelegation +{} + contract AccountsTest_setName is AccountsTest { function setUp() public { super.setUp(); @@ -691,6 +707,8 @@ contract AccountsTest_setName is AccountsTest { } } +contract AccountsTest_setName_L2 is AccountsTest_L2, AccountsTest_setName {} + contract AccountsTest_GenericAuthorization is AccountsTest { address account2 = actor("account2"); address signer; @@ -875,6 +893,11 @@ contract AccountsTest_GenericAuthorization is AccountsTest { } } +contract AccountsTest_GenericAuthorization_L2 is + AccountsTest_L2, + AccountsTest_GenericAuthorization +{} + contract AccountsTest_BackwardCompatibility is AccountsTest { address account = address(this); address otherAccount = actor("otherAccount"); @@ -1542,3 +1565,8 @@ contract AccountsTest_BackwardCompatibility is AccountsTest { helper_ShouldRemoveSigner(Role.Validator, false, true); } } + +contract AccountsTest_BackwardCompatibility_L2 is + AccountsTest_L2, + AccountsTest_BackwardCompatibility +{}