Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unlock without pledge #48

Merged
merged 8 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ contract BondEscalationModule is Module, IBondEscalationModule {
uint256 _pledgesForDispute = _escalation.amountOfPledgesForDispute;
uint256 _pledgesAgainstDispute = _escalation.amountOfPledgesAgainstDispute;

if (_pledgesAgainstDispute > 0) {
if (_pledgesAgainstDispute > 0 || _pledgesForDispute > 0) {
0xJabberwock marked this conversation as resolved.
Show resolved Hide resolved
0xJabberwock marked this conversation as resolved.
Show resolved Hide resolved
uint256 _amountToPay = _won
? _params.bondSize
+ FixedPointMathLib.mulDivDown(_pledgesAgainstDispute, _params.bondSize, _pledgesForDispute)
Expand Down
30 changes: 14 additions & 16 deletions solidity/test/unit/modules/dispute/BondEscalationModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,11 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest {
* the users that pledged in favor of the dispute, as they have won.
*/
function test_shouldChangeBondEscalationStatusAndCallPayPledgersWon(
IBondEscalationModule.RequestParameters memory _params
IBondEscalationModule.RequestParameters memory _params,
uint256 _numPledgers
) public assumeFuzzable(address(_params.accountingExtension)) {
vm.assume(_params.bondSize < type(uint256).max / 2);
vm.assume(_params.bondSize < type(uint128).max / 2);
vm.assume(_numPledgers > 0 && _numPledgers < 30);

IOracle.DisputeStatus _status = IOracle.DisputeStatus.Won;

Expand All @@ -798,11 +800,8 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest {
mockDispute.requestId = _requestId;
bytes32 _disputeId = _getId(mockDispute);

uint256 _numForPledgers = 2;
uint256 _numAgainstPledgers = 2;

// Set bond escalation data to have pledgers and to return the winning for pledgers as in this case they won the escalation
_setBondEscalation(_requestId, _numForPledgers, _numAgainstPledgers);
_setBondEscalation(_requestId, _numPledgers, _numPledgers);

// Set this dispute to have gone through the bond escalation process
bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId);
Expand Down Expand Up @@ -839,7 +838,7 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest {
address(_params.accountingExtension),
abi.encodeCall(
IBondEscalationAccounting.onSettleBondEscalation,
(_requestId, _disputeId, _params.bondToken, _params.bondSize << 1, _numForPledgers)
(_requestId, _disputeId, _params.bondToken, _params.bondSize << 1, _numPledgers)
),
abi.encode()
);
Expand All @@ -865,9 +864,11 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest {
* the users that pledged against the dispute, as those that pledged in favor have lost .
*/
function test_shouldChangeBondEscalationStatusAndCallPayPledgersLost(
IBondEscalationModule.RequestParameters memory _params
IBondEscalationModule.RequestParameters memory _params,
uint256 _numPledgers
) public assumeFuzzable(address(_params.accountingExtension)) {
vm.assume(_params.bondSize < type(uint256).max / 2);
vm.assume(_params.bondSize < type(uint128).max / 2);
vm.assume(_numPledgers > 0 && _numPledgers < 30);

// Set to Lost so the proposer and againstDisputePledgers win
IOracle.DisputeStatus _status = IOracle.DisputeStatus.Lost;
Expand All @@ -877,11 +878,8 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest {
mockDispute.requestId = _requestId;
bytes32 _disputeId = _getId(mockDispute);

uint256 _numForPledgers = 2;
uint256 _numAgainstPledgers = 2;

// Set bond escalation data to have pledgers and to return the winning for pledgers as in this case they won the escalation
_setBondEscalation(_requestId, _numForPledgers, _numAgainstPledgers);
_setBondEscalation(_requestId, _numPledgers, _numPledgers);

// Set this dispute to have gone through the bond escalation process
bondEscalationModule.forTest_setEscalatedDispute(_requestId, _disputeId);
Expand All @@ -905,13 +903,13 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest {
);

// Mock and expect IBondEscalationAccounting.onSettleBondEscalation to be called
vm.mockCall(
_mockAndExpect(
address(_params.accountingExtension),
abi.encodeCall(
IBondEscalationAccounting.onSettleBondEscalation,
(_requestId, _disputeId, _params.bondToken, _params.bondSize << 1, _numAgainstPledgers)
(_requestId, _disputeId, _params.bondToken, _params.bondSize << 1, _numPledgers)
),
abi.encode(true)
abi.encode()
);

// Check: is th event emitted?
Expand Down
Loading