Skip to content

Commit

Permalink
Remove testRequestGuardianNotOwner and add verifier test case for upg…
Browse files Browse the repository at this point in the history
…rading
  • Loading branch information
wshino committed Oct 23, 2024
1 parent bc1b66d commit 5174231
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,4 @@ contract EmailAccountRecoveryTest_requestGuardian is StructHelper {
RecoveryController.GuardianStatus.REQUESTED
);
}

// function testRequestGuardianNotOwner() public {
// setUp();

// require(
// recoveryController.guardians(guardian) ==
// recoveryController.GuardianStatus.NONE
// );

// vm.startPrank(receiver);
// recoveryController.requestGuardian(guardian);
// vm.stopPrank();

// require(
// recoveryController.guardians(guardian) ==
// recoveryController.GuardianStatus.NONE
// );
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,6 @@ contract EmailAccountRecoveryZKSyncTest_requestGuardian is StructHelper {
);
}

// function testRequestGuardianNotOwner() public {
// setUp();

// require(
// recoveryControllerZKSync.guardians(guardian) ==
// recoveryControllerZKSync.GuardianStatus.NONE
// );

// vm.startPrank(receiver);
// recoveryControllerZKSync.requestGuardian(guardian);
// vm.stopPrank();

// require(
// recoveryControllerZKSync.guardians(guardian) ==
// recoveryControllerZKSync.GuardianStatus.NONE
// );
// }

function testExpectRevertRequestGuardianInvalidGuardian() public {
skipIfNotZkSync();

Expand Down
45 changes: 45 additions & 0 deletions packages/contracts/test/utils/Verifier.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;

import "forge-std/Test.sol";
import "../../src/utils/Verifier.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

contract VerifierTest is Test {
Verifier public verifier;
address public deployer;

function setUp() public {
deployer = address(this);
verifier = new Verifier();
}

function testUpgradeVerifier() public {
// Deploy new implementation
Verifier newImplementation = new Verifier();

// Execute upgrade using proxy
ERC1967Proxy proxy = new ERC1967Proxy(
address(verifier),
abi.encodeCall(
verifier.initialize,
(deployer, address(0)) // Assuming a dummy address for groth16Verifier
)
);
Verifier verifierProxy = Verifier(address(proxy));

// Store initial values for comparison
uint256 initialDomainFields = verifierProxy.DOMAIN_FIELDS();
uint256 initialDomainBytes = verifierProxy.DOMAIN_BYTES();

// Upgrade to new implementation through proxy
verifierProxy.upgradeToAndCall(
address(newImplementation),
new bytes(0)
);

// Verify the upgrade
assertEq(verifierProxy.DOMAIN_FIELDS(), initialDomainFields);
assertEq(verifierProxy.DOMAIN_BYTES(), initialDomainBytes);
}
}

0 comments on commit 5174231

Please sign in to comment.