Testing disputable contracts
Guide and API description of different mock contracts.
Last updated
Was this helpful?
Guide and API description of different mock contracts.
Last updated
Was this helpful?
The celeste-helpers
package provides a number of mocks which simulate the DisputeManger, AragonCourt and Arbitrator Manifest API's and their functionality on a basic level. This should help when creating tests for Disputable contracts as you can avoid all the overhead necessary to fork xDai or even deploy a full Celeste instance in your test environment.
As the name implies is an ERC20 token that is easy to instantiate for tests. TestERC20
supports all standard ERC20 methods and events along with additional methods defined in@openzeppelin/contracts/token/ERC20/ERC20.sol
.
This contract takes no constructor arguments. The deployer address will automatically be assigned as the token owner. Ownership can queried, transferred and revoked based on .
TestERC20.mint(address, uint256) -> ()
address _recipient
:
Recipient of newly minted test tokens
uint256 _amount
:
Amount of test tokens to be minted
In accordance to the recommendation in the ERC20 spec a ERC20.Transfer
event is transferred with the from
address being the zero address and the to
address being the _recipient
Method issues new tokens to recipient. Reverts if caller is not the owner. This is to avoid accidental mints within your tests.
The mock for these contracts is a single contract taking up the functionality and the API of both. The mock only simulates the necessary methods so that evidence can be submitted, disputes can be settled and rulings can be set.
The Dispute Lifecycle is mostly absent for disputes created within the mocks. Once created they'll be open, existing indefinitely until the owner sets a ruling.
celest-helpers/contracts/mocks/MockArbitrator.sol
APIIdentical to the normal Arbitrator Manifest except it's only compatible with the AragonCourt / DisputeManager mock. The outward facing API is also identical.
Stores the _feeToken
address in an immutable property and sets the instantiating address as the owner of this instance. Uses for ownership.
For a concrete example on how a test for a Disputable contract using the mocks looks like check out the test for the WorkAgreement
contract described in the section. The test can be found .