From 20e3bbeca4669b3a32174a0038682194f21f2805 Mon Sep 17 00:00:00 2001 From: Alain Nicolas Date: Tue, 26 Nov 2024 09:48:52 +0100 Subject: [PATCH] chore(contracts): Add tests to cover the bulkRevoke function in AbstractPortal and AbstractPortalV2 --- contracts/test/DefaultPortal.t.sol | 11 +++++++++++ contracts/test/DefaultPortalV2.t.sol | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/contracts/test/DefaultPortal.t.sol b/contracts/test/DefaultPortal.t.sol index 0863b517..e50de5b7 100644 --- a/contracts/test/DefaultPortal.t.sol +++ b/contracts/test/DefaultPortal.t.sol @@ -323,6 +323,17 @@ contract DefaultPortalTest is Test { defaultPortal.bulkRevoke(attestationsToRevoke); } + function test_bulkRevoke_OnlyOwner() public { + bytes32[] memory attestationsToRevoke = new bytes32[](2); + attestationsToRevoke[0] = bytes32("1"); + attestationsToRevoke[1] = bytes32("2"); + + // Revoke the attestation as a random user + vm.prank(makeAddr("random")); + vm.expectRevert(AbstractPortal.OnlyPortalOwner.selector); + defaultPortal.bulkRevoke(attestationsToRevoke); + } + function test_supportsInterface() public view { bool isIERC165Supported = defaultPortal.supportsInterface(type(ERC165Upgradeable).interfaceId); assertEq(isIERC165Supported, true); diff --git a/contracts/test/DefaultPortalV2.t.sol b/contracts/test/DefaultPortalV2.t.sol index 89e46b17..70186a6f 100644 --- a/contracts/test/DefaultPortalV2.t.sol +++ b/contracts/test/DefaultPortalV2.t.sol @@ -243,6 +243,17 @@ contract DefaultPortalV2Test is Test { defaultPortal.bulkRevoke(attestationsToRevoke); } + function test_bulkRevoke_OnlyOwner() public { + bytes32[] memory attestationsToRevoke = new bytes32[](2); + attestationsToRevoke[0] = bytes32("1"); + attestationsToRevoke[1] = bytes32("2"); + + // Revoke the attestation as a random user + vm.prank(makeAddr("random")); + vm.expectRevert(AbstractPortalV2.OnlyPortalOwner.selector); + defaultPortal.bulkRevoke(attestationsToRevoke); + } + function test_supportsInterface() public view { bool isIERC165Supported = defaultPortal.supportsInterface(type(ERC165Upgradeable).interfaceId); assertEq(isIERC165Supported, true);