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

import { V3Fixtures } from "../helpers/V3Fixtures.sol";
import { PartnershipBondV3Safe } from "../../contracts/bonds/PartnershipBondV3Safe.sol";
import { AccountabilityBondV3Safe } from "../../contracts/bonds/AccountabilityBondV3Safe.sol";
import { BondStateV3 } from "../../contracts/bonds/BondStateV3.sol";

/// @notice Regression: generic consensus and dispute inputs are inert for both bond types.
contract BondDisputeHardeningV3Test is V3Fixtures {
    PartnershipBondV3Safe private partnership;
    AccountabilityBondV3Safe private accountability;

    function setUp() public {
        _setUpDependencies();
        partnership = new PartnershipBondV3Safe(
            owner, address(0), address(consensus), address(disputeRegistry), 10 ether, 20 ether, 100 ether, address(0)
        );
        accountability = new AccountabilityBondV3Safe(
            owner, address(consensus), address(disputeRegistry), 10 ether, 100 ether, address(0)
        );
    }

    function test_genericAttestationAndDisputeCallsFailClosed() external {
        (bool attestOk,) = address(accountability)
            .call(
                abi.encodeWithSignature(
                    "attestBreach(uint256,uint256,bytes32,uint96)", 1, 1 ether, keccak256("quality-or-reputation"), 1
                )
            );
        (bool freezeOk,) =
            address(accountability).call(abi.encodeWithSignature("freezeSettlement(uint256,uint96)", 1, 1));
        assertFalse(attestOk || freezeOk);
        vm.expectRevert(PartnershipBondV3Safe.PilotMutualConsentOnly.selector);
        partnership.requestSettlement(1);
    }

    function test_expiryRecoveryLeavesNoDisputeDerivedState() external {
        uint256 id = _createPartnership(partnership, _partnershipTerms(1, 1 ether, 1 ether));
        _fundActivePartnership(partnership, id, 1 ether, 1 ether);
        PartnershipBondV3Safe.BondData memory bond = partnership.bondOf(id);
        vm.warp(bond.terms.activePeriodEnd);
        partnership.markExpired(id);
        partnership.forceExit(id);
        assertEq(uint256(partnership.bondOf(id).state), uint256(BondStateV3.State.ForceExited));
        assertEq(partnership.creditOf(address(0), partyA), 1 ether);
        assertEq(partnership.creditOf(address(0), partyB), 1 ether);
    }
}
