Skip to content

Commit 96fa410

Browse files
authored
[SDK] Avoid IPFS uploads in tests whenever possible (#4824)
1 parent fc56142 commit 96fa410

File tree

16 files changed

+36
-49
lines changed

16 files changed

+36
-49
lines changed

packages/thirdweb/src/extensions/erc1155/drop1155.test.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, it } from "vitest";
2+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
23
import { VITALIK_WALLET } from "../../../test/src/addresses.js";
34
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
45
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
@@ -11,7 +12,6 @@ import { type ThirdwebContract, getContract } from "../../contract/contract.js";
1112
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
1213
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
1314
import { toEther } from "../../utils/units.js";
14-
import { getContractMetadata } from "../common/read/getContractMetadata.js";
1515
import { deployERC1155Contract } from "../prebuilts/deploy-erc1155.js";
1616
import { balanceOf } from "./__generated__/IERC1155/read/balanceOf.js";
1717
import { nextTokenIdToMint } from "./__generated__/IERC1155Enumerable/read/nextTokenIdToMint.js";
@@ -37,6 +37,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
3737
client: TEST_CLIENT,
3838
params: {
3939
name: "Test DropERC1155",
40+
contractURI: TEST_CONTRACT_URI,
4041
},
4142
type: "DropERC1155",
4243
});
@@ -49,16 +50,6 @@ describe.runIf(process.env.TW_SECRET_KEY)(
4950
// this deploys a contract, it may take some time
5051
}, 60_000);
5152

52-
describe("Deployment", () => {
53-
it("should deploy", async () => {
54-
expect(contract).toBeDefined();
55-
});
56-
it("should have the correct name", async () => {
57-
const metadata = await getContractMetadata({ contract });
58-
expect(metadata.name).toBe("Test DropERC1155");
59-
});
60-
});
61-
6253
it("should allow for lazy minting tokens", async () => {
6354
const mintTx = lazyMint({
6455
contract,

packages/thirdweb/src/extensions/erc1155/token1155.test.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, it } from "vitest";
2+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
23
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
34
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
45
import {
@@ -7,7 +8,6 @@ import {
78
} from "../../../test/src/test-wallets.js";
89
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
910
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
10-
import { getContractMetadata } from "../common/read/getContractMetadata.js";
1111
import { deployERC1155Contract } from "../prebuilts/deploy-erc1155.js";
1212
import { balanceOf } from "./__generated__/IERC1155/read/balanceOf.js";
1313
import { totalSupply } from "./__generated__/IERC1155/read/totalSupply.js";
@@ -27,6 +27,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenERC1155", () => {
2727
client: TEST_CLIENT,
2828
params: {
2929
name: "Test TokenERC1155",
30+
contractURI: TEST_CONTRACT_URI,
3031
},
3132
type: "TokenERC1155",
3233
});
@@ -39,16 +40,6 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenERC1155", () => {
3940
// this deploys a contract, it may take some time
4041
}, 60_000);
4142

42-
describe("Deployment", () => {
43-
it("should deploy", async () => {
44-
expect(contract).toBeDefined();
45-
});
46-
it("should have the correct name", async () => {
47-
const metadata = await getContractMetadata({ contract });
48-
expect(metadata.name).toBe("Test TokenERC1155");
49-
});
50-
});
51-
5243
it("should allow for minting tokens", async () => {
5344
// initially no tokens minted
5445
await expect(nextTokenIdToMint({ contract })).resolves.toBe(0n);

packages/thirdweb/src/extensions/erc20/drop20.test.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, it } from "vitest";
2+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
23
import { VITALIK_WALLET } from "../../../test/src/addresses.js";
34
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
45
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
@@ -12,7 +13,6 @@ import { type ThirdwebContract, getContract } from "../../contract/contract.js";
1213
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
1314
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
1415
import { toEther } from "../../utils/units.js";
15-
import { getContractMetadata } from "../common/read/getContractMetadata.js";
1616
import { deployERC20Contract } from "../prebuilts/deploy-erc20.js";
1717
import { getClaimConditions } from "./drops/read/getClaimConditions.js";
1818
import { claimTo } from "./drops/write/claimTo.js";
@@ -35,6 +35,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
3535
client: TEST_CLIENT,
3636
params: {
3737
name: "Test DropERC20",
38+
contractURI: TEST_CONTRACT_URI,
3839
},
3940
type: "DropERC20",
4041
});
@@ -47,16 +48,6 @@ describe.runIf(process.env.TW_SECRET_KEY)(
4748
// this deploys a contract, it may take some time
4849
}, 60_000);
4950

