Skip to content

Commit 1992208

Browse files
update tests
1 parent a69b1d6 commit 1992208

24 files changed

+110
-279
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"url": "https://github.com/storyprotocol/sdk-e2e-tests.git"
1919
},
2020
"dependencies": {
21-
"@story-protocol/core-sdk": "1.0.0-rc.14",
21+
"@story-protocol/core-sdk": "1.0.0-rc.15",
2222
"viem": "^2.8.12"
2323
},
2424
"devDependencies": {

test/dispute/raiseDispute.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ describe("SDK Test", function () {
3434
let ipIdA: any;
3535
const response = await expect(
3636
raiseDispute("B", ipIdA, arbitrationPolicyAddress, "test", "PLAGIARISM", waitForTransaction)
37-
).to.be.rejectedWith("Failed to raise dispute: Address \"undefined\" is invalid.");
37+
).to.be.rejectedWith(`Failed to raise dispute: request.targetIpId address is invalid: undefined, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.`);
3838
});
3939

4040
it("Raise dispute fail as invalid ipId", async function () {
4141
const response = await expect(
4242
raiseDispute("B", "0x0000", arbitrationPolicyAddress, "test", "PLAGIARISM", waitForTransaction)
43-
).to.be.rejectedWith("Failed to raise dispute: Address \"0x0000\" is invalid.");
43+
).to.be.rejectedWith(`Failed to raise dispute: request.targetIpId address is invalid: 0x0000, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.`);
4444
});
4545

4646
it("Raise dispute fail as non-existent ipId", async function () {
4747
const response = await expect(
4848
raiseDispute("B", "0x8Dcd7f0be38Be6adbe2a7d8fb58032b1e20E3681", arbitrationPolicyAddress, "test", "PLAGIARISM", waitForTransaction)
49-
).to.be.rejectedWith("Failed to raise dispute: Address \"0x8Dcd7f0be38Be6adbe2a7d8fb58032b1e20E3681\" is invalid.");
49+
).to.be.rejectedWith(`Failed to raise dispute: The contract function "raiseDispute" reverted.`, `Error: DisputeModule__NotRegisteredIpId()`);
5050
});
5151

5252
it("Raise dispute fail as undefined linkToDisputeEvidence", async function () {

test/dispute/resolveDispute.test.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -51,41 +51,41 @@ describe("SDK Test", function () {
5151
let disputeId1: any;
5252
const response = await expect(
5353
resolveDispute("B", disputeId1, "0x", true)
54-
).to.be.rejectedWith("Failed to cancel dispute: Cannot convert undefined to a BigInt");
54+
).to.be.rejectedWith(`Failed to resolve dispute: Cannot convert undefined to a BigInt`);
5555
});
5656

5757
it("Resolve dispute fail as invalid disputeId", async function () {
5858
const response = await expect(
5959
resolveDispute("B", "test", "0x", true)
60-
).to.be.rejectedWith("Failed to cancel dispute: Cannot convert test to a BigInt");
60+
).to.be.rejectedWith(`Failed to resolve dispute: Cannot convert test to a BigInt`);
6161
});
6262

6363
it("Resolve dispute fail as non-existent disputeId", async function () {
6464
const response = await expect(
6565
resolveDispute("B", "999999", "0x", true)
66-
).to.be.rejectedWith("Failed to cancel dispute: The contract function \"resolveDispute\" reverted.",
67-
"Error: DisputeModule__NotDisputeInitiator()");
66+
).to.be.rejectedWith(`Failed to resolve dispute: The contract function "resolveDispute" reverted.`,
67+
`Error: DisputeModule__NotDisputeInitiator()`);
6868
});
6969

7070
it("Resolve dispute fail as undefined data", async function () {
7171
let data: any;
7272
const response = await expect(
7373
resolveDispute("B", disputeId1, data, true)
74-
).to.be.rejectedWith("Failed to cancel dispute: Cannot read properties of undefined (reading 'length')");
74+
).to.be.rejectedWith(`Failed to resolve dispute: Cannot read properties of undefined (reading 'length')`);
7575
});
7676

7777
it("Resolve dispute fail as not dispute initiator", async function () {
7878
const response = await expect(
7979
resolveDispute("A", disputeId1, "0x", true)
80-
).to.be.rejectedWith("Failed to cancel dispute: The contract function \"resolveDispute\" reverted.",
81-
"Error: DisputeModule__NotDisputeInitiator()");
80+
).to.be.rejectedWith(`Failed to resolve dispute: The contract function "resolveDispute" reverted.`,
81+
`Error: DisputeModule__NotDisputeInitiator()`);
8282
});
8383

