// 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 { BondMathLibV3 } from "../../contracts/lib/BondMathLibV3.sol";

/// @notice Legacy dispute compatibility calls must be inert: no dispute can change custody.
contract ChallengeRemedyV3Test 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_disputeAndChallengeCompatibilityEntriesFailClosed() external {
        BondMathLibV3.Split memory split = BondMathLibV3.Split(5000, 5000, 0);
        vm.expectRevert(PartnershipBondV3Safe.PilotMutualConsentOnly.selector);
        partnership.challengeSettlement(1, 1);
        vm.expectRevert(PartnershipBondV3Safe.PilotMutualConsentOnly.selector);
        partnership.resolveChallenge(1);
        vm.expectRevert(PartnershipBondV3Safe.PilotMutualConsentOnly.selector);
        partnership.releaseDisputePayout(1, partyA, 0);
        vm.expectRevert(PartnershipBondV3Safe.PilotMutualConsentOnly.selector);
        partnership.freezeSettlement(1, 1, split);

        (bool challengeOk,) =
            address(accountability).call(abi.encodeWithSignature("challengeSettlement(uint256,uint256)", 1, 1));
        assertFalse(challengeOk);
        (bool resolveOk,) = address(accountability).call(abi.encodeWithSignature("resolveChallenge(uint256)", 1));
        (bool payoutOk,) = address(accountability)
            .call(abi.encodeWithSignature("releaseDisputePayout(uint256,address,uint256)", 1, partyA, 0));
        assertFalse(resolveOk || payoutOk);
    }
}