50-
describe("Deployment", () => {
51-
it("should deploy", async () => {
52-
expect(contract).toBeDefined();
53-
});
54-
it("should have the correct name", async () => {
55-
const metadata = await getContractMetadata({ contract });
56-
expect(metadata.name).toBe("Test DropERC20");
57-
});
58-
});
59-
6051
it("should allow to claim tokens", async () => {
6152
await expect(
6253
getBalance({ contract, address: TEST_ACCOUNT_A.address }),

packages/thirdweb/src/extensions/erc721/drop721.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, it } from "vitest";
2+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
23
import { VITALIK_WALLET } from "../../../test/src/addresses.js";
34
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
45
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
@@ -12,7 +13,6 @@ import { type ThirdwebContract, getContract } from "../../contract/contract.js";
1213
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
1314
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
1415
import { toEther } from "../../utils/units.js";
15-
import { getContractMetadata } from "../common/read/getContractMetadata.js";
1616
import { deployERC20Contract } from "../prebuilts/deploy-erc20.js";
1717
import { deployERC721Contract } from "../prebuilts/deploy-erc721.js";
1818
import { balanceOf } from "./__generated__/IERC721A/read/balanceOf.js";
@@ -40,6 +40,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
4040
client: TEST_CLIENT,
4141
params: {
4242
name: "Test DropERC721",
43+
contractURI: TEST_CONTRACT_URI,
4344
},
4445
type: "DropERC721",
4546
});
@@ -50,6 +51,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
5051
client: TEST_CLIENT,
5152
params: {
5253
name: "Test ERC20",
54+
contractURI: TEST_CONTRACT_URI,
5355
},
5456
type: "TokenERC20",
5557
});
@@ -68,16 +70,6 @@ describe.runIf(process.env.TW_SECRET_KEY)(
6870
// this deploys a contract, it may take some time
6971
}, 120_000);
7072

71-
describe("Deployment", () => {
72-
it("should deploy", async () => {
73-
expect(contract).toBeDefined();
74-
});
75-
it("should have the correct name", async () => {
76-
const metadata = await getContractMetadata({ contract });
77-
expect(metadata.name).toBe("Test DropERC721");
78-
});
79-
});
80-
8173
it("should allow for lazy minting tokens", async () => {
8274
const mintTx = lazyMint({
8375
contract,

packages/thirdweb/src/extensions/erc721/lazyMinting/write/createAndReveal.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { beforeAll, describe, it } from "vitest";
22
import { expect } from "vitest";
3+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
34
import { ANVIL_CHAIN } from "../../../../../test/src/chains.js";
45
import { TEST_CLIENT } from "../../../../../test/src/test-clients.js";
56
import { TEST_ACCOUNT_A } from "../../../../../test/src/test-wallets.js";
@@ -39,8 +40,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("createAndReveal", () => {
3940
type: "DropERC721",
4041
params: {
4142
name: "Test NFT",
42-
description: "Test NFT Description",
43-
contractURI: "",
43+
contractURI: TEST_CONTRACT_URI,
4444
},
4545
});
4646
contract = getContract({

packages/thirdweb/src/extensions/erc721/write/mintTo.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ANVIL_CHAIN } from "~test/chains.js";
33
import { TEST_CLIENT } from "~test/test-clients.js";
44
import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
55

6+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
67
import {
78
type ThirdwebContract,
89
getContract,
@@ -27,6 +28,7 @@ describe.runIf(!!process.env.TW_SECRET_KEY)("erc721 mintTo extension", () => {
2728
type: "TokenERC721",
2829
params: {
2930
name: "NFTDrop",
31+
contractURI: TEST_CONTRACT_URI,
3032
},
3133
});
3234
contract = getContract({

packages/thirdweb/src/extensions/marketplace/english-auctions/english-auctions.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, it } from "vitest";
2+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
23
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
34
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
45
import {
@@ -37,6 +38,7 @@ describe.skip("Marketplace: English Auctions", () => {
3738
client: TEST_CLIENT,
3839
params: {
3940
name: "TestMarketPlace",
41+
contractURI: TEST_CONTRACT_URI,
4042
},
4143
});
4244
marketplaceContract = getContract({
@@ -53,6 +55,7 @@ describe.skip("Marketplace: English Auctions", () => {
5355
client: TEST_CLIENT,
5456
params: {
5557
name: "TestERC721",
58+
contractURI: TEST_CONTRACT_URI,
5659
},
5760
});
5861

packages/thirdweb/src/extensions/marketplace/offers/offers.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, it } from "vitest";
2+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
23
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
34
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
45
import {
@@ -43,6 +44,7 @@ describe.skip("Marketplace: Offers", () => {
4344
client: TEST_CLIENT,
4445
params: {
4546
name: "TestMarketPlace",
47+
contractURI: TEST_CONTRACT_URI,
4648
},
4749
});
4850
marketplaceContract = getContract({
@@ -59,6 +61,7 @@ describe.skip("Marketplace: Offers", () => {
5961
client: TEST_CLIENT,
6062
params: {
6163
name: "TestERC721",
64+
contractURI: TEST_CONTRACT_URI,
6265
},
6366
});
6467

packages/thirdweb/src/extensions/modules/ClaimableERC1155/claimableERC1155.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, it } from "vitest";
2+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
23
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
34
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
45
import {
@@ -29,7 +30,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularClaimableERC1155", () => {
2930
core: "ERC1155",
3031
params: {
3132
name: "TestDropERC1155",
32-
symbol: "TT",
33+
contractURI: TEST_CONTRACT_URI,
3334
},
3435
modules: [
3536
ClaimableERC1155.module({

packages/thirdweb/src/extensions/modules/ClaimableERC20/claimableERC20.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, it } from "vitest";
2+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
23
import { ANVIL_CHAIN } from "../../../../test/src/chains.js";
34
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
45
import {
@@ -26,7 +27,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularDropERC20", () => {
2627
core: "ERC20",
2728
params: {
2829
name: "TestDropERC20",
29-
symbol: "TT",
30+
contractURI: TEST_CONTRACT_URI,
3031
},
3132
modules: [
3233
ClaimableERC20.module({

0 commit comments

Comments
 (0)