8484
it("Resolve dispute fail as not set judgement", async function () {
8585
const response = await expect(
8686
resolveDispute("B", disputeId1, "0x0000", true)
87-
).to.be.rejectedWith("Failed to cancel dispute: The contract function \"resolveDispute\" reverted.",
88-
"Error: DisputeModule__NotAbleToResolve()");
87+
).to.be.rejectedWith(`Failed to resolve dispute: The contract function "resolveDispute" reverted.`,
88+
`Error: DisputeModule__NotAbleToResolve()`);
8989
});
9090

9191
it("Resolve dispute fail as judgement decision is false", async function () {
@@ -94,15 +94,15 @@ describe("SDK Test", function () {
9494

9595
const response = await expect(
9696
resolveDispute("B", disputeId1, "0x0000", true)
97-
).to.be.rejectedWith("Failed to cancel dispute: The contract function \"resolveDispute\" reverted.",
98-
"Error: DisputeModule__NotAbleToResolve()");
97+
).to.be.rejectedWith(`Failed to resolve dispute: The contract function "resolveDispute" reverted.`,
98+
`Error: DisputeModule__NotAbleToResolve()`);
9999
});
100100

101101
it("Resolve dispute faile as already resolved", async function () {
102102
const response = await expect(
103103
resolveDispute("B", disputeId1, "0x0000", false)
104-
).to.be.rejectedWith("Failed to cancel dispute: The contract function \"resolveDispute\" reverted.",
105-
"Error: DisputeModule__NotDisputeInitiator()");
104+
).to.be.rejectedWith(`Failed to resolve dispute: The contract function "resolveDispute" reverted.`,
105+
`Error: DisputeModule__NotAbleToResolve()`);
106106
});
107107

108108
it("Resolve dispute with waitForTransaction: false", async function () {

test/e2e/derivativeIP.comUsePIL.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { privateKeyA, privateKeyB, privateKeyC, accountA, accountB, accountC, nftContractAddress } from '../../config/config'
2-
import { mintNFTWithRetry } from '../../utils/utils'
3-
import { registerIpAsset, attachLicenseTerms, mintLicenseTokens, registerDerivative, registerDerivativeWithLicenseTokens } from '../../utils/sdkUtils'
4-
import { expect } from 'chai'
1+
import { privateKeyA, privateKeyB, privateKeyC, accountA, accountB, accountC, nftContractAddress } from '../../config/config';
2+
import { mintNFTWithRetry } from '../../utils/utils';
3+
import { registerIpAsset, attachLicenseTerms, mintLicenseTokens, registerDerivative, registerDerivativeWithLicenseTokens } from '../../utils/sdkUtils';
4+
import { expect } from 'chai';
55

66
import chai from 'chai';
77
import chaiAsPromised from 'chai-as-promised';

test/e2e/derivativeIP.nonComPIL.test.ts

+7-79
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { privateKeyA, privateKeyB, privateKeyC, accountA, accountB, accountC,nftContractAddress } from '../../config/config'
2-
import { mintNFTWithRetry } from '../../utils/utils'
3-
import { registerIpAsset, attachLicenseTerms, mintLicenseTokens, registerDerivative, registerDerivativeWithLicenseTokens } from '../../utils/sdkUtils'
4-
import { expect } from 'chai'
1+
import { privateKeyA, privateKeyB, privateKeyC, accountA, accountB, accountC,nftContractAddress } from '../../config/config';
2+
import { mintNFTWithRetry } from '../../utils/utils';
3+
import { registerIpAsset, attachLicenseTerms, mintLicenseTokens, registerDerivative, registerDerivativeWithLicenseTokens } from '../../utils/sdkUtils';
4+
import { expect } from 'chai';
55

66
import chai from 'chai';
77
import chaiAsPromised from 'chai-as-promised';
@@ -42,14 +42,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
4242
ipIdA = response.ipId;
4343
});
4444

45-
step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
46-
const response = await expect(
47-
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
48-
).to.not.be.rejected;
49-
50-
expect(response.txHash).to.be.a("string").and.not.empty;
51-
});
52-
5345
step("Wallet A mint a license token with the receiverAddress set as Wallet B, get a licenseTokenId (licenseTokenIdA)", async function () {
5446
const response = await expect(
5547
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 2, accountB.address, waitForTransaction)
@@ -143,14 +135,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
143135
ipIdA = response.ipId;
144136
});
145137

