Skip to content

Commit

Permalink
feat: test
Browse files Browse the repository at this point in the history
  • Loading branch information
ashitakah committed Jul 22, 2024
1 parent 79e87df commit 19c3ca1
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions solidity/test/unit/modules/dispute/BondEscalationModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,51 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest {
bondEscalationModule.onDisputeStatusChange(_disputeId, mockRequest, mockResponse, mockDispute);
}

/**
* @notice Tests that onDisputeStatusChange pays the disputer if the disputer won
*/
function test_callPayIfNormalDisputeWonPledgesForDispute(
IBondEscalationModule.RequestParameters memory _params,
address[] memory _pledgersforDispute
) public assumeFuzzable(address(_params.accountingExtension)) {
vm.assume(_pledgersforDispute.length > 0 && _pledgersforDispute.length < 10);
_params.accountingExtension = IBondEscalationAccounting(makeAddr('BondEscalationAccounting'));
mockRequest.disputeModuleData = abi.encode(_params);
bytes32 _requestId = _getId(mockRequest);

mockDispute.requestId = _requestId;
bytes32 _disputeId = _getId(mockDispute);

// Mock and expect IAccountingExtension.pay to be called
_mockAndExpect(
address(_params.accountingExtension),
abi.encodeCall(
IAccountingExtension.pay,
(_requestId, mockDispute.proposer, mockDispute.disputer, _params.bondToken, _params.bondSize)
),
abi.encode(true)
);

// Mock and expect IAccountingExtension.pay to be called
_mockAndExpect(
address(_params.accountingExtension),
abi.encodeCall(
IAccountingExtension.release, (mockDispute.disputer, _requestId, _params.bondToken, _params.bondSize)
),
abi.encode(true)
);

// Mock and expect IOracle.createdAt to be called
_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.disputeStatus, (_disputeId)), abi.encode(IOracle.DisputeStatus.Won)
);

bondEscalationModule.forTest_setBondEscalation(_requestId, _pledgersforDispute, new address[](0));

vm.prank(address(oracle));
bondEscalationModule.onDisputeStatusChange(_disputeId, mockRequest, mockResponse, mockDispute);
}

function test_emitsEvent(IBondEscalationModule.RequestParameters memory _params)
public
assumeFuzzable(address(_params.accountingExtension))
Expand Down

0 comments on commit 19c3ca1

Please sign in to comment.