// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "forge-std/Test.sol"; import "../../contracts/vault/RegulatedEntityRegistry.sol"; contract RegulatedEntityRegistryTest is Test { RegulatedEntityRegistry public registry; address public admin = address(0x1); address public entity = address(0x2); address public wallet1 = address(0x3); address public wallet2 = address(0x4); address public operator = address(0x5); bytes32 public constant JURISDICTION = keccak256("US"); function setUp() public { registry = new RegulatedEntityRegistry(admin); } function test_RegisterEntity() public { address[] memory wallets = new address[](2); wallets[0] = wallet1; wallets[1] = wallet2; vm.prank(admin); registry.registerEntity(entity, JURISDICTION, wallets); assertTrue(registry.isEligible(entity)); assertTrue(registry.isAuthorized(entity, wallet1)); assertTrue(registry.isAuthorized(entity, wallet2)); } function test_RegisterEntity_RevertIfZeroAddress() public { vm.prank(admin); vm.expectRevert("RegulatedEntityRegistry: zero address"); registry.registerEntity(address(0), JURISDICTION, new address[](0)); } function test_IsEligible() public { address[] memory wallets = new address[](0); vm.prank(admin); registry.registerEntity(entity, JURISDICTION, wallets); assertTrue(registry.isEligible(entity)); vm.prank(admin); registry.suspendEntity(entity); assertFalse(registry.isEligible(entity)); } function test_SuspendEntity() public { address[] memory wallets = new address[](0); vm.prank(admin); registry.registerEntity(entity, JURISDICTION, wallets); vm.prank(admin); registry.suspendEntity(entity); assertFalse(registry.isEligible(entity)); vm.prank(admin); registry.unsuspendEntity(entity); assertTrue(registry.isEligible(entity)); } function test_AddAuthorizedWallet() public { address[] memory wallets = new address[](0); vm.prank(admin); registry.registerEntity(entity, JURISDICTION, wallets); address newWallet = address(0x100); vm.prank(admin); registry.addAuthorizedWallet(entity, newWallet); assertTrue(registry.isAuthorized(entity, newWallet)); } function test_SetOperator() public { address[] memory wallets = new address[](1); wallets[0] = wallet1; vm.prank(admin); registry.registerEntity(entity, JURISDICTION, wallets); vm.prank(wallet1); registry.setOperator(entity, operator, true); assertTrue(registry.isOperator(entity, operator)); vm.prank(wallet1); registry.setOperator(entity, operator, false); assertFalse(registry.isOperator(entity, operator)); } }