Skip to content

Commit

Permalink
add arweave link parameter to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcabot committed Sep 28, 2022
1 parent 94d6e45 commit d26d8c9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 29 deletions.
25 changes: 13 additions & 12 deletions test/SoulName.test.ts
Expand Up @@ -18,6 +18,7 @@ const SOUL_NAME1 = "soulNameTest1";
const SOUL_NAME2 = "soulNameTest2";
const YEAR = 1; // 1 year
const YEAR_PERIOD = 31536000; // 60 seconds * 60 minutes * 24 hours * 365 days
const ARWEAVE_LINK = "ar://jK9sR4OrYvODj7PD3czIAyNJalub0-vdV_JAg1NqQ-o";

// contract instances
let soulboundIdentity: SoulboundIdentity;
Expand Down Expand Up @@ -129,7 +130,7 @@ describe("Soul Name", () => {
it("should mint from admin", async () => {
const mintTx = await soulName
.connect(admin)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR);
.mint(address1.address, SOUL_NAME1, identityId1, YEAR, ARWEAVE_LINK);
const mintReceipt = await mintTx.wait();

const nameId = mintReceipt.events![0].args![2].toNumber();
Expand All @@ -141,30 +142,30 @@ describe("Soul Name", () => {
it("should success to mint a name twice to the same idenity", async () => {
await soulName
.connect(admin)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR);
.mint(address1.address, SOUL_NAME1, identityId1, YEAR, ARWEAVE_LINK);

await soulName
.connect(admin)
.mint(address1.address, SOUL_NAME2, identityId1, YEAR);
.mint(address1.address, SOUL_NAME2, identityId1, YEAR, ARWEAVE_LINK);
});

it("should fail to mint duplicated name", async () => {
await soulName
.connect(admin)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR);
.mint(address1.address, SOUL_NAME1, identityId1, YEAR, ARWEAVE_LINK);

await expect(
soulName
.connect(admin)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR, ARWEAVE_LINK)
).to.be.rejected;
});

it("should fail to mint from non-admin address", async () => {
await expect(
soulName
.connect(address1)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR, ARWEAVE_LINK)
).to.be.rejected;
});
});
Expand All @@ -175,7 +176,7 @@ describe("Soul Name", () => {
beforeEach(async () => {
const mintTx = await soulName
.connect(admin)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR);
.mint(address1.address, SOUL_NAME1, identityId1, YEAR, ARWEAVE_LINK);
const mintReceipt = await mintTx.wait();

nameId = mintReceipt.events![0].args![2].toNumber();
Expand Down Expand Up @@ -258,7 +259,7 @@ describe("Soul Name", () => {
beforeEach(async () => {
const mintTx = await soulName
.connect(admin)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR);
.mint(address1.address, SOUL_NAME1, identityId1, YEAR, ARWEAVE_LINK);
const mintReceipt = await mintTx.wait();

nameId = mintReceipt.events![0].args![2].toNumber();
Expand Down Expand Up @@ -311,7 +312,7 @@ describe("Soul Name", () => {
beforeEach(async () => {
const mintTx = await soulName
.connect(admin)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR);
.mint(address1.address, SOUL_NAME1, identityId1, YEAR, ARWEAVE_LINK);
const mintReceipt = await mintTx.wait();

nameId = mintReceipt.events![0].args![2].toNumber();
Expand All @@ -335,7 +336,7 @@ describe("Soul Name", () => {
beforeEach(async () => {
const mintTx = await soulName
.connect(admin)
.mint(address1.address, SOUL_NAME1, identityId1, YEAR);
.mint(address1.address, SOUL_NAME1, identityId1, YEAR, ARWEAVE_LINK);
const mintReceipt = await mintTx.wait();

nameId = mintReceipt.events![0].args![2].toNumber();
Expand Down Expand Up @@ -421,7 +422,7 @@ describe("Soul Name", () => {
// once expired, another user mints the same soul name
await soulName
.connect(admin)
.mint(address2.address, SOUL_NAME1, identityId2, YEAR);
.mint(address2.address, SOUL_NAME1, identityId2, YEAR, ARWEAVE_LINK);
});

it("shouldn't renew period when period has expired and somebody has minted same name", async () => {
Expand All @@ -432,7 +433,7 @@ describe("Soul Name", () => {
// once expired, another user mints the same soul name
await soulName
.connect(admin)
.mint(address2.address, SOUL_NAME1, identityId2, YEAR);
.mint(address2.address, SOUL_NAME1, identityId2, YEAR, ARWEAVE_LINK);

// the first admin of the soul name tries to renew the period and fails
await expect(
Expand Down
33 changes: 24 additions & 9 deletions test/SoulStore.test.ts
Expand Up @@ -39,6 +39,7 @@ const MINTING_NAME_PRICE_5LETTERS = 10000000; // 10 USDC, with 6 decimals

const SOUL_NAME = "soulNameTest";
const YEAR = 1; // 1 year
const ARWEAVE_LINK = "ar://jK9sR4OrYvODj7PD3czIAyNJalub0-vdV_JAg1NqQ-o";

describe("Soul Store", () => {
before(async () => {
Expand Down Expand Up @@ -306,6 +307,7 @@ describe("Soul Store", () => {
ethers.constants.AddressZero, // ETH
SOUL_NAME,
YEAR,
ARWEAVE_LINK,
{ value: priceInETH }
);
});
Expand All @@ -325,7 +327,8 @@ describe("Soul Store", () => {
await soulStore.connect(address1).purchaseIdentityAndName(
USDC_GOERLI, // USDC
SOUL_NAME,
YEAR
YEAR,
ARWEAVE_LINK
);
});

Expand All @@ -344,7 +347,8 @@ describe("Soul Store", () => {
await soulStore.connect(address1).purchaseIdentityAndName(
CORN_GOERLI, // $CORN
SOUL_NAME,
YEAR
YEAR,
ARWEAVE_LINK
);
});

Expand All @@ -356,6 +360,7 @@ describe("Soul Store", () => {
ethers.constants.AddressZero, // ETH
SOUL_NAME,
YEAR,
ARWEAVE_LINK,
{ value: priceInETH.div(2) }
)
).to.be.rejectedWith("INVALID_PAYMENT_AMOUNT");
Expand All @@ -377,7 +382,8 @@ describe("Soul Store", () => {
soulStore.connect(address2).purchaseIdentityAndName(
USDC_GOERLI, // USDC
SOUL_NAME,
YEAR
YEAR,
ARWEAVE_LINK
)
).to.be.rejected;
});
Expand All @@ -398,7 +404,8 @@ describe("Soul Store", () => {
soulStore.connect(address2).purchaseIdentityAndName(
CORN_GOERLI, // $CORN
SOUL_NAME,
YEAR
YEAR,
ARWEAVE_LINK
)
).to.be.rejected;
});
Expand All @@ -412,6 +419,7 @@ describe("Soul Store", () => {
ethers.constants.AddressZero, // ETH
SOUL_NAME,
YEAR,
ARWEAVE_LINK,
{ value: priceInETH.mul(2) }
);
const receipt = await tx.wait();
Expand Down Expand Up @@ -446,6 +454,7 @@ describe("Soul Store", () => {
ethers.constants.AddressZero, // ETH
SOUL_NAME,
YEAR,
ARWEAVE_LINK,
{ value: priceInETH }
);
});
Expand All @@ -465,7 +474,8 @@ describe("Soul Store", () => {
await soulStore.connect(address1).purchaseName(
USDC_GOERLI, // USDC
SOUL_NAME,
YEAR
YEAR,
ARWEAVE_LINK
);
});

Expand All @@ -484,7 +494,8 @@ describe("Soul Store", () => {
await soulStore.connect(address1).purchaseName(
CORN_GOERLI, // $CORN
SOUL_NAME,
YEAR
YEAR,
ARWEAVE_LINK
);
});

Expand All @@ -496,6 +507,7 @@ describe("Soul Store", () => {
ethers.constants.AddressZero, // ETH
SOUL_NAME,
YEAR,
ARWEAVE_LINK,
{ value: priceInETH.div(2) }
)
).to.be.rejectedWith("INVALID_PAYMENT_AMOUNT");
Expand All @@ -517,7 +529,8 @@ describe("Soul Store", () => {
soulStore.connect(address2).purchaseName(
USDC_GOERLI, // USDC
SOUL_NAME,
YEAR
YEAR,
ARWEAVE_LINK
)
).to.be.rejected;
});
Expand All @@ -538,7 +551,8 @@ describe("Soul Store", () => {
soulStore.connect(address2).purchaseName(
CORN_GOERLI, // $CORN
SOUL_NAME,
YEAR
YEAR,
ARWEAVE_LINK
)
).to.be.rejected;
});
Expand All @@ -550,7 +564,8 @@ describe("Soul Store", () => {
soulStore.connect(address1).purchaseIdentityAndName(
address2.address, // invalid payment method
SOUL_NAME,
YEAR
YEAR,
ARWEAVE_LINK
)
).to.be.rejectedWith("INVALID_PAYMENT_METHOD");
});
Expand Down
32 changes: 24 additions & 8 deletions test/SoulboundIdentity.test.ts
Expand Up @@ -18,6 +18,7 @@ let someone: SignerWithAddress;
const SOUL_NAME1 = "soulName1";
const SOUL_NAME2 = "soulName2";
const YEAR = 1; // 1 year
const ARWEAVE_LINK = "ar://jK9sR4OrYvODj7PD3czIAyNJalub0-vdV_JAg1NqQ-o";

let address1: SignerWithAddress;
let address2: SignerWithAddress;
Expand Down Expand Up @@ -79,7 +80,7 @@ describe("Soulbound Identity", () => {
it("should mint from admin", async () => {
await soulboundIdentity
.connect(admin)
.mintIdentityWithName(address1.address, SOUL_NAME1, YEAR);
.mintIdentityWithName(address1.address, SOUL_NAME1, YEAR, ARWEAVE_LINK);

expect(await soulboundIdentity.balanceOf(address1.address)).to.be.equal(
1
Expand All @@ -93,29 +94,44 @@ describe("Soulbound Identity", () => {
await expect(
soulboundIdentity
.connect(address1)
.mintIdentityWithName(address1.address, SOUL_NAME1, YEAR)
.mintIdentityWithName(
address1.address,
SOUL_NAME1,
YEAR,
ARWEAVE_LINK
)
).to.be.rejected;
});

it("should fail to mint twice", async () => {
await soulboundIdentity
.connect(admin)
.mintIdentityWithName(address1.address, SOUL_NAME1, YEAR);
.mintIdentityWithName(address1.address, SOUL_NAME1, YEAR, ARWEAVE_LINK);
await expect(
soulboundIdentity
.connect(admin)
.mintIdentityWithName(address1.address, SOUL_NAME2, YEAR)
.mintIdentityWithName(
address1.address,
SOUL_NAME2,
YEAR,
ARWEAVE_LINK
)
).to.be.rejectedWith("Soulbound identity already created!");
});

it("should fail to mint duplicated name", async () => {
await soulboundIdentity
.connect(admin)
.mintIdentityWithName(address1.address, SOUL_NAME1, YEAR);
.mintIdentityWithName(address1.address, SOUL_NAME1, YEAR, ARWEAVE_LINK);
await expect(
soulboundIdentity
.connect(admin)
.mintIdentityWithName(address2.address, SOUL_NAME1, YEAR)
.mintIdentityWithName(
address2.address,
SOUL_NAME1,
YEAR,
ARWEAVE_LINK
)
).to.be.rejectedWith("NAME_ALREADY_EXISTS");
});
});
Expand Down Expand Up @@ -179,7 +195,7 @@ describe("Soulbound Identity", () => {
beforeEach(async () => {
const mintTx = await soulboundIdentity
.connect(admin)
.mintIdentityWithName(someone.address, SOUL_NAME1, YEAR);
.mintIdentityWithName(someone.address, SOUL_NAME1, YEAR, ARWEAVE_LINK);

const mintReceipt = await mintTx.wait();
tokenId = mintReceipt.events![0].args![2].toNumber();
Expand Down Expand Up @@ -224,7 +240,7 @@ describe("Soulbound Identity", () => {
beforeEach(async () => {
const mintTx = await soulboundIdentity
.connect(admin)
.mintIdentityWithName(address1.address, SOUL_NAME1, YEAR);
.mintIdentityWithName(address1.address, SOUL_NAME1, YEAR, ARWEAVE_LINK);
const mintReceipt = await mintTx.wait();

identityId = mintReceipt.events![0].args![2].toNumber();
Expand Down

0 comments on commit d26d8c9

Please sign in to comment.