// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Test} from "forge-std/Test.sol";
import {PolicyProfileRegistry} from "../../contracts/universal-resource/PolicyProfileRegistry.sol";

contract PolicyProfileRegistryTest is Test {
    PolicyProfileRegistry internal reg;
    address internal admin = address(0xA11CE);

    function setUp() public {
        vm.prank(admin);
        reg = new PolicyProfileRegistry(admin);
    }

    function testPublishAndRead() public {
        bytes32 h = keccak256("profile-json");
        vm.prank(admin);
        reg.publishProfile("institutional_custody_skr_v1", h, 1, block.timestamp);
        PolicyProfileRegistry.Record memory r = reg.getRecord("institutional_custody_skr_v1");
        assertTrue(r.exists);
        assertEq(r.contentHash, h);
        assertEq(r.version, 1);
    }

    function testProfileKeyStable() public view {
        assertEq(reg.profileKey("a"), keccak256(bytes("a")));
    }
}
