Skip to content

Commit 700738e

Browse files
committed
test: refactored to cover both shutter and gated DK combinations without duplicating the tests
1 parent 83a8ba6 commit 700738e

File tree

6 files changed

+1638
-1216
lines changed

6 files changed

+1638
-1216
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.24;
4+
5+
import "../arbitration/dispute-kits/DisputeKitGatedShutter.sol";
6+
7+
/// @title DisputeKitGatedShutterMock
8+
/// DisputeKitGatedShutter with view functions to use in Foundry tests.
9+
contract DisputeKitGatedShutterMock is DisputeKitGatedShutter {
10+
function extraDataToTokenInfo(
11+
bytes memory _extraData
12+
) public pure returns (address tokenGate, bool isERC1155, uint256 tokenId) {
13+
(tokenGate, isERC1155, tokenId) = _extraDataToTokenInfo(_extraData);
14+
}
15+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import {
2+
setupTokenGatedTest,
3+
testTokenWhitelistManagement,
4+
testAccessControl,
5+
testUnsupportedTokenErrors,
6+
testERC20Gating,
7+
testERC721Gating,
8+
testERC1155Gating,
9+
testWhitelistIntegration,
10+
TokenGatedTestContext,
11+
} from "./helpers/dispute-kit-gated-common";
12+
import {
13+
setupShutterTest,
14+
testCommitPhase,
15+
testNormalFlowBotReveals,
16+
testRecoveryFlowJurorReveals,
17+
testHashFunctionBehavior,
18+
testEdgeCasesAndSecurity,
19+
ShutterTestContext,
20+
} from "./helpers/dispute-kit-shutter-common";
21+
22+
/* eslint-disable no-unused-vars */
23+
/* eslint-disable no-unused-expressions */
24+
25+
/**
26+
* Test suite for DisputeKitGatedShutter - a dispute kit that requires jurors to hold
27+
* specific tokens (ERC20, ERC721, or ERC1155) to participate in disputes, with additional
28+
* Shutter functionality for commit-reveal voting.
29+
*
30+
* Tests cover:
31+
* - All DisputeKitGated functionality (via shared tests)
32+
* - Shutter-specific commit/reveal mechanism
33+
* - Recovery commits for juror vote recovery
34+
* - Integration between token gating and Shutter features
35+
*/
36+
describe("DisputeKitGatedShutter", async () => {
37+
describe("Token Gating Features", async () => {
38+
let tokenContext: TokenGatedTestContext;
39+
40+
beforeEach("Setup", async () => {
41+
tokenContext = await setupTokenGatedTest({ contractName: "DisputeKitGatedShutterMock" });
42+
});
43+
44+
// Run all shared token gating tests
45+
testTokenWhitelistManagement(() => tokenContext);
46+
testAccessControl(() => tokenContext);
47+
testUnsupportedTokenErrors(() => tokenContext);
48+
testERC20Gating(() => tokenContext);
49+
testERC721Gating(() => tokenContext);
50+
testERC1155Gating(() => tokenContext);
51+
testWhitelistIntegration(() => tokenContext);
52+
});
53+
54+
describe("Shutter Features", async () => {
55+
let shutterContext: ShutterTestContext;
56+
57+
beforeEach("Setup", async () => {
58+
// Setup DisputeKitGatedShutter with token gating enabled
59+
shutterContext = await setupShutterTest({
60+
contractName: "DisputeKitGatedShutter",
61+
isGated: true, // Enable token gating for DAI
62+
});
63+
});
64+
65+
// Run all shared Shutter tests
66+
testCommitPhase(() => shutterContext);
67+
testNormalFlowBotReveals(() => shutterContext);
68+
testRecoveryFlowJurorReveals(() => shutterContext);
69+
testHashFunctionBehavior(() => shutterContext);
70+
testEdgeCasesAndSecurity(() => shutterContext);
71+
});
72+
});

0 commit comments

Comments
 (0)