- Add Foundry project configuration (foundry.toml, foundry.lock) - Add Solidity contracts (TokenFactory138, BridgeVault138, ComplianceRegistry, etc.) - Add API definitions (OpenAPI, GraphQL, gRPC, AsyncAPI) - Add comprehensive test suite (unit, integration, fuzz, invariants) - Add API services (REST, GraphQL, orchestrator, packet service) - Add documentation (ISO20022 mapping, runbooks, adapter guides) - Add development tools (RBC tool, Swagger UI, mock server) - Update OpenZeppelin submodules to v5.0.0
89 lines
2.6 KiB
Solidity
89 lines
2.6 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
import "forge-std/Test.sol";
|
|
import "../../src/ComplianceRegistry.sol";
|
|
import "../../src/interfaces/IComplianceRegistry.sol";
|
|
|
|
contract ComplianceRegistryTest is Test {
|
|
ComplianceRegistry public registry;
|
|
address public admin;
|
|
address public complianceRole;
|
|
address public account1;
|
|
address public account2;
|
|
|
|
event ComplianceUpdated(address indexed account, bool allowed, uint8 tier, bytes32 jurisdictionHash);
|
|
event FrozenUpdated(address indexed account, bool frozen);
|
|
|
|
function setUp() public {
|
|
admin = address(0x1);
|
|
complianceRole = address(0x2);
|
|
account1 = address(0x10);
|
|
account2 = address(0x20);
|
|
|
|
registry = new ComplianceRegistry(admin);
|
|
|
|
vm.startPrank(admin);
|
|
registry.grantRole(registry.COMPLIANCE_ROLE(), complianceRole);
|
|
vm.stopPrank();
|
|
}
|
|
|
|
function test_initialState() public {
|
|
assertFalse(registry.isAllowed(account1));
|
|
assertFalse(registry.isFrozen(account1));
|
|
assertEq(registry.riskTier(account1), 0);
|
|
assertEq(registry.jurisdictionHash(account1), bytes32(0));
|
|
}
|
|
|
|
function test_setCompliance() public {
|
|
bytes32 jurHash = keccak256("US");
|
|
uint8 tier = 2;
|
|
|
|
vm.expectEmit(true, false, false, true);
|
|
emit ComplianceUpdated(account1, true, tier, jurHash);
|
|
|
|
vm.prank(complianceRole);
|
|
registry.setCompliance(account1, true, tier, jurHash);
|
|
|
|
assertTrue(registry.isAllowed(account1));
|
|
assertEq(registry.riskTier(account1), tier);
|
|
assertEq(registry.jurisdictionHash(account1), jurHash);
|
|
}
|
|
|
|
function test_setCompliance_unauthorized() public {
|
|
vm.expectRevert();
|
|
registry.setCompliance(account1, true, 1, bytes32(0));
|
|
}
|
|
|
|
function test_setFrozen() public {
|
|
vm.expectEmit(true, false, false, true);
|
|
emit FrozenUpdated(account1, true);
|
|
|
|
vm.prank(complianceRole);
|
|
registry.setFrozen(account1, true);
|
|
|
|
assertTrue(registry.isFrozen(account1));
|
|
|
|
vm.expectEmit(true, false, false, true);
|
|
emit FrozenUpdated(account1, false);
|
|
|
|
vm.prank(complianceRole);
|
|
registry.setFrozen(account1, false);
|
|
|
|
assertFalse(registry.isFrozen(account1));
|
|
}
|
|
|
|
function test_setFrozen_unauthorized() public {
|
|
vm.expectRevert();
|
|
registry.setFrozen(account1, true);
|
|
}
|
|
|
|
function test_riskTier() public {
|
|
vm.prank(complianceRole);
|
|
registry.setCompliance(account1, true, 5, bytes32(0));
|
|
|
|
assertEq(registry.riskTier(account1), 5);
|
|
}
|
|
}
|
|
|