Skip to content

Commit

Permalink
test: add unit test for when user did not approve the access module
Browse files Browse the repository at this point in the history
  • Loading branch information
xorsal committed Nov 8, 2024
1 parent fc27d21 commit 2b5a988
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions solidity/test/unit/modules/dispute/BondEscalationModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '../../../../contracts/utils/Typehash.sol';
import {IAccountingExtension} from '../../../../interfaces/extensions/IAccountingExtension.sol';
import {IBondEscalationAccounting} from '../../../../interfaces/extensions/IBondEscalationAccounting.sol';
import {IModuleAccessController} from '../../../../interfaces/modules/access/IModuleAccessController.sol';

/**
* @dev Harness to set an entry in the requestData mapping, without triggering setup request hooks
Expand Down Expand Up @@ -1507,7 +1508,7 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest {
super.setUp();
}

function test_pledgeForDispute_accessControl(
function test_pledgeForDispute_accessControl_granted(
address _caller,
address _user,
bytes memory _data,
Expand Down Expand Up @@ -1552,12 +1553,7 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest {
sender: _caller,
accessControl: _accessControl,
typehash: _PLEDGE_FOR_DISPUTE_TYPEHASH,
<<<<<<< HEAD
typehashParams: abi.encode(mockRequest, _dispute)
=======
typehashParams: abi.encode(mockRequest, _dispute),
accessControl: _accessControl
>>>>>>> 1045a6d (refactor: rename modules/accessControl to modules/access)
})
)
)
Expand All @@ -1577,7 +1573,29 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest {
bondEscalationModule.pledgeForDispute(mockRequest, _dispute, _accessControl);
}

function test_pledgeAgainstDispute_accessControl(
function test_pledgeForDispute_accessControl_notGranted(
address _caller,
address _user,
bytes memory _data,
IBondEscalationModule.RequestParameters memory _params
) public assumeFuzzable(address(_params.accountingExtension)) {
vm.assume(_caller != _user);

// mock and expect a call checking whether the access module has been approved by the user
_mockAndExpect(
address(oracle),
abi.encodeCall(IOracleAccessController.isAccessModuleApproved, (_user, _accessModule)),
abi.encode(false)
);

IAccessController.AccessControl memory _accessControl = IAccessController.AccessControl({user: _user, data: _data});

vm.expectRevert(IModuleAccessController.ModuleAccessController_AccessModuleNotApproved.selector);
vm.prank(_caller);
bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _accessControl);
}

function test_pledgeAgainstDispute_accessControl_granted(
address _caller,
address _user,
bytes memory _data,
Expand Down

0 comments on commit 2b5a988

Please sign in to comment.