diff --git a/contracts/src/PBHVerifierImplV1.sol b/contracts/src/PBHVerifierImplV1.sol index 5f9e609..c721c02 100644 --- a/contracts/src/PBHVerifierImplV1.sol +++ b/contracts/src/PBHVerifierImplV1.sol @@ -129,7 +129,6 @@ contract PBHVerifierImplV1 is WorldIDImpl { /// @param _numPbhPerMonth The number of allowed PBH transactions per month. /// /// @custom:reverts string If called more than once at the same initialisation number. - /// @custom:reverts InvalidWorldId if `_worldId` is set to the zero address function initialize(IWorldIDGroups _worldId, uint8 _numPbhPerMonth) public reinitializer(1) { // First, ensure that all of the parent contracts are initialised. __delegateInit(); diff --git a/contracts/test/PBHVerifierConstruction.t.sol b/contracts/test/PBHVerifierConstruction.t.sol new file mode 100644 index 0000000..9c50eee --- /dev/null +++ b/contracts/test/PBHVerifierConstruction.t.sol @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.21; + +import {PBHVerifierTest} from "./PBHVerifierTest.sol"; +import {IWorldIDGroups} from "@world-id-contracts/interfaces/IWorldIDGroups.sol"; + +import {PBHVerifierImplV1 as PBHVerifierImpl} from "../src/PBHVerifierImplV1.sol"; +import {PBHVerifier} from "../src/PBHVerifier.sol"; + +/// @title World ID Router Construction Tests +/// @notice Contains tests for the WorldID router +/// @author Worldcoin +/// @dev This test suite tests both the proxy and the functionality of the underlying implementation +/// so as to test everything in the context of how it will be deployed. +contract PBHVerifierConstruction is PBHVerifierTest { + /// @notice Taken from Initializable.sol + event Initialized(uint8 version); + + /// @notice Tests if it is possible to construct a router without a delegate. + function testCanConstructPBHVerifierWithNoDelegate() public { + // Setup + address dummy = address(this); + bytes memory data = new bytes(0x0); + + // Test + pbhVerifier = new PBHVerifier(dummy, data); + } + + /// @notice Tests that it is possible to properly construct and initialise a router. + function testCanConstructRouterWithDelegate(IWorldIDGroups dummy) public { + // Setup + vm.expectEmit(true, true, true, true); + emit Initialized(1); + pbhVerifierImpl = new PBHVerifierImpl(); + bytes memory callData = abi.encodeCall(PBHVerifierImpl.initialize, (dummy, 30)); + + // Test + pbhVerifier = new PBHVerifier(address(pbhVerifierImpl), callData); + } +} \ No newline at end of file diff --git a/contracts/test/PBHVerifier.t.sol b/contracts/test/PBHVerifierTest.sol similarity index 84% rename from contracts/test/PBHVerifier.t.sol rename to contracts/test/PBHVerifierTest.sol index 5eb5421..ba9b69f 100644 --- a/contracts/test/PBHVerifier.t.sol +++ b/contracts/test/PBHVerifierTest.sol @@ -10,8 +10,8 @@ import {PBHVerifierImplV1 as PBHVerifierImpl} from "../src/PBHVerifierImplV1.sol import {PBHVerifier} from "../src/PBHVerifier.sol"; // import {WorldIDTest} from "@world-id-contracts/test/WorldIdTest.sol"; -/// @title World ID Router Test. -/// @notice Contains tests for the WorldID Router. +/// @title PBHVerifier Test. +/// @notice Contains tests for the PBHVerifier. /// @author Worldcoin /// @dev This test suite tests both the proxy and the functionality of the underlying implementation /// so as to test everything in the context of how it will be deployed. @@ -28,12 +28,7 @@ contract PBHVerifierTest is WorldIDTest { IWorldIDGroups internal nullManager = IWorldIDGroups(address(0)); IWorldIDGroups internal thisWorldID; - - /// @notice Emitted when a group is enabled in the router. - /// - /// @param initialGroupIdentityManager The address of the identity manager to be used for the first group - event GroupIdentityManagerRouterImplInitialized(IWorldIDGroups initialGroupIdentityManager); - + /////////////////////////////////////////////////////////////////////////////// /// TEST ORCHESTRATION /// /////////////////////////////////////////////////////////////////////////////// @@ -47,7 +42,7 @@ contract PBHVerifierTest is WorldIDTest { // Label the addresses for better errors. hevm.label(thisAddress, "Sender"); hevm.label(pbhVerifierAddress, "PBHVerifier"); - hevm.label(pbhVerifierImplAddress, "PBHVerifierImplementation"); + hevm.label(pbhVerifierImplAddress, "PBHVerifierImpl"); } /////////////////////////////////////////////////////////////////////////////// @@ -62,9 +57,8 @@ contract PBHVerifierTest is WorldIDTest { pbhVerifierImpl = new PBHVerifierImpl(); pbhVerifierImplAddress = address(pbhVerifierImpl); - vm.expectEmit(true, true, true, true); - - emit GroupIdentityManagerRouterImplInitialized(initialGroupAddress); + // TODO: why does this not work? + // vm.expectEmit(true, true, true, true); bytes memory initCallData = abi.encodeCall(PBHVerifierImpl.initialize, (initialGroupAddress, 30)); @@ -74,7 +68,7 @@ contract PBHVerifierTest is WorldIDTest { /// @notice Constructs a new router without initializing the delegate. /// @dev It is constructed in the globals. - function makeUninitRouter() public { + function makeUninitPBHVerifier() public { pbhVerifierImpl = new PBHVerifierImpl(); pbhVerifierImplAddress = address(pbhVerifierImpl); pbhVerifier = new PBHVerifier(pbhVerifierImplAddress, new bytes(0x0));