Skip to content

Commit

Permalink
refactor: integration create request
Browse files Browse the repository at this point in the history
  • Loading branch information
ashitakah committed Aug 16, 2024
1 parent b3966e3 commit 4d1da18
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/contracts/EBORequestCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ pragma solidity 0.8.26;
import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';

import {Arbitrable} from 'contracts/Arbitrable.sol';

import {IEBORequestCreator, IEpochManager, IOracle} from 'interfaces/IEBORequestCreator.sol';
import {IAccountingExtension, IEBORequestModule} from 'interfaces/IEBORequestModule.sol';

contract EBORequestCreator is IEBORequestCreator, Arbitrable {
using EnumerableSet for EnumerableSet.Bytes32Set;
Expand Down Expand Up @@ -67,6 +69,10 @@ contract EBORequestCreator is IEBORequestCreator, Arbitrable {
|| (ORACLE.finalizedAt(_requestId) > 0 && ORACLE.finalizedResponseId(_requestId) == bytes32(0))
) {
// TODO: CREATE REQUEST DATA
_requestData.requestModuleData = abi.encode(
IEBORequestModule.RequestParameters(_epoch, _chainIds[_i], IAccountingExtension(address(0)), uint256(0))
);

_requestId = ORACLE.createRequest(_requestData, bytes32(0));

requestIdPerChainAndEpoch[_chainIds[_i]][_epoch] = _requestId;
Expand Down
6 changes: 1 addition & 5 deletions test/integration/arbitrum/CreateRequest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ contract Integration_CreateRequest is IntegrationBase {
vm.prank(_arbitrator);
_eboRequestCreator.addChain('chainId1');

bytes32 _requestId = keccak256('requestId');
// TODO: Remove the mock when the Oracle contract is implemented
vm.mockCall(address(_oracle), abi.encodeWithSelector(IOracle.createRequest.selector), abi.encode(_requestId));

vm.prank(_user);
_eboRequestCreator.createRequests(_currentEpoch, _chainIds);
assertEq(_eboRequestCreator.requestIdPerChainAndEpoch('chainId1', _currentEpoch), _requestId);
assertNotEq(_eboRequestCreator.requestIdPerChainAndEpoch('chainId1', _currentEpoch), bytes32(0));

// Remove the chain id
vm.prank(_arbitrator);
Expand Down
14 changes: 14 additions & 0 deletions test/integration/arbitrum/IntegrationBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,46 @@ import {Test} from 'forge-std/Test.sol';

import {Oracle} from '@defi-wonderland/prophet-core/solidity/contracts/Oracle.sol';
import {EBORequestCreator, IEBORequestCreator, IEpochManager, IOracle} from 'contracts/EBORequestCreator.sol';
import {EBORequestModule, IEBORequestModule} from 'contracts/EBORequestModule.sol';

contract IntegrationBase is Test {
uint256 internal constant _FORK_BLOCK = 240_000_000;

// Addresses
address internal _arbitrator = makeAddr('arbitrator');
address internal _council = makeAddr('council');
address internal _owner = makeAddr('owner');
address internal _user = makeAddr('user');

// Data
IOracle.Request _requestData;

Check warning on line 21 in test/integration/arbitrum/IntegrationBase.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Explicitly mark visibility of state

// Contracts
IEBORequestCreator internal _eboRequestCreator;
IEBORequestModule internal _eboRequestModule;
IOracle internal _oracle;
IEpochManager internal _epochManager;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('arbitrum'), _FORK_BLOCK);
vm.startPrank(_owner);

// Deploy Oracle
_oracle = new Oracle();

// Deploy EpochManager
_epochManager = IEpochManager(_EPOCH_MANAGER);

_requestData.nonce = 0;
// Deploy EBORequestCreator
_eboRequestCreator = new EBORequestCreator(_oracle, _epochManager, _arbitrator, _council, _requestData);

// Deploy EBORequestModule
_eboRequestModule = new EBORequestModule(_oracle, _eboRequestCreator, _arbitrator, _council);

vm.stopPrank();

vm.prank(_arbitrator);
_eboRequestCreator.setRequestModuleData(address(_eboRequestModule), bytes(''));
}
}

0 comments on commit 4d1da18

Please sign in to comment.