// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { PartnershipBondV3Safe } from "../../contracts/bonds/PartnershipBondV3Safe.sol";
import { BondMathLibV3 } from "../../contracts/lib/BondMathLibV3.sol";
import { V3Fixtures } from "../helpers/V3Fixtures.sol";

/// @title Inv08_SettlementInputsFrozen
/// @notice Generic settlement input paths are disabled; only typed mutual
///         authorization can determine a settlement split.
contract Inv08_SettlementInputsFrozen is V3Fixtures {
    PartnershipBondV3Safe internal bonds;
    uint256 internal bondId;

    function setUp() public {
        _setUpDependencies();
        bonds = new PartnershipBondV3Safe(
            owner, address(0), address(consensus), address(disputeRegistry), 10 ether, 20 ether, 100 ether, address(0)
        );
        bondId = _createPartnership(bonds, _partnershipTerms(8, 1 ether, 2 ether));
        _fundActivePartnership(bonds, bondId, 1 ether, 2 ether);
    }

    function test_legacyConsensusSplitCannotFreezeOrSettle() external {
        BondMathLibV3.Split memory split =
            BondMathLibV3.Split({ humanShareBps: 5000, aiShareBps: 5000, partnershipShareBps: 0 });
        vm.prank(partyA);
        vm.expectRevert(PartnershipBondV3Safe.PilotMutualConsentOnly.selector);
        bonds.requestSettlement(bondId);
        vm.expectRevert(PartnershipBondV3Safe.PilotMutualConsentOnly.selector);
        bonds.advanceToFinalizable(bondId);
        vm.expectRevert(PartnershipBondV3Safe.PilotMutualConsentOnly.selector);
        bonds.freezeSettlement(bondId, 8, split);
        vm.expectRevert(PartnershipBondV3Safe.PilotMutualConsentOnly.selector);
        bonds.settle(bondId);

        assertEq(bonds.creditOf(address(0), partyA), 0, "legacy split created party A payout");
        assertEq(bonds.creditOf(address(0), partyB), 0, "legacy split created party B payout");
    }
}
