Skip to content

Commit 467520f

Browse files
authored
test: remove redundant error case in integration tests (#679)
Refactor: Remove fake data test cases from integration tests in core-sdk package
1 parent 6a4b4c2 commit 467520f

File tree

7 files changed

+61
-565
lines changed

7 files changed

+61
-565
lines changed

packages/core-sdk/test/integration/dispute.test.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,6 @@ describe("Dispute Functions", () => {
8787
disputeId = response.disputeId!;
8888
});
8989

90-
it("should validate all enum values defined in DisputeTargetTag", async () => {
91-
const allTags = Object.values(DisputeTargetTag);
92-
93-
for (const tag of allTags) {
94-
const tagHex: Hex = toHex(tag, { size: 32 });
95-
const { allowed } = await clientA.dispute.disputeModuleClient.isWhitelistedDisputeTag({
96-
tag: tagHex,
97-
});
98-
if (tag === DisputeTargetTag.IN_DISPUTE) {
99-
expect(allowed).equal(false);
100-
} else {
101-
expect(allowed).equal(true);
102-
}
103-
}
104-
});
105-
10690
it("should raise disputes with different DisputeTargetTag enum values", async () => {
10791
const allTags = Object.values(DisputeTargetTag);
10892

@@ -127,18 +111,6 @@ describe("Dispute Functions", () => {
127111
}
128112
});
129113

130-
it("should reject a dispute with an invalid tag not defined in the enum", async () => {
131-
await expect(
132-
clientA.dispute.raiseDispute({
133-
targetIpId: ipIdB,
134-
cid: await generateCID(),
135-
targetTag: "INVALID_TAG" as DisputeTargetTag,
136-
liveness: 2592000,
137-
bond: minimumBond,
138-
}),
139-
).to.be.rejectedWith("The target tag INVALID_TAG is not whitelisted");
140-
});
141-
142114
it("should be able to counter existing dispute once", async () => {
143115
const assertionId = await clientB.dispute.disputeIdToAssertionId(disputeId!);
144116
const counterEvidenceCID = await generateCID();
@@ -473,19 +445,6 @@ describe("Dispute Functions", () => {
473445
expect(responses[1].txHash).to.be.a("string");
474446
});
475447

476-
it("should fail when trying to tag with invalid dispute ID", async () => {
477-
await expect(
478-
clientA.dispute.tagIfRelatedIpInfringed({
479-
infringementTags: [
480-
{
481-
ipId: childIpId,
482-
disputeId: 999999n,
483-
},
484-
],
485-
}),
486-
).to.be.rejected;
487-
});
488-
489448
it("should resolve a dispute successfully when initiated by dispute initiator", async () => {
490449
await settleAssertion(TEST_PRIVATE_KEY, disputeId);
491450

packages/core-sdk/test/integration/group.test.ts

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -217,28 +217,6 @@ describe("Group Functions", () => {
217217
expect(result.groupId).to.be.a("string");
218218
});
219219

220-
it("should fail when trying to add unregistered IP to group", async () => {
221-
await expect(
222-
client.groupClient.registerGroupAndAttachLicenseAndAddIps({
223-
groupPool: groupPoolAddress,
224-
maxAllowedRewardShare: 5,
225-
ipIds: [zeroAddress], // Invalid IP address
226-
licenseData: {
227-
licenseTermsId,
228-
licensingConfig: {
229-
isSet: true,
230-
mintingFee: 0n,
231-
licensingHook: zeroAddress,
232-
hookData: zeroAddress,
233-
commercialRevShare: 0,
234-
disabled: false,
235-
expectMinimumGroupRewardShare: 0,
236-
expectGroupRewardPool: zeroAddress,
237-
},
238-
},
239-
}),
240-
).to.be.rejectedWith("Failed to register group and attach license and add ips");
241-
});
242220
describe("Add IPs to Group and Remove IPs from Group", () => {
243221
let ipIds: Address[];
244222
it("should successfully add multiple IPs to group", async () => {
@@ -275,39 +253,6 @@ describe("Group Functions", () => {
275253
});
276254
expect(result.txHash).to.be.a("string");
277255
});
278-
279-
it("should fail when trying to remove IPs from a non-existent group", async () => {
280-
const registerResult = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
281-
spgNftContract,
282-
licenseTermsData,
283-
});
284-
const testIpId = registerResult.ipId!;
285-
286-
const nonExistentGroupId = zeroAddress;
287-
288-
await expect(
289-
client.groupClient.removeIpsFromGroup({
290-
groupIpId: nonExistentGroupId,
291-
ipIds: [testIpId],
292-
}),
293-
).to.be.rejectedWith("Failed to remove IPs from group");
294-
});
295-
296-
it("should fail when trying to remove non-existent IPs from a group", async () => {
297-
const groupResult = await client.groupClient.registerGroup({
298-
groupPool: groupPoolAddress,
299-
});
300-
const testGroupId = groupResult.groupId!;
301-
302-
const nonExistentIpId = zeroAddress;
303-
304-
await expect(
305-
client.groupClient.removeIpsFromGroup({
306-
groupIpId: testGroupId,
307-
ipIds: [nonExistentIpId],
308-
}),
309-
).to.be.rejectedWith("Failed to remove IPs from group");
310-
});
311256
});
312257
});
313258

@@ -488,28 +433,6 @@ describe("Group Functions", () => {
488433
expect(result.claimedReward?.[0].amount[0]).to.equal(10n);
489434
});
490435

491-
it("should fail when trying to claim reward for a non-existent group", async () => {
492-
const nonExistentGroupId = zeroAddress;
493-
await expect(
494-
client.groupClient.claimReward({
495-
groupIpId: nonExistentGroupId,
496-
currencyToken: WIP_TOKEN_ADDRESS,
497-
memberIpIds: [ipId],
498-
}),
499-
).to.be.rejectedWith("Failed to claim reward");
500-
});
501-
502-
it("should fail when trying to claim reward with invalid token address", async () => {
503-
const invalidTokenAddress = zeroAddress;
504-
await expect(
505-
client.groupClient.claimReward({
506-
groupIpId: groupIpId,
507-
currencyToken: invalidTokenAddress,
508-
memberIpIds: [ipId],
509-
}),
510-
).to.be.rejectedWith("Failed to claim reward");
511-
});
512-
513436
it("should successfully collect royalties and claim reward in one transaction", async () => {
514437
const ipIds: Address[] = [];
515438

packages/core-sdk/test/integration/ipAccount.test.ts

Lines changed: 9 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,6 @@ describe("IPAccount Functions", () => {
6868
});
6969
expect(response.txHash).to.be.a("string");
7070
});
71-
72-
it("should fail with invalid ipId", async () => {
73-
await expect(
74-
client.ipAccount.execute({
75-
to: permissionAddress,
76-
value: 0,
77-
data: data,
78-
ipId: "0x0000000000000000000000000000000000000000",
79-
}),
80-
).to.be.rejected;
81-
});
8271
});
8372

