Skip to content

Commit 2166ee0

Browse files
committed
test: contracts getter tests with new dispute kits
1 parent f4ed9a0 commit 2166ee0

File tree

3 files changed

+128
-8
lines changed

3 files changed

+128
-8
lines changed

contracts/test/integration/getContractsEthers.test.ts

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import {
2020
BlockHashRNG__factory,
2121
PNK__factory,
2222
KlerosCoreSnapshotProxy__factory,
23+
DisputeKitShutter__factory,
24+
DisputeKitGated__factory,
25+
DisputeKitGatedShutter__factory,
2326
} from "../../typechain-types";
2427
import { getActualAddress } from "../utils/getActualAddress";
2528

@@ -39,10 +42,32 @@ type ContractMapping = {
3942
};
4043
};
4144

42-
const baseContractMapping: ContractMapping = {
45+
const devnetContractMapping: ContractMapping = {
4346
klerosCore: { name: "KlerosCore" },
4447
sortition: { name: "SortitionModule" },
4548
disputeKitClassic: { name: "DisputeKitClassic" },
49+
disputeKitShutter: { name: "DisputeKitShutter" },
50+
disputeKitGated: { name: "DisputeKitGated" },
51+
disputeKitGatedShutter: { name: "DisputeKitGatedShutter" },
52+
disputeResolver: { name: "DisputeResolver" },
53+
disputeTemplateRegistry: { name: "DisputeTemplateRegistry" },
54+
evidence: { name: "EvidenceModule" },
55+
policyRegistry: { name: "PolicyRegistry" },
56+
transactionBatcher: { name: "TransactionBatcher" },
57+
chainlinkRng: { name: "ChainlinkRNG", optional: true },
58+
randomizerRng: { name: "RandomizerRNG", optional: true },
59+
blockHashRng: { name: "BlockHashRNG" },
60+
pnk: { name: "PNK" },
61+
klerosCoreSnapshotProxy: { name: "KlerosCoreSnapshotProxy" },
62+
};
63+
64+
const testnetContractMapping: ContractMapping = {
65+
klerosCore: { name: "KlerosCore" },
66+
sortition: { name: "SortitionModule" },
67+
disputeKitClassic: { name: "DisputeKitClassic" },
68+
disputeKitShutter: { name: "DisputeKitShutter", optional: true },
69+
disputeKitGated: { name: "DisputeKitGated", optional: true },
70+
disputeKitGatedShutter: { name: "DisputeKitGatedShutter", optional: true },
4671
disputeResolver: { name: "DisputeResolver" },
4772
disputeTemplateRegistry: { name: "DisputeTemplateRegistry" },
4873
evidence: { name: "EvidenceModule" },
@@ -59,6 +84,9 @@ const universityContractMapping: ContractMapping = {
5984
klerosCore: { name: "KlerosCoreUniversity" },
6085
sortition: { name: "SortitionModuleUniversity" },
6186
disputeKitClassic: { name: "DisputeKitClassicUniversity" },
87+
disputeKitShutter: { name: "DisputeKitShutterUniversity", optional: true },
88+
disputeKitGated: { name: "DisputeKitGatedUniversity", optional: true },
89+
disputeKitGatedShutter: { name: "DisputeKitGatedShutterUniversity", optional: true },
6290
disputeResolver: { name: "DisputeResolverUniversity" },
6391
disputeTemplateRegistry: { name: "DisputeTemplateRegistry" },
6492
evidence: { name: "EvidenceModule" },
@@ -75,6 +103,9 @@ const neoContractMapping: ContractMapping = {
75103
klerosCore: { name: "KlerosCoreNeo" },
76104
sortition: { name: "SortitionModuleNeo" },
77105
disputeKitClassic: { name: "DisputeKitClassicNeo" },
106+
disputeKitShutter: { name: "DisputeKitShutterNeo", optional: true },
107+
disputeKitGated: { name: "DisputeKitGatedNeo", optional: true },
108+
disputeKitGatedShutter: { name: "DisputeKitGatedShutterNeo", optional: true },
78109
disputeResolver: { name: "DisputeResolverNeo" },
79110
disputeTemplateRegistry: { name: "DisputeTemplateRegistry" },
80111
evidence: { name: "EvidenceModule" },
@@ -87,7 +118,7 @@ const neoContractMapping: ContractMapping = {
87118
klerosCoreSnapshotProxy: { name: "KlerosCoreSnapshotProxy" },
88119
};
89120

90-
describe("getContractsEthers", () => {
121+
describe("getContractsEthers", async () => {
91122
// Use real providers for each network
92123
const arbitrumSepoliaProvider = new ethers.JsonRpcProvider("https://sepolia-rollup.arbitrum.io/rpc");
93124
const arbitrumProvider = new ethers.JsonRpcProvider("https://arb1.arbitrum.io/rpc");
@@ -104,6 +135,17 @@ describe("getContractsEthers", () => {
104135
provider: ethers.Provider
105136
) {
106137
expect(contracts.disputeKitClassic).to.be.instanceOf(getConstructor(DisputeKitClassic__factory, provider));
138+
if (contracts.disputeKitShutter) {
139+
expect(contracts.disputeKitShutter).to.be.instanceOf(getConstructor(DisputeKitShutter__factory, provider));
140+
}
141+
if (contracts.disputeKitGated) {
142+
expect(contracts.disputeKitGated).to.be.instanceOf(getConstructor(DisputeKitGated__factory, provider));
143+
}
144+
if (contracts.disputeKitGatedShutter) {
145+
expect(contracts.disputeKitGatedShutter).to.be.instanceOf(
146+
getConstructor(DisputeKitGatedShutter__factory, provider)
147+
);
148+
}
107149
expect(contracts.disputeResolver).to.be.instanceOf(getConstructor(DisputeResolver__factory, provider));
108150
expect(contracts.disputeTemplateRegistry).to.be.instanceOf(
109151
getConstructor(DisputeTemplateRegistry__factory, provider)
@@ -136,6 +178,15 @@ describe("getContractsEthers", () => {
136178
await verifyContractAddress(contracts.klerosCore.getAddress());
137179
await verifyContractAddress(contracts.sortition.getAddress());
138180
await verifyContractAddress(contracts.disputeKitClassic.getAddress());
181+
if (contracts.disputeKitShutter) {
182+
await verifyContractAddress(contracts.disputeKitShutter.getAddress());
183+
}
184+
if (contracts.disputeKitGated) {
185+
await verifyContractAddress(contracts.disputeKitGated.getAddress());
186+
}
187+
if (contracts.disputeKitGatedShutter) {
188+
await verifyContractAddress(contracts.disputeKitGatedShutter.getAddress());
189+
}
139190
await verifyContractAddress(contracts.disputeResolver.getAddress());
140191
await verifyContractAddress(contracts.disputeTemplateRegistry.getAddress());
141192
await verifyContractAddress(contracts.evidence.getAddress());
@@ -181,12 +232,15 @@ describe("getContractsEthers", () => {
181232
expect(contracts.klerosCore).to.be.instanceOf(getConstructor(KlerosCore__factory, arbitrumSepoliaProvider));
182233
expect(contracts.sortition).to.be.instanceOf(getConstructor(SortitionModule__factory, arbitrumSepoliaProvider));
183234
verifyCommonContractInstances(contracts, arbitrumSepoliaProvider);
235+
expect(contracts.disputeKitShutter).to.not.be.null;
236+
expect(contracts.disputeKitGated).to.not.be.null;
237+
expect(contracts.disputeKitGatedShutter).to.not.be.null;
184238
expect(contracts.chainlinkRng).to.not.be.null;
185239
expect(contracts.randomizerRng).to.be.null;
186240

187241
// Verify all contract addresses
188242
await verifyAllContractAddresses(contracts);
189-
await verifyDeployedAddresses(contracts, NETWORKS.DEVNET, baseContractMapping);
243+
await verifyDeployedAddresses(contracts, NETWORKS.DEVNET, devnetContractMapping);
190244
});
191245

192246
it("should return correct contract instances for university", async () => {
@@ -204,6 +258,9 @@ describe("getContractsEthers", () => {
204258
getConstructor(SortitionModuleUniversity__factory, arbitrumSepoliaProvider)
205259
);
206260
verifyCommonContractInstances(contracts, arbitrumSepoliaProvider);
261+
expect(contracts.disputeKitShutter).to.be.null;
262+
expect(contracts.disputeKitGated).to.be.null;
263+
expect(contracts.disputeKitGatedShutter).to.be.null;
207264
expect(contracts.chainlinkRng).to.not.be.null;
208265
expect(contracts.randomizerRng).to.be.null;
209266

@@ -223,12 +280,15 @@ describe("getContractsEthers", () => {
223280
expect(contracts.klerosCore).to.be.instanceOf(getConstructor(KlerosCore__factory, arbitrumSepoliaProvider));
224281
expect(contracts.sortition).to.be.instanceOf(getConstructor(SortitionModule__factory, arbitrumSepoliaProvider));
225282
verifyCommonContractInstances(contracts, arbitrumSepoliaProvider);
283+
expect(contracts.disputeKitShutter).to.be.null;
284+
expect(contracts.disputeKitGated).to.be.null;
285+
expect(contracts.disputeKitGatedShutter).to.be.null;
226286
expect(contracts.chainlinkRng).to.not.be.null;
227287
expect(contracts.randomizerRng).to.be.null;
228288

229289
// Verify all contract addresses
230290
await verifyAllContractAddresses(contracts);
231-
await verifyDeployedAddresses(contracts, NETWORKS.TESTNET, baseContractMapping);
291+
await verifyDeployedAddresses(contracts, NETWORKS.TESTNET, testnetContractMapping);
232292
});
233293

234294
it("should return correct contract instances for mainnetNeo", async () => {
@@ -242,6 +302,9 @@ describe("getContractsEthers", () => {
242302
expect(contracts.klerosCore).to.be.instanceOf(getConstructor(KlerosCoreNeo__factory, arbitrumProvider));
243303
expect(contracts.sortition).to.be.instanceOf(getConstructor(SortitionModuleNeo__factory, arbitrumProvider));
244304
verifyCommonContractInstances(contracts, arbitrumProvider);
305+
expect(contracts.disputeKitShutter).to.be.null;
306+
expect(contracts.disputeKitGated).to.be.null;
307+
expect(contracts.disputeKitGatedShutter).to.be.null;
245308
expect(contracts.chainlinkRng).to.not.be.null;
246309
expect(contracts.randomizerRng).to.not.be.null;
247310

contracts/test/integration/getContractsViem.test.ts

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,32 @@ type ContractMapping = {
2020
};
2121
};
2222

23-
const baseContractMapping: ContractMapping = {
23+
const devnetContractMapping: ContractMapping = {
2424
klerosCore: { name: "KlerosCore" },
2525
sortition: { name: "SortitionModule" },
2626
disputeKitClassic: { name: "DisputeKitClassic" },
27+
disputeKitShutter: { name: "DisputeKitShutter" },
28+
disputeKitGated: { name: "DisputeKitGated" },
29+
disputeKitGatedShutter: { name: "DisputeKitGatedShutter" },
30+
disputeResolver: { name: "DisputeResolver" },
31+
disputeTemplateRegistry: { name: "DisputeTemplateRegistry" },
32+
evidence: { name: "EvidenceModule" },
33+
policyRegistry: { name: "PolicyRegistry" },
34+
transactionBatcher: { name: "TransactionBatcher" },
35+
chainlinkRng: { name: "ChainlinkRNG", optional: true },
36+
randomizerRng: { name: "RandomizerRNG", optional: true },
37+
blockHashRng: { name: "BlockHashRNG" },
38+
pnk: { name: "PNK" },
39+
klerosCoreSnapshotProxy: { name: "KlerosCoreSnapshotProxy" },
40+
};
41+
42+
const testnetContractMapping: ContractMapping = {
43+
klerosCore: { name: "KlerosCore" },
44+
sortition: { name: "SortitionModule" },
45+
disputeKitClassic: { name: "DisputeKitClassic" },
46+
disputeKitShutter: { name: "DisputeKitShutter", optional: true },
47+
disputeKitGated: { name: "DisputeKitGated", optional: true },
48+
disputeKitGatedShutter: { name: "DisputeKitGatedShutter", optional: true },
2749
disputeResolver: { name: "DisputeResolver" },
2850
disputeTemplateRegistry: { name: "DisputeTemplateRegistry" },
2951
evidence: { name: "EvidenceModule" },
@@ -40,6 +62,9 @@ const universityContractMapping: ContractMapping = {
4062
klerosCore: { name: "KlerosCoreUniversity" },
4163
sortition: { name: "SortitionModuleUniversity" },
4264
disputeKitClassic: { name: "DisputeKitClassicUniversity" },
65+
disputeKitShutter: { name: "DisputeKitShutterUniversity", optional: true },
66+
disputeKitGated: { name: "DisputeKitGatedUniversity", optional: true },
67+
disputeKitGatedShutter: { name: "DisputeKitGatedShutterUniversity", optional: true },
4368
disputeResolver: { name: "DisputeResolverUniversity" },
4469
disputeTemplateRegistry: { name: "DisputeTemplateRegistry" },
4570
evidence: { name: "EvidenceModule" },
@@ -56,6 +81,9 @@ const neoContractMapping: ContractMapping = {
5681
klerosCore: { name: "KlerosCoreNeo" },
5782
sortition: { name: "SortitionModuleNeo" },
5883
disputeKitClassic: { name: "DisputeKitClassicNeo" },
84+
disputeKitShutter: { name: "DisputeKitShutterNeo", optional: true },
85+
disputeKitGated: { name: "DisputeKitGatedNeo", optional: true },
86+
disputeKitGatedShutter: { name: "DisputeKitGatedShutterNeo", optional: true },
5987
disputeResolver: { name: "DisputeResolverNeo" },
6088
disputeTemplateRegistry: { name: "DisputeTemplateRegistry" },
6189
evidence: { name: "EvidenceModule" },
@@ -93,6 +121,15 @@ describe("getContractsViem", () => {
93121
verifyContractInstance(contracts.klerosCore);
94122
verifyContractInstance(contracts.sortition);
95123
verifyContractInstance(contracts.disputeKitClassic);
124+
if (contracts.disputeKitShutter) {
125+
verifyContractInstance(contracts.disputeKitShutter);
126+
}
127+
if (contracts.disputeKitGated) {
128+
verifyContractInstance(contracts.disputeKitGated);
129+
}
130+
if (contracts.disputeKitGatedShutter) {
131+
verifyContractInstance(contracts.disputeKitGatedShutter);
132+
}
96133
verifyContractInstance(contracts.disputeResolver);
97134
verifyContractInstance(contracts.disputeTemplateRegistry);
98135
verifyContractInstance(contracts.evidence);
@@ -140,12 +177,17 @@ describe("getContractsViem", () => {
140177
// Verify all contract instances
141178
verifyAllContractInstances(contracts);
142179

180+
// Verify specific DisputeKit instances
181+
expect(contracts.disputeKitShutter).to.not.be.undefined;
182+
expect(contracts.disputeKitGated).to.not.be.undefined;
183+
expect(contracts.disputeKitGatedShutter).to.not.be.undefined;
184+
143185
// Verify specific RNG instances
144186
expect(contracts.chainlinkRng).to.not.be.undefined;
145187
expect(contracts.randomizerRng).to.be.undefined;
146188

147189
// Verify deployed addresses
148-
await verifyDeployedAddresses(contracts, NETWORKS.DEVNET, baseContractMapping);
190+
await verifyDeployedAddresses(contracts, NETWORKS.DEVNET, devnetContractMapping);
149191
});
150192

151193
it("should return correct contract instances for university", async () => {
@@ -160,6 +202,11 @@ describe("getContractsViem", () => {
160202
// Verify all contract instances
161203
verifyAllContractInstances(contracts);
162204

205+
// Verify specific DisputeKit instances
206+
expect(contracts.disputeKitShutter).to.be.undefined;
207+
expect(contracts.disputeKitGated).to.be.undefined;
208+
expect(contracts.disputeKitGatedShutter).to.be.undefined;
209+
163210
// Verify specific RNG instances
164211
expect(contracts.chainlinkRng).to.be.undefined;
165212
expect(contracts.randomizerRng).to.be.undefined;
@@ -180,12 +227,17 @@ describe("getContractsViem", () => {
180227
// Verify all contract instances
181228
verifyAllContractInstances(contracts);
182229

230+
// Verify specific DisputeKit instances
231+
expect(contracts.disputeKitShutter).to.be.undefined;
232+
expect(contracts.disputeKitGated).to.be.undefined;
233+
expect(contracts.disputeKitGatedShutter).to.be.undefined;
234+
183235
// Verify specific RNG instances
184236
expect(contracts.chainlinkRng).to.not.be.undefined;
185237
expect(contracts.randomizerRng).to.be.undefined;
186238

187239
// Verify deployed addresses
188-
await verifyDeployedAddresses(contracts, NETWORKS.TESTNET, baseContractMapping);
240+
await verifyDeployedAddresses(contracts, NETWORKS.TESTNET, testnetContractMapping);
189241
});
190242

191243
it("should return correct contract instances for mainnetNeo", async () => {
@@ -200,6 +252,11 @@ describe("getContractsViem", () => {
200252
// Verify all contract instances
201253
verifyAllContractInstances(contracts);
202254

255+
// Verify specific DisputeKit instances
256+
expect(contracts.disputeKitShutter).to.be.undefined;
257+
expect(contracts.disputeKitGated).to.be.undefined;
258+
expect(contracts.disputeKitGatedShutter).to.be.undefined;
259+
203260
// Verify specific RNG instances
204261
expect(contracts.chainlinkRng).to.not.be.undefined;
205262
expect(contracts.randomizerRng).to.not.be.undefined;

contracts/test/utils/getActualAddress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
export async function getActualAddress(network: string, contractName: string): Promise<string> {
99
try {
1010
const deployment = await import(`../../deployments/${network}/${contractName}.json`, {
11-
assert: { type: "json" },
11+
with: { type: "json" },
1212
});
1313
if (!deployment.default.address) {
1414
throw new Error(`No address found in deployment file for ${contractName} on ${network}`);

0 commit comments

Comments
 (0)