Skip to content

Commit

Permalink
update arbitration policy fix (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spablob authored Nov 28, 2024
1 parent 4bd1147 commit c340938
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/modules/dispute/DisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ contract DisputeModule is
if (!$.isWhitelistedArbitrationPolicy[nextArbitrationPolicy])
revert Errors.DisputeModule__NotWhitelistedArbitrationPolicy();

// if applicable updates the active arbitration policy to the queued arbitration policy
// before setting the new next arbitration policy
_updateActiveArbitrationPolicy(ipId);

$.nextArbitrationPolicies[ipId] = nextArbitrationPolicy;

uint256 nextArbitrationUpdateTimestamp = block.timestamp + $.arbitrationPolicyCooldown;
Expand Down
21 changes: 21 additions & 0 deletions test/foundry/modules/dispute/DisputeModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,27 @@ contract DisputeModuleTest is BaseTest {
assertEq(disputeModule.nextArbitrationUpdateTimestamps(ipAddr), block.timestamp + 7 days);
}

function test_DisputeModule_setArbitrationPolicy_WithQueuedPolicy() public {
vm.startPrank(u.admin);
disputeModule.whitelistArbitrationPolicy(address(mockArbitrationPolicy2), true);
vm.stopPrank();

vm.startPrank(ipAddr);

vm.expectEmit(true, true, true, true, address(disputeModule));
emit IDisputeModule.ArbitrationPolicySet(ipAddr, address(mockArbitrationPolicy2), block.timestamp + 7 days);

disputeModule.setArbitrationPolicy(ipAddr, address(mockArbitrationPolicy2));

vm.warp(block.timestamp + disputeModule.arbitrationPolicyCooldown() + 1);

disputeModule.setArbitrationPolicy(ipAddr, address(mockArbitrationPolicy));

assertEq(disputeModule.arbitrationPolicies(ipAddr), address(mockArbitrationPolicy2));
assertEq(disputeModule.nextArbitrationPolicies(ipAddr), address(mockArbitrationPolicy));
assertEq(disputeModule.nextArbitrationUpdateTimestamps(ipAddr), block.timestamp + 7 days);
}

function test_DisputeModule_raiseDispute_revert_NotRegisteredIpId() public {
vm.expectRevert(Errors.DisputeModule__NotRegisteredIpId.selector);
disputeModule.raiseDispute(address(1), disputeEvidenceHashExample, "IMPROPER_REGISTRATION", "");
Expand Down

0 comments on commit c340938

Please sign in to comment.