generated from defi-wonderland/solidity-foundry-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(medusa): handlers and working setup
- Loading branch information
1 parent
5d5fd14
commit 3b77715
Showing
23 changed files
with
1,371 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import {PropertyParent} from './properties/PropertyParent.t.sol'; | ||
|
||
contract FuzzTest is PropertyParent { | ||
function test_debug() public { | ||
assert(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import {ValidatorLib} from '@defi-wonderland/prophet-core/solidity/libraries/ValidatorLib.sol'; | ||
|
||
import { | ||
BondEscalationModule, | ||
IBondEscalationModule | ||
} from '@defi-wonderland/prophet-modules/solidity/contracts/modules/dispute/BondEscalationModule.sol'; | ||
|
||
import { | ||
ArbitratorModule, | ||
IArbitratorModule | ||
} from '@defi-wonderland/prophet-modules/solidity/contracts/modules/resolution/ArbitratorModule.sol'; | ||
import { | ||
BondedResponseModule, | ||
IBondedResponseModule | ||
} from '@defi-wonderland/prophet-modules/solidity/contracts/modules/response/BondedResponseModule.sol'; | ||
import {IArbitrator} from '@defi-wonderland/prophet-modules/solidity/interfaces/IArbitrator.sol'; | ||
import {IAccountingExtension} from | ||
'@defi-wonderland/prophet-modules/solidity/interfaces/extensions/IAccountingExtension.sol'; | ||
import {IBondEscalationAccounting} from | ||
'@defi-wonderland/prophet-modules/solidity/interfaces/extensions/IBondEscalationAccounting.sol'; | ||
|
||
import {IArbitrable, IArbitratorModule, ICouncilArbitrator, IOracle} from 'interfaces/ICouncilArbitrator.sol'; | ||
|
||
import {Utils} from './helpers/Utils.t.sol'; | ||
|
||
import {IEBOFinalityModule} from 'interfaces/IEBOFinalityModule.sol'; | ||
import {IEBORequestModule} from 'interfaces/IEBORequestModule.sol'; | ||
|
||
import {IEpochManager} from 'interfaces/external/IEpochManager.sol'; | ||
import {IHorizonStaking} from 'interfaces/external/IHorizonStaking.sol'; | ||
|
||
import {FuzzERC20, IERC20} from './helpers/FuzzERC20.sol'; | ||
|
||
import {IOracle, Oracle} from '@defi-wonderland/prophet-core/solidity/contracts/Oracle.sol'; | ||
|
||
import {BondEscalationModule} from | ||
'@defi-wonderland/prophet-modules/solidity/contracts/modules/dispute/BondEscalationModule.sol'; | ||
import {BondedResponseModule} from | ||
'@defi-wonderland/prophet-modules/solidity/contracts/modules/response/BondedResponseModule.sol'; | ||
|
||
import {Arbitrable} from 'contracts/Arbitrable.sol'; | ||
import {CouncilArbitrator} from 'contracts/CouncilArbitrator.sol'; | ||
import {EBOFinalityModule} from 'contracts/EBOFinalityModule.sol'; | ||
import {EBORequestCreator, IEBORequestCreator} from 'contracts/EBORequestCreator.sol'; | ||
import {EBORequestModule} from 'contracts/EBORequestModule.sol'; | ||
|
||
import {HorizonAccountingExtension} from 'contracts/HorizonAccountingExtension.sol'; | ||
|
||
import {MockEpochManager} from './helpers/MockEpochManager.t.sol'; | ||
import {MockHorizonStaking} from './helpers/MockHorizonStaking.t.sol'; | ||
|
||
contract Setup is Utils { | ||
// Core contracts | ||
Oracle internal oracle; | ||
EBORequestCreator internal eboRequestCreator; | ||
EBORequestModule internal eboRequestModule; | ||
BondedResponseModule internal bondedResponseModule; | ||
BondEscalationModule internal bondEscalationModule; | ||
CouncilArbitrator internal councilArbitrator; | ||
EBOFinalityModule internal eboFinalityModule; | ||
Arbitrable internal arbitrable; | ||
HorizonAccountingExtension internal horizonAccountingExtension; | ||
ArbitratorModule internal arbitratorModule; | ||
|
||
// External contracts (mocked) | ||
IHorizonStaking internal horizonStaking; | ||
IERC20 internal GRT; | ||
IEpochManager internal epochManager; | ||
|
||
// Constants | ||
uint256 internal constant START_EPOCH = 1000; | ||
uint64 internal constant MIN_THAWING_PERIOD = 1 days; | ||
uint128 internal constant INITIAL_MAX_USERS_TO_CHECK = 10; | ||
uint32 internal constant MAX_VERIFIER_CUT = 1_000_000; | ||
|
||
uint256 internal constant PAYMENT_AMOUNT = 0 ether; | ||
|
||
uint256 internal constant RESPONSE_BOND_SIZE = 0.5 ether; | ||
uint256 internal constant RESPONSE_DEADLINE = 5 days; | ||
uint256 internal constant RESPONSE_DISPUTE_WINDOW = 1 weeks; | ||
|
||
uint256 internal constant DISPUTE_BOND_SIZE = 0.3 ether; | ||
uint256 internal constant MAX_NB_ESCALATION = 2; | ||
uint256 internal constant DISPUTE_DEADLINE = 10 days; | ||
uint256 internal constant TYING_BUFFER = 3 days; | ||
uint256 internal constant DISPUTE_DISPUTE_WINDOW = 2 weeks; | ||
|
||
constructor() { | ||
// Deploy mock contracts | ||
GRT = IERC20(address(new FuzzERC20())); | ||
epochManager = IEpochManager(address(new MockEpochManager(START_EPOCH))); | ||
horizonStaking = IHorizonStaking(address(new MockHorizonStaking(GRT))); | ||
|
||
// Deploy core contracts | ||
arbitrable = new Arbitrable( | ||
address(this), // Initial arbitrator | ||
address(this) // Initial council | ||
); | ||
|
||
oracle = new Oracle(); | ||
|
||
eboRequestModule = new EBORequestModule( | ||
oracle, | ||
EBORequestCreator(address(0)), //eboRequestCreator will be set after creation | ||
arbitrable | ||
); | ||
|
||
bondedResponseModule = new BondedResponseModule(oracle); | ||
|
||
bondEscalationModule = new BondEscalationModule(oracle); | ||
|
||
arbitratorModule = new ArbitratorModule(oracle); | ||
|
||
councilArbitrator = new CouncilArbitrator(arbitratorModule, arbitrable); | ||
|
||
eboFinalityModule = new EBOFinalityModule( | ||
oracle, | ||
EBORequestCreator(address(0)), // Will be set after creation | ||
arbitrable | ||
); | ||
|
||
// Set up accounting extension | ||
address[] memory authorizedCallers = new address[](1); | ||
authorizedCallers[0] = address(bondEscalationModule); | ||
|
||
horizonAccountingExtension = new HorizonAccountingExtension( | ||
horizonStaking, oracle, GRT, arbitrable, MIN_THAWING_PERIOD, INITIAL_MAX_USERS_TO_CHECK, authorizedCallers | ||
); | ||
|
||
// Create EBO request creator with initial parameters | ||
IOracle.Request memory initialRequest = IOracle.Request({ | ||
requestModule: address(eboRequestModule), | ||
responseModule: address(bondedResponseModule), | ||
disputeModule: address(bondEscalationModule), | ||
resolutionModule: address(arbitratorModule), | ||
finalityModule: address(eboFinalityModule), | ||
requester: address(0), // Will be set to eboRequestCreator's address | ||
requestModuleData: '', | ||
responseModuleData: '', | ||
disputeModuleData: '', | ||
resolutionModuleData: '', | ||
finalityModuleData: '', | ||
nonce: 0 | ||
}); | ||
|
||
eboRequestCreator = new EBORequestCreator(oracle, epochManager, arbitrable, initialRequest); | ||
|
||
// Initialize modules with eboRequestCreator | ||
eboRequestModule.addEBORequestCreator(eboRequestCreator); | ||
eboFinalityModule.addEBORequestCreator(eboRequestCreator); | ||
|
||
// Set up module permissions | ||
horizonAccountingExtension.approveModule(address(bondedResponseModule)); | ||
horizonAccountingExtension.approveModule(address(bondEscalationModule)); | ||
|
||
// Set up initial chain IDs | ||
eboRequestCreator.addChain('mainnet'); | ||
eboRequestCreator.addChain('optimism'); | ||
eboRequestCreator.addChain('arbitrum'); | ||
|
||
// Set up initial module parameters | ||
_setupModuleParameters(); | ||
} | ||
|
||
function _setupModuleParameters() internal { | ||
// Set up request module parameters | ||
IEBORequestModule.RequestParameters memory requestParams = IEBORequestModule.RequestParameters({ | ||
epoch: START_EPOCH, | ||
chainId: 'mainnet', | ||
accountingExtension: IAccountingExtension(address(horizonAccountingExtension)), | ||
paymentAmount: PAYMENT_AMOUNT | ||
}); | ||
eboRequestCreator.setRequestModuleData(address(eboRequestModule), requestParams); | ||
|
||
// Set up response module parameters | ||
IBondedResponseModule.RequestParameters memory responseParams = IBondedResponseModule.RequestParameters({ | ||
accountingExtension: IAccountingExtension(address(horizonAccountingExtension)), | ||
bondToken: GRT, | ||
bondSize: RESPONSE_BOND_SIZE, | ||
deadline: RESPONSE_DEADLINE, | ||
disputeWindow: RESPONSE_DISPUTE_WINDOW | ||
}); | ||
eboRequestCreator.setResponseModuleData(address(bondedResponseModule), responseParams); | ||
|
||
// Set up dispute module parameters | ||
IBondEscalationModule.RequestParameters memory disputeParams = IBondEscalationModule.RequestParameters({ | ||
accountingExtension: IBondEscalationAccounting(address(horizonAccountingExtension)), | ||
bondToken: GRT, | ||
bondSize: DISPUTE_BOND_SIZE, | ||
maxNumberOfEscalations: MAX_NB_ESCALATION, | ||
bondEscalationDeadline: DISPUTE_DEADLINE, | ||
tyingBuffer: TYING_BUFFER, | ||
disputeWindow: DISPUTE_DISPUTE_WINDOW | ||
}); | ||
eboRequestCreator.setDisputeModuleData(address(bondEscalationModule), disputeParams); | ||
|
||
// Set up resolution module parameters | ||
IArbitratorModule.RequestParameters memory resolutionParams = | ||
IArbitratorModule.RequestParameters({arbitrator: address(councilArbitrator)}); | ||
eboRequestCreator.setResolutionModuleData(address(arbitratorModule), resolutionParams); | ||
|
||
// Set finality module | ||
eboRequestCreator.setFinalityModuleData(address(eboFinalityModule)); | ||
} | ||
} |
Oops, something went wrong.