146-
step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
147-
const response = await expect(
148-
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
149-
).to.not.be.rejected;
150-
151-
expect(response.txHash).to.be.a("string").and.not.empty;
152-
});
153-
154138
step("Mint a NFT to WalletB, get a tokenId (tokenidB)", async function () {
155139
tokenIdB = await mintNFTWithRetry(privateKeyB);
156140
if (tokenIdB === '') {
@@ -170,14 +154,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
170154
ipIdB = response.ipId;
171155
});
172156

173-
step("Wallet B attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
174-
const response = await expect(
175-
attachLicenseTerms("B", ipIdB, nonComLicenseTermsId, waitForTransaction)
176-
).to.not.be.rejected;
177-
178-
expect(response.txHash).to.be.a("string").and.not.empty;
179-
});
180-
181157
step("Mint a NFT to WalletC, get a tokenId (tokenidC)", async function () {
182158
tokenIdC = await mintNFTWithRetry(privateKeyC);
183159
if (tokenIdC === '') {
@@ -226,14 +202,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
226202
ipIdA = response.ipId;
227203
});
228204

229-
step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
230-
const response = await expect(
231-
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
232-
).to.not.be.rejected;
233-
234-
expect(response.txHash).to.be.a("string").and.not.empty;
235-
});
236-
237205
step("Wallet A mint a license token with the receiverAddress set as Wallet B, get a licenseId (licenseTokenIdA)", async function () {
238206
const response = await expect(
239207
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 2, accountC.address, waitForTransaction)
@@ -264,14 +232,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
264232
ipIdB = response.ipId;
265233
});
266234

267-
step("Wallet B attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdB", async function () {
268-
const response = await expect(
269-
attachLicenseTerms("B", ipIdB, nonComLicenseTermsId, waitForTransaction)
270-
).to.not.be.rejected;
271-
272-
expect(response.txHash).to.be.a("string").and.not.empty;
273-
});
274-
275235
step("Wallet B mint a license token with the receiverAddress set as Wallet C, get a licenseTokenId (licenseTokenIdB)", async function () {
276236
const response = await expect(
277237
mintLicenseTokens("B", ipIdB, nonComLicenseTermsId, 2, accountC.address, waitForTransaction)
@@ -331,14 +291,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
331291
ipIdA = response.ipId;
332292
});
333293

334-
step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
335-
const response = await expect(
336-
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
337-
).to.not.be.rejected;
338-
339-
expect(response.txHash).to.be.a("string").and.not.empty;
340-
});
341-
342294
step("Wallet A mint a license token with the receiverAddress set as Wallet B, get a licenseId (licenseTokenIdA)", async function () {
343295
const response = await expect(
344296
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 2, accountB.address, waitForTransaction)
@@ -369,14 +321,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
369321
ipIdB = response.ipId;
370322
});
371323

372-
step("Wallet B attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdB", async function () {
373-
const response = await expect(
374-
attachLicenseTerms("B", ipIdB, nonComLicenseTermsId, waitForTransaction)
375-
).to.not.be.rejected;
376-
377-
expect(response.txHash).to.be.a("string").and.not.empty;
378-
});
379-
380324
step("Wallet B mint a license token with the receiverAddress set as Wallet C, get a licenseTokenId (licenseTokenIdB)", async function () {
381325
const response = await expect(
382326
mintLicenseTokens("B", ipIdB, nonComLicenseTermsId, 2, accountC.address, waitForTransaction)
@@ -435,14 +379,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
435379
ipIdA = response.ipId;
436380
});
437381

438-
step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
439-
const response = await expect(
440-
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
441-
).to.not.be.rejected;
442-
443-
expect(response.txHash).to.be.a("string").and.not.empty;
444-
});
445-
446382
step("Wallet A mint a license token with ipIdA and get a licenseTokenId (licenseTokenIdA)", async function () {
447383
const response = await expect(
448384
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 1, accountB.address, waitForTransaction)
@@ -527,14 +463,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
527463
ipIdA = response.ipId;
528464
});
529465

530-
step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
531-
const response = await expect(
532-
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
533-
).to.not.be.rejected;
534-
535-
expect(response.txHash).to.be.a("string").and.not.empty;
536-
});
537-
538466
step("Wallet A mint a license token with ipIdA and get a licenseTokenId (licenseTokenIdA)", async function () {
539467
const response = await expect(
540468
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 1, accountB.address, waitForTransaction)
@@ -565,17 +493,17 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
565493
ipIdB = response.ipId;
566494
});
567495

568-
step("Wallet B attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
496+
step("Wallet B attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdB", async function () {
569497
const response = await expect(
570-
attachLicenseTerms("B", ipIdB, nonComLicenseTermsId, waitForTransaction)
498+
attachLicenseTerms("B", ipIdB, 0n, waitForTransaction)
571499
).to.not.be.rejected;
572500

573501
expect(response.txHash).to.be.a("string").and.not.empty;
574502
});
575503

576504
step("Wallet B mint a license token with ipIdB and get a licenseTokenId (licenseTokenIdB)", async function () {
577505
const response = await expect(
578-
mintLicenseTokens("B", ipIdB, nonComLicenseTermsId, 1, accountA.address, waitForTransaction)
506+
mintLicenseTokens("B", ipIdB, 0n, 1, accountA.address, waitForTransaction)
579507
).to.not.be.rejected;
580508

581509
expect(response.txHash).to.be.a("string").and.not.empty;

test/e2e/dispute.test.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe("SDK E2E Test - Dispute Module", function () {
5959
describe("Attach License Terms to IN_DISPUTE IP Asset", async function () {
6060
it("Attach non-commerical social remixing PIL to IN_DISPUTE IP asset", async function () {
6161
const response = await expect(
62-
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
62+
attachLicenseTerms("A", ipIdA, 0n, waitForTransaction)
6363
).to.not.be.rejected;
6464

6565
expect(response.txHash).to.be.a("string").and.not.empty;
@@ -287,7 +287,7 @@ describe("SDK E2E Test - Dispute Module", function () {
287287
describe("Attach License Terms to DISPUTED IP Asset", async function () {
288288
it("Attach non-commerical social remixing PIL to a DISPUTED IP asset", async function () {
289289
const response = await expect(
290-
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
290+
attachLicenseTerms("A", ipIdA, 0n, waitForTransaction)
291291
).to.be.rejectedWith("Failed to attach license terms: The contract function \"attachLicenseTerms\" reverted.",
292292
"Error: LicensingModule__DisputedIpId()");
293293
});
@@ -309,23 +309,17 @@ describe("SDK E2E Test - Dispute Module", function () {
309309

310310
describe("Mint License Tokens for DISPUTED IP asset", async function () {
311311
before("Attach license terms, raise dispute and set judgement", async function () {
312-
const response1 = await expect(
313-
attachLicenseTerms("B", ipIdB, nonComLicenseTermsId, waitForTransaction)
314-
).to.not.be.rejected;
315-
316-
expect(response1.txHash).to.be.a("string").and.not.empty;
317-
318-
const response2 = await expect(
312+
const responseComUsePIL = await expect(
319313
attachLicenseTerms("B", ipIdB, comUseLicenseTermsId1, waitForTransaction)
320314
).to.not.be.rejected;
321315

322-
expect(response2.txHash).to.be.a("string").and.not.empty;
316+
expect(responseComUsePIL.txHash).to.be.a("string").and.not.empty;
323317

324-
const response3 = await expect(
318+
const responsecomRemixPIL = await expect(
325319
attachLicenseTerms("B", ipIdB, comRemixLicenseTermsId2, waitForTransaction)
326320
).to.not.be.rejected;
327321

328-
expect(response3.txHash).to.be.a("string").and.not.empty;
322+
expect(responsecomRemixPIL.txHash).to.be.a("string").and.not.empty;
329323

330324
const responseRaiseDispute = await expect(
331325
raiseDispute("A", ipIdB, arbitrationPolicyAddress, "test", "PLAGIARISM", waitForTransaction)
@@ -386,7 +380,7 @@ describe("SDK E2E Test - Dispute Module", function () {
386380

387381
step("Register derivative with non-commercial social remixing PIL, derivative IP is a DISPUTED IP asset", async function () {
388382
const responseAttachLicenseTerms = await expect(
389-
attachLicenseTerms("A", ipIdC, nonComLicenseTermsId, waitForTransaction)
383+
attachLicenseTerms("A", ipIdC, 0n, waitForTransaction)
390384
).to.not.be.rejected;
391385

392386
expect(responseAttachLicenseTerms.txHash).to.be.a("string").and.not.empty;

0 commit comments

Comments
 (0)