Skip to content

Commit

Permalink
refactor: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJabberwock committed Aug 5, 2024
1 parent 0b7fb0c commit efdec74
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 47 deletions.
26 changes: 13 additions & 13 deletions src/contracts/EBOFinalityModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ contract EBOFinalityModule is Module, IEBOFinalityModule {
/// @inheritdoc IEBOFinalityModule
address public arbitrator;

/**
* @notice Constructor
* @param _oracle The address of the oracle
* @param _arbitrator The address of The Graph's Arbitrator
*/
constructor(IOracle _oracle, address _eboRequestCreator, address _arbitrator) Module(_oracle) {
eboRequestCreator = _eboRequestCreator;
arbitrator = _arbitrator;
}

/**
* @notice Checks that the caller is The Graph's Arbitrator
*/
Expand All @@ -37,9 +27,14 @@ contract EBOFinalityModule is Module, IEBOFinalityModule {
_;
}

/// @inheritdoc IModule
function moduleName() external pure returns (string memory _moduleName) {
_moduleName = 'EBOFinalityModule';
/**
* @notice Constructor
* @param _oracle The address of the oracle
* @param _arbitrator The address of The Graph's Arbitrator
*/
constructor(IOracle _oracle, address _eboRequestCreator, address _arbitrator) Module(_oracle) {

Check warning on line 35 in src/contracts/EBOFinalityModule.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Variable "_oracle" is unused
eboRequestCreator = _eboRequestCreator;
arbitrator = _arbitrator;
}

/// @inheritdoc IEBOFinalityModule
Expand Down Expand Up @@ -80,4 +75,9 @@ contract EBOFinalityModule is Module, IEBOFinalityModule {
function setArbitrator(address _arbitrator) external onlyArbitrator {
arbitrator = _arbitrator;
}

/// @inheritdoc IModule
function moduleName() external pure returns (string memory _moduleName) {
_moduleName = 'EBOFinalityModule';
}
}
6 changes: 5 additions & 1 deletion src/interfaces/IEBOFinalityModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface IEBOFinalityModule is IFinalityModule {
error EBOFinalityModule_LengthMismatch();

/*///////////////////////////////////////////////////////////////
LOGIC
VARIABLES
//////////////////////////////////////////////////////////////*/

/**
Expand All @@ -66,6 +66,10 @@ interface IEBOFinalityModule is IFinalityModule {
*/
function arbitrator() external view returns (address _arbitrator);

/*///////////////////////////////////////////////////////////////
LOGIC
//////////////////////////////////////////////////////////////*/

/**
* @notice Finalizes the request by publishing the response
* @dev Callable only by the oracle
Expand Down
68 changes: 35 additions & 33 deletions test/unit/EBOFinalityModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {EBOFinalityModule} from 'contracts/EBOFinalityModule.sol';

import 'forge-std/Test.sol';

contract BaseTest is Test {
contract EBOFinalityModule_Unit_BaseTest is Test {
EBOFinalityModule public eboFinalityModule;

IOracle public oracle;
Expand Down Expand Up @@ -47,57 +47,61 @@ contract BaseTest is Test {
}
}

contract EBOFinalityModule_Unit_Constructor is BaseTest {
function test_setOracle() public {
contract EBOFinalityModule_Unit_Constructor is EBOFinalityModule_Unit_BaseTest {
function test_setOracle() public view {
assertEq(address(eboFinalityModule.ORACLE()), address(oracle));
}

function test_setEBORequestCreator() public {
function test_setEBORequestCreator() public view {
assertEq(eboFinalityModule.eboRequestCreator(), eboRequestCreator);
}

function test_setArbitrator() public {
function test_setArbitrator() public view {
assertEq(eboFinalityModule.arbitrator(), arbitrator);
}
}

contract EBOFinalityModule_Unit_ModuleName is BaseTest {
function test_returnModuleName() public {
assertEq(eboFinalityModule.moduleName(), 'EBOFinalityModule');
contract EBOFinalityModule_Unit_FinalizeRequest is EBOFinalityModule_Unit_BaseTest {
modifier happyPath(IOracle.Request memory _request, IOracle.Response memory _response) {
_request.requester = eboRequestCreator;
_response.requestId = _getId(_request);

vm.startPrank(address(oracle));
_;
}
}

contract EBOFinalityModule_Unit_FinalizeRequest is BaseTest {
function test_revertOnlyOracle(
IOracle.Request memory _request,
IOracle.Response memory _response,
address _finalizer
) public {
) public happyPath(_request, _response) {
vm.stopPrank();
vm.expectRevert(IModule.Module_OnlyOracle.selector);
eboFinalityModule.finalizeRequest(_request, _response, _finalizer);
}

function test_revertInvalidRequester(
IOracle.Request memory _request,
IOracle.Response memory _response,
address _finalizer
) public {
vm.assume(_request.requester != eboRequestCreator);
address _finalizer,
address _requester
) public happyPath(_request, _response) {
vm.assume(_requester != eboRequestCreator);
_request.requester = _requester;

vm.prank(address(oracle));
vm.expectRevert(IEBOFinalityModule.EBOFinalityModule_InvalidRequester.selector);
eboFinalityModule.finalizeRequest(_request, _response, _finalizer);
}

function test_revertInvalidResponseBody(
IOracle.Request memory _request,
IOracle.Response memory _response,
address _finalizer
) public {
_request.requester = eboRequestCreator;
vm.assume(_response.requestId != _getId(_request));
address _finalizer,
bytes32 _requestId
) public happyPath(_request, _response) {
vm.assume(_requestId != _getId(_request));
_response.requestId = _requestId;

vm.prank(address(oracle));
vm.expectRevert(IModule.Module_InvalidResponseBody.selector);
eboFinalityModule.finalizeRequest(_request, _response, _finalizer);
}
Expand All @@ -106,12 +110,8 @@ contract EBOFinalityModule_Unit_FinalizeRequest is BaseTest {
IOracle.Request memory _request,
IOracle.Response memory _response,
address _finalizer
) public {
_request.requester = eboRequestCreator;
_response.requestId = _getId(_request);
) public happyPath(_request, _response) {
vm.skip(true);

vm.prank(address(oracle));
// vm.expectEmit();
// emit NewEpoch(_response.epoch, _response.chainId, _response.block);
eboFinalityModule.finalizeRequest(_request, _response, _finalizer);
Expand All @@ -121,18 +121,14 @@ contract EBOFinalityModule_Unit_FinalizeRequest is BaseTest {
IOracle.Request memory _request,
IOracle.Response memory _response,
address _finalizer
) public {
_request.requester = eboRequestCreator;
_response.requestId = _getId(_request);

vm.prank(address(oracle));
) public happyPath(_request, _response) {
vm.expectEmit();
emit RequestFinalized(_response.requestId, _response, _finalizer);
eboFinalityModule.finalizeRequest(_request, _response, _finalizer);
}
}

contract EBOFinalityModule_Unit_AmendEpoch is BaseTest {
contract EBOFinalityModule_Unit_AmendEpoch is EBOFinalityModule_Unit_BaseTest {
function test_revertOnlyArbitrator(
uint256 _epoch,
uint256[] calldata _chainIds,
Expand Down Expand Up @@ -171,7 +167,7 @@ contract EBOFinalityModule_Unit_AmendEpoch is BaseTest {
}
}

contract EBOFinalityModule_Unit_SetEBORequestCreator is BaseTest {
contract EBOFinalityModule_Unit_SetEBORequestCreator is EBOFinalityModule_Unit_BaseTest {
function test_revertOnlyArbitrator(address _eboRequestCreator) public {
vm.expectRevert(IEBOFinalityModule.EBOFinalityModule_OnlyArbitrator.selector);
eboFinalityModule.setEBORequestCreator(_eboRequestCreator);
Expand All @@ -185,7 +181,7 @@ contract EBOFinalityModule_Unit_SetEBORequestCreator is BaseTest {
}
}

contract EBOFinalityModule_Unit_SetArbitrator is BaseTest {
contract EBOFinalityModule_Unit_SetArbitrator is EBOFinalityModule_Unit_BaseTest {
function test_revertOnlyArbitrator(address _arbitrator) public {
vm.expectRevert(IEBOFinalityModule.EBOFinalityModule_OnlyArbitrator.selector);
eboFinalityModule.setArbitrator(_arbitrator);
Expand All @@ -198,3 +194,9 @@ contract EBOFinalityModule_Unit_SetArbitrator is BaseTest {
assertEq(eboFinalityModule.arbitrator(), _arbitrator);
}
}

contract EBOFinalityModule_Unit_ModuleName is EBOFinalityModule_Unit_BaseTest {
function test_returnModuleName() public view {
assertEq(eboFinalityModule.moduleName(), 'EBOFinalityModule');
}
}

0 comments on commit efdec74

Please sign in to comment.