Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"url": "https://github.com/storyprotocol/sdk-e2e-tests.git"
},
"dependencies": {
"@story-protocol/core-sdk": "1.0.0-rc.14",
"@story-protocol/core-sdk": "1.0.0-rc.15",
"viem": "^2.8.12"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions test/dispute/raiseDispute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ describe("SDK Test", function () {
let ipIdA: any;
const response = await expect(
raiseDispute("B", ipIdA, arbitrationPolicyAddress, "test", "PLAGIARISM", waitForTransaction)
).to.be.rejectedWith("Failed to raise dispute: Address \"undefined\" is invalid.");
).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.`);
});

it("Raise dispute fail as invalid ipId", async function () {
const response = await expect(
raiseDispute("B", "0x0000", arbitrationPolicyAddress, "test", "PLAGIARISM", waitForTransaction)
).to.be.rejectedWith("Failed to raise dispute: Address \"0x0000\" is invalid.");
).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.`);
});

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

it("Raise dispute fail as undefined linkToDisputeEvidence", async function () {
Expand Down
26 changes: 13 additions & 13 deletions test/dispute/resolveDispute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,41 @@ describe("SDK Test", function () {
let disputeId1: any;
const response = await expect(
resolveDispute("B", disputeId1, "0x", true)
).to.be.rejectedWith("Failed to cancel dispute: Cannot convert undefined to a BigInt");
).to.be.rejectedWith(`Failed to resolve dispute: Cannot convert undefined to a BigInt`);
});

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

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

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

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

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

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

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

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

it("Resolve dispute with waitForTransaction: false", async function () {
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/derivativeIP.comUsePIL.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { privateKeyA, privateKeyB, privateKeyC, accountA, accountB, accountC, nftContractAddress } from '../../config/config'
import { mintNFTWithRetry } from '../../utils/utils'
import { registerIpAsset, attachLicenseTerms, mintLicenseTokens, registerDerivative, registerDerivativeWithLicenseTokens } from '../../utils/sdkUtils'
import { expect } from 'chai'
import { privateKeyA, privateKeyB, privateKeyC, accountA, accountB, accountC, nftContractAddress } from '../../config/config';
import { mintNFTWithRetry } from '../../utils/utils';
import { registerIpAsset, attachLicenseTerms, mintLicenseTokens, registerDerivative, registerDerivativeWithLicenseTokens } from '../../utils/sdkUtils';
import { expect } from 'chai';

import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
Expand Down
86 changes: 7 additions & 79 deletions test/e2e/derivativeIP.nonComPIL.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { privateKeyA, privateKeyB, privateKeyC, accountA, accountB, accountC,nftContractAddress } from '../../config/config'
import { mintNFTWithRetry } from '../../utils/utils'
import { registerIpAsset, attachLicenseTerms, mintLicenseTokens, registerDerivative, registerDerivativeWithLicenseTokens } from '../../utils/sdkUtils'
import { expect } from 'chai'
import { privateKeyA, privateKeyB, privateKeyC, accountA, accountB, accountC,nftContractAddress } from '../../config/config';
import { mintNFTWithRetry } from '../../utils/utils';
import { registerIpAsset, attachLicenseTerms, mintLicenseTokens, registerDerivative, registerDerivativeWithLicenseTokens } from '../../utils/sdkUtils';
import { expect } from 'chai';

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

step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
const response = await expect(
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

step("Wallet A mint a license token with the receiverAddress set as Wallet B, get a licenseTokenId (licenseTokenIdA)", async function () {
const response = await expect(
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 2, accountB.address, waitForTransaction)
Expand Down Expand Up @@ -143,14 +135,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
ipIdA = response.ipId;
});

step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
const response = await expect(
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

step("Mint a NFT to WalletB, get a tokenId (tokenidB)", async function () {
tokenIdB = await mintNFTWithRetry(privateKeyB);
if (tokenIdB === '') {
Expand All @@ -170,14 +154,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
ipIdB = response.ipId;
});

step("Wallet B attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
const response = await expect(
attachLicenseTerms("B", ipIdB, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

step("Mint a NFT to WalletC, get a tokenId (tokenidC)", async function () {
tokenIdC = await mintNFTWithRetry(privateKeyC);
if (tokenIdC === '') {
Expand Down Expand Up @@ -226,14 +202,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
ipIdA = response.ipId;
});

step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
const response = await expect(
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

step("Wallet A mint a license token with the receiverAddress set as Wallet B, get a licenseId (licenseTokenIdA)", async function () {
const response = await expect(
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 2, accountC.address, waitForTransaction)
Expand Down Expand Up @@ -264,14 +232,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
ipIdB = response.ipId;
});

step("Wallet B attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdB", async function () {
const response = await expect(
attachLicenseTerms("B", ipIdB, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

step("Wallet B mint a license token with the receiverAddress set as Wallet C, get a licenseTokenId (licenseTokenIdB)", async function () {
const response = await expect(
mintLicenseTokens("B", ipIdB, nonComLicenseTermsId, 2, accountC.address, waitForTransaction)
Expand Down Expand Up @@ -331,14 +291,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
ipIdA = response.ipId;
});

step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
const response = await expect(
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

step("Wallet A mint a license token with the receiverAddress set as Wallet B, get a licenseId (licenseTokenIdA)", async function () {
const response = await expect(
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 2, accountB.address, waitForTransaction)
Expand Down Expand Up @@ -369,14 +321,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
ipIdB = response.ipId;
});

step("Wallet B attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdB", async function () {
const response = await expect(
attachLicenseTerms("B", ipIdB, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

step("Wallet B mint a license token with the receiverAddress set as Wallet C, get a licenseTokenId (licenseTokenIdB)", async function () {
const response = await expect(
mintLicenseTokens("B", ipIdB, nonComLicenseTermsId, 2, accountC.address, waitForTransaction)
Expand Down Expand Up @@ -435,14 +379,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
ipIdA = response.ipId;
});

step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
const response = await expect(
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

step("Wallet A mint a license token with ipIdA and get a licenseTokenId (licenseTokenIdA)", async function () {
const response = await expect(
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 1, accountB.address, waitForTransaction)
Expand Down Expand Up @@ -527,14 +463,6 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
ipIdA = response.ipId;
});

step("Wallet A attach nonComLicenseTermsId(non-commercial social remixing PIL) to ipIdA", async function () {
const response = await expect(
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

step("Wallet A mint a license token with ipIdA and get a licenseTokenId (licenseTokenIdA)", async function () {
const response = await expect(
mintLicenseTokens("A", ipIdA, nonComLicenseTermsId, 1, accountB.address, waitForTransaction)
Expand Down Expand Up @@ -565,17 +493,17 @@ describe("SDK E2E Test - Register Derivative IP Asset with Non-Commercial Social
ipIdB = response.ipId;
});

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

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

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

expect(response.txHash).to.be.a("string").and.not.empty;
Expand Down
20 changes: 7 additions & 13 deletions test/e2e/dispute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("SDK E2E Test - Dispute Module", function () {
describe("Attach License Terms to IN_DISPUTE IP Asset", async function () {
it("Attach non-commerical social remixing PIL to IN_DISPUTE IP asset", async function () {
const response = await expect(
attachLicenseTerms("A", ipIdA, nonComLicenseTermsId, waitForTransaction)
attachLicenseTerms("A", ipIdA, 0n, waitForTransaction)
).to.not.be.rejected;

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

describe("Mint License Tokens for DISPUTED IP asset", async function () {
before("Attach license terms, raise dispute and set judgement", async function () {
const response1 = await expect(
attachLicenseTerms("B", ipIdB, nonComLicenseTermsId, waitForTransaction)
).to.not.be.rejected;

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

const response2 = await expect(
const responseComUsePIL = await expect(
attachLicenseTerms("B", ipIdB, comUseLicenseTermsId1, waitForTransaction)
).to.not.be.rejected;

expect(response2.txHash).to.be.a("string").and.not.empty;
expect(responseComUsePIL.txHash).to.be.a("string").and.not.empty;

const response3 = await expect(
const responsecomRemixPIL = await expect(
attachLicenseTerms("B", ipIdB, comRemixLicenseTermsId2, waitForTransaction)
).to.not.be.rejected;

expect(response3.txHash).to.be.a("string").and.not.empty;
expect(responsecomRemixPIL.txHash).to.be.a("string").and.not.empty;

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

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

expect(responseAttachLicenseTerms.txHash).to.be.a("string").and.not.empty;
Expand Down
Loading