8473
describe("executeWithSig", () => {
@@ -127,19 +116,6 @@ describe("IPAccount Functions", () => {
127116
).to.be.rejectedWith("IPAccount__ExpiredSignature");
128117
});
129118

130-
it("should fail with invalid signature format", async () => {
131-
await expect(
132-
client.ipAccount.executeWithSig({
133-
to: permissionAddress,
134-
data: data,
135-
ipId: ipId,
136-
signer: TEST_WALLET_ADDRESS,
137-
deadline: VALID_DEADLINE,
138-
signature: "0x1234567890abcdef" as Hex, // Invalid signature format
139-
}),
140-
).to.be.rejectedWith("IPAccount__InvalidSignature");
141-
});
142-
143119
it("should fail with signature from wrong signer", async () => {
144120
// Generate signature with wrong signer
145121
const wrongSigner = "0x1234567890123456789012345678901234567890" as Address;
@@ -167,158 +143,6 @@ describe("IPAccount Functions", () => {
167143
).to.be.rejectedWith("IPAccount__InvalidSignature");
168144
});
169145

170-
it("should fail with invalid ipId format", async () => {
171-
const nonceResult = await client.ipAccount.getIpAccountNonce(ipId);
172-
173-
const { signature } = await getSignature({
174-
state: nonceResult,
175-
to: permissionAddress,
176-
encodeData: data,
177-
wallet: walletClient,
178-
verifyingContract: ipId,
179-
deadline: VALID_DEADLINE,
180-
chainId: aeneid,
181-
});
182-
183-
await expect(
184-
client.ipAccount.executeWithSig({
185-
to: permissionAddress,
186-
data: data,
187-
ipId: "0x123" as Address, // Invalid address format
188-
signer: TEST_WALLET_ADDRESS,
189-
deadline: VALID_DEADLINE,
190-
signature: signature,
191-
}),
192-
).to.be.rejectedWith("Invalid address: 0x123.");
193-
});
194-
195-
it("should fail when IP account does not exist", async () => {
196-
// Create a real non-existent IP address (but with correct format)
197-
const nonExistentIpId = "0x1111111111111111111111111111111111111111" as Address;
198-
199-
// Generate signature for this non-existent IP
200-
// Note: We need to try to get nonce first, if IP doesn't exist, this step should fail
201-
try {
202-
const nonceResult = await client.ipAccount.getIpAccountNonce(nonExistentIpId);
203-
204-
const { signature } = await getSignature({
205-
state: nonceResult,
206-
to: permissionAddress,
207-
encodeData: data,
208-
wallet: walletClient,
209-
verifyingContract: nonExistentIpId, // Use non-existent IP as verifying contract
210-
deadline: VALID_DEADLINE,
211-
chainId: aeneid,
212-
});
213-
214-
await expect(
215-
client.ipAccount.executeWithSig({
216-
to: permissionAddress,
217-
data: data,
218-
ipId: nonExistentIpId,
219-
signer: TEST_WALLET_ADDRESS,
220-
deadline: VALID_DEADLINE,
221-
signature: signature,
222-
}),
223-
).to.be.rejectedWith("IPAccount__InvalidSignature"); // Should fail because IP doesn't exist
224-
} catch (error) {
225-
// If getting nonce fails, it means IP indeed doesn't exist, which is also our expected result
226-
expect((error as Error).message).to.include("Failed to get the IP Account nonce");
227-
}
228-
});
229-
230-
it("should fail with unauthorized signer", async () => {
231-
// Test various unauthorized signer scenarios
232-
const unauthorizedSigner = "0x2222222222222222222222222222222222222222" as Address;
233-
234-
const nonceResult = await client.ipAccount.getIpAccountNonce(ipId);
235-
const { signature } = await getSignature({
236-
state: nonceResult,
237-
to: permissionAddress,
238-
encodeData: data,
239-
wallet: walletClient,
240-
verifyingContract: ipId,
241-
deadline: VALID_DEADLINE,
242-
chainId: aeneid,
243-
});
244-
245-
await expect(
246-
client.ipAccount.executeWithSig({
247-
to: permissionAddress,
248-
data: data,
249-
ipId: ipId,
250-
signer: unauthorizedSigner, // Unauthorized signer
251-
deadline: VALID_DEADLINE,
252-
signature: signature,
253-
}),
254-
).to.be.rejectedWith("IPAccount__InvalidSignature"); // Contract returns InvalidSignature for permission issues
255-
});
256-
257-
it("should fail with signature for wrong data", async () => {
258-
// Generate signature for different data than what we execute
259-
const wrongData = encodeFunctionData({
260-
abi: accessControllerAbi,
261-
functionName: "setTransientPermission",
262-
args: [
263-
getAddress("0x1234567890123456789012345678901234567890"),
264-
getAddress(TEST_WALLET_ADDRESS),
265-
getAddress(coreMetadataModule),
266-
toFunctionSelector("function setAll(address,string,bytes32,bytes32)"),
267-
AccessPermission.DENY,
268-
],
269-
});
270-
271-
const nonceResult = await client.ipAccount.getIpAccountNonce(ipId);
272-
273-
const { signature } = await getSignature({
274-
state: nonceResult,
275-
to: permissionAddress,
276-
encodeData: wrongData, // Sign wrong data
277-
wallet: walletClient,
278-
verifyingContract: ipId,
279-
deadline: VALID_DEADLINE,
280-
chainId: aeneid,
281-
});
282-
283-
await expect(
284-
client.ipAccount.executeWithSig({
285-
to: permissionAddress,
286-
data: data, // Execute with original data, not the signed data
287-
ipId: ipId,
288-
signer: TEST_WALLET_ADDRESS,
289-
deadline: VALID_DEADLINE,
290-
signature: signature,
291-
}),
292-
).to.be.rejectedWith("IPAccount__InvalidSignature"); // Should fail because data doesn't match signature
293-
});
294-
295-
it("should fail with signature for wrong target address", async () => {
296-
// Generate signature for different target address than what we execute
297-
const wrongTarget = "0x1234567890123456789012345678901234567890" as Address;
298-
const nonceResult = await client.ipAccount.getIpAccountNonce(ipId);
299-
300-
const { signature } = await getSignature({
301-
state: nonceResult,
302-
to: wrongTarget, // Sign for wrong target
303-
encodeData: data,
304-
wallet: walletClient,
305-
verifyingContract: ipId,
306-
deadline: VALID_DEADLINE,
307-
chainId: aeneid,
308-
});
309-
310-
await expect(
311-
client.ipAccount.executeWithSig({
312-
to: permissionAddress, // Execute with original target, not the signed target
313-
data: data,
314-
ipId: ipId,
315-
signer: TEST_WALLET_ADDRESS,
316-
deadline: VALID_DEADLINE,
317-
signature: signature,
318-
}),
319-
).to.be.rejectedWith("IPAccount__InvalidSignature"); // Should fail because target doesn't match signature
320-
});
321-
322146
it("should execute with zero value transaction", async () => {
323147
// Test successful execution with zero value
324148
const nonceResult = await client.ipAccount.getIpAccountNonce(ipId);
@@ -347,32 +171,18 @@ describe("IPAccount Functions", () => {
347171
});
348172
});
349173

350-
describe("getIpAccountNonce", () => {
351-
it("should successfully return account nonce", async () => {
352-
const response = await client.ipAccount.getIpAccountNonce(ipId);
353-
expect(response).to.be.a("string");
354-
});
355-
356-
it("should fail with invalid ipId", async () => {
357-
await expect(client.ipAccount.getIpAccountNonce("0x0000000000000000000000000000000000000000"))
358-
.to.be.rejected;
359-
});
174+
it("should successfully return account nonce", async () => {
175+
const response = await client.ipAccount.getIpAccountNonce(ipId);
176+
expect(response).to.be.a("string");
360177
});
361178

362-
describe("getToken", () => {
363-
it("should successfully return token information", async () => {
364-
const response = await client.ipAccount.getToken(ipId);
179+
it("should successfully return token information", async () => {
180+
const response = await client.ipAccount.getToken(ipId);
365181

366-
expect(response.chainId).to.be.a("bigint");
367-
expect(response.tokenContract).to.be.a("string");
368-
expect(response.tokenId).to.be.a("bigint");
369-
expect(response.tokenContract).to.equal(mockERC721);
370-
});
371-
372-
it("should fail with invalid ipId", async () => {
373-
await expect(client.ipAccount.getToken("0x0000000000000000000000000000000000000000")).to.be
374-
.rejected;
375-
});
182+
expect(response.chainId).to.be.a("bigint");
183+
expect(response.tokenContract).to.be.a("string");
184+
expect(response.tokenId).to.be.a("bigint");
185+
expect(response.tokenContract).to.equal(mockERC721);
376186
});
377187

378188
it("should successfully set ip metadata", async () => {

0 commit comments

Comments
 (0)