Skip to content

Commit

Permalink
test: PrivateERC20ResolutionModule unit tests (#51)
Browse files Browse the repository at this point in the history
# 🤖 Linear

Closes OPO-201
  • Loading branch information
0xng authored Jul 26, 2023
2 parents 2eaf5d6 + c2f98e4 commit 295290a
Show file tree
Hide file tree
Showing 3 changed files with 596 additions and 6 deletions.
10 changes: 5 additions & 5 deletions solidity/contracts/modules/PrivateERC20ResolutionModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ contract PrivateERC20ResolutionModule is Module, IPrivateERC20ResolutionModule {

// todo: this storage layout must be super optimizable. many disputeId mappings
mapping(bytes32 _disputeId => EscalationData _escalationData) public escalationData;
mapping(bytes32 _disputeId => mapping(address _voter => VoterData)) private _votersData;
mapping(bytes32 _disputeId => uint256 _numOfVotes) public totalNumberOfVotes;
mapping(bytes32 _disputeId => EnumerableSet.AddressSet _votersSet) private _voters;
mapping(bytes32 _disputeId => mapping(address _voter => VoterData)) public _votersData;
mapping(bytes32 _disputeId => EnumerableSet.AddressSet _votersSet) internal _voters;

constructor(IOracle _oracle) Module(_oracle) {}

Expand Down Expand Up @@ -73,8 +72,8 @@ contract PrivateERC20ResolutionModule is Module, IPrivateERC20ResolutionModule {
_escalationData.startTime + _commitingTimeWindow,
_escalationData.startTime + _commitingTimeWindow + _revealingTimeWindow
);
if (block.timestamp < _revealStartTime) revert PrivateERC20ResolutionModule_OnGoingCommitingPhase();
if (block.timestamp >= _revealEndTime) revert PrivateERC20ResolutionModule_RevealingPhaseOver();
if (block.timestamp <= _revealStartTime) revert PrivateERC20ResolutionModule_OnGoingCommitingPhase();
if (block.timestamp > _revealEndTime) revert PrivateERC20ResolutionModule_RevealingPhaseOver();

VoterData storage _voterData = _votersData[_disputeId][msg.sender];

Expand All @@ -83,6 +82,7 @@ contract PrivateERC20ResolutionModule is Module, IPrivateERC20ResolutionModule {
}

_voterData.numOfVotes = _numberOfVotes;
_voterData.commitment = bytes32('');
_voters[_disputeId].add(msg.sender);
escalationData[_disputeId].totalVotes += _numberOfVotes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ interface IPrivateERC20ResolutionModule is IResolutionModule {
function escalationData(bytes32 _disputeId) external view returns (uint256 _startTime, uint256 _totalVotes);
// TODO: create getter -- see if its possible to declare this
// function votes(bytes32 _disputeId) external view returns (VoterData memory _voterData);
function totalNumberOfVotes(bytes32 _disputeId) external view returns (uint256 _numOfVotes);
function commitVote(bytes32 _requestId, bytes32 _disputeId, bytes32 _commitment) external;
function revealVote(bytes32 _requestId, bytes32 _disputeId, uint256 _numberOfVotes, bytes32 _salt) external;
function resolveDispute(bytes32 _disputeId) external;
Expand Down
Loading

0 comments on commit 295290a

Please sign in to comment.