Skip to content

Commit 7275356

Browse files
authored
test tuneups/fixes (#1712)
1 parent f086b5a commit 7275356

8 files changed

Lines changed: 48 additions & 77 deletions

File tree

test/api/api.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import { getWETHAddress } from "../../src/utils";
55
import {
66
BAYC_CONTRACT_ADDRESS,
77
mainAPI,
8-
MAINNET_API_KEY,
9-
testnetAPI,
8+
OPENSEA_API_KEY,
109
} from "../utils/constants";
1110

1211
suite("API", () => {
1312
test("API has correct base url", () => {
1413
assert.equal(mainAPI.apiBaseUrl, "https://api.opensea.io");
15-
assert.equal(testnetAPI.apiBaseUrl, "https://testnets-api.opensea.io");
1614
});
1715

1816
test("Includes API key in request", async () => {
@@ -21,7 +19,7 @@ suite("API", () => {
2119
const logPromise = new Promise<void>((resolve, reject) => {
2220
mainAPI.logger = (log) => {
2321
try {
24-
assert.include(log, `"x-api-key":"${MAINNET_API_KEY}"`);
22+
assert.include(log, `"x-api-key":"${OPENSEA_API_KEY}"`);
2523
resolve();
2624
} catch (e) {
2725
reject(e);

test/api/getOrders.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@ suite("Getting orders", () => {
3434

3535
[OrderSide.LISTING, OrderSide.OFFER].forEach((side) => {
3636
test(`getOrders should return a list of orders > ${side}`, async () => {
37-
const { orders, next, previous } = await mainAPI.getOrders({
37+
const { orders, next } = await mainAPI.getOrders({
3838
protocol: "seaport",
3939
side,
4040
tokenIds: BAYC_TOKEN_IDS,
4141
assetContractAddress: BAYC_CONTRACT_ADDRESS,
4242
});
4343
orders.map((order) => expectValidOrder(order));
4444
expect(next).to.not.be.undefined;
45-
expect(previous).to.not.be.undefined;
4645
});
4746
});
4847
});

test/integration/postOrder.spec.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ suite("SDK: order posting", () => {
5252
});
5353

5454
test("Post Listing - Mainnet", async function () {
55-
// English auctions are no longer supported on OpenSea
56-
this.skip();
57-
5855
if (!TOKEN_ADDRESS_MAINNET || !TOKEN_ID_MAINNET) {
5956
this.skip();
6057
}
@@ -72,6 +69,9 @@ suite("SDK: order posting", () => {
7269
});
7370

7471
test("Post English Auction Listing - Mainnet", async function () {
72+
// English auctions are no longer supported on OpenSea
73+
this.skip();
74+
7575
if (!TOKEN_ADDRESS_MAINNET || !TOKEN_ID_MAINNET) {
7676
this.skip();
7777
}
@@ -102,26 +102,21 @@ suite("SDK: order posting", () => {
102102
});
103103

104104
test.skip("Post Listing - Polygon", async function () {
105-
// POL not currently supported on OS2, update this test to use WETH
106-
// (will need to supply account with WETH and do approval to conduit)
107-
108-
if (!TOKEN_ADDRESS_POLYGON || !TOKEN_ID_POLYGON) {
109-
this.skip();
110-
}
111105
const listing = {
112106
accountAddress: walletAddress,
107+
paymentTokenAddress: getWETHAddress(sdkPolygon.chain),
113108
startAmount: +LISTING_AMOUNT * 1_000_000,
114109
asset: {
115-
tokenAddress: TOKEN_ADDRESS_POLYGON,
116-
tokenId: TOKEN_ID_POLYGON,
110+
tokenAddress: TOKEN_ADDRESS_POLYGON as string,
111+
tokenId: TOKEN_ID_POLYGON as string,
117112
},
118113
expirationTime,
119114
};
120115
const order = await sdkPolygon.createListing(listing);
121116
expectValidOrder(order);
122117
});
123118

124-
test("Post Collection Offer - Mainnet", async () => {
119+
test.skip("Post Collection Offer - Mainnet", async () => {
125120
const collection = await sdk.api.getCollection("cool-cats-nft");
126121
const paymentTokenAddress = getWETHAddress(sdk.chain);
127122
const postOrderRequest = {
@@ -148,7 +143,7 @@ suite("SDK: order posting", () => {
148143
);
149144
});
150145

151-
test("Post Collection Offer - Polygon", async () => {
146+
test.skip("Post Collection Offer - Polygon", async () => {
152147
const collection = await sdkPolygon.api.getCollection("arttoken-1155-4");
153148
const paymentTokenAddress = getWETHAddress(sdkPolygon.chain);
154149
const postOrderRequest = {

test/integration/setup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ethers } from "ethers";
22
import { OpenSeaSDK } from "../../src/sdk";
33
import { Chain } from "../../src/types";
44
import {
5-
MAINNET_API_KEY,
5+
OPENSEA_API_KEY,
66
RPC_PROVIDER_MAINNET,
77
RPC_PROVIDER_POLYGON,
88
WALLET_PRIV_KEY,
@@ -36,7 +36,7 @@ export const sdk = new OpenSeaSDK(
3636
walletMainnet,
3737
{
3838
chain: Chain.Mainnet,
39-
apiKey: MAINNET_API_KEY,
39+
apiKey: OPENSEA_API_KEY,
4040
},
4141
(line) => console.info(`MAINNET: ${line}`),
4242
);
@@ -45,7 +45,7 @@ export const sdkPolygon = new OpenSeaSDK(
4545
walletPolygon,
4646
{
4747
chain: Chain.Polygon,
48-
apiKey: MAINNET_API_KEY,
48+
apiKey: OPENSEA_API_KEY,
4949
},
5050
(line) => console.info(`POLYGON: ${line}`),
5151
);

test/sdk/getBalance.spec.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
import { assert } from "chai";
22
import { ethers } from "ethers";
33
import { suite, test } from "mocha";
4-
import { OpenSeaSDK } from "../../src/index";
5-
import { Chain, TokenStandard } from "../../src/types";
6-
import { MAINNET_API_KEY, RPC_PROVIDER_MAINNET } from "../utils/constants";
7-
8-
const client = new OpenSeaSDK(
9-
RPC_PROVIDER_MAINNET,
10-
{
11-
chain: Chain.Mainnet,
12-
apiKey: MAINNET_API_KEY,
13-
},
14-
(line) => console.info(`MAINNET: ${line}`),
15-
);
4+
import { TokenStandard } from "../../src/types";
5+
import { client } from "../utils/constants";
166

177
suite("SDK: getBalance", () => {
188
const accountAddress = "0x000000000000000000000000000000000000dEaD";

test/sdk/misc.spec.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,11 @@ import {
55
SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS,
66
SHARED_STOREFRONT_ADDRESSES,
77
} from "../../src/constants";
8-
import { OpenSeaSDK } from "../../src/index";
9-
import { Chain } from "../../src/types";
108
import {
119
decodeTokenIds,
1210
getAddressAfterRemappingSharedStorefrontAddressToLazyMintAdapterAddress,
1311
} from "../../src/utils/utils";
14-
import {
15-
DAPPER_ADDRESS,
16-
MAINNET_API_KEY,
17-
RPC_PROVIDER_MAINNET,
18-
} from "../utils/constants";
19-
20-
const client = new OpenSeaSDK(
21-
RPC_PROVIDER_MAINNET,
22-
{
23-
chain: Chain.Mainnet,
24-
apiKey: MAINNET_API_KEY,
25-
},
26-
(line) => console.info(`MAINNET: ${line}`),
27-
);
12+
import { BAYC_CONTRACT_ADDRESS, client } from "../utils/constants";
2813

2914
suite("SDK: misc", () => {
3015
test("Instance has public methods", () => {
@@ -37,7 +22,7 @@ suite("SDK: misc", () => {
3722
});
3823

3924
test("Checks that a non-shared storefront address is not remapped", async () => {
40-
const address = DAPPER_ADDRESS;
25+
const address = BAYC_CONTRACT_ADDRESS;
4126
assert.equal(
4227
getAddressAfterRemappingSharedStorefrontAddressToLazyMintAdapterAddress(
4328
address,

test/sdk/orders.spec.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
import { assert } from "chai";
22
import { suite, test } from "mocha";
3-
import { OpenSeaSDK } from "../../src/index";
4-
import { Chain } from "../../src/types";
5-
import { MAINNET_API_KEY, RPC_PROVIDER_MAINNET } from "../utils/constants";
6-
7-
const client = new OpenSeaSDK(
8-
RPC_PROVIDER_MAINNET,
9-
{
10-
chain: Chain.Mainnet,
11-
apiKey: MAINNET_API_KEY,
12-
},
13-
(line) => console.info(`MAINNET: ${line}`),
14-
);
3+
import { client } from "../utils/constants";
154

165
suite("SDK: orders", () => {
176
test("Fungible tokens filter", async () => {
187
const manaAddress = "0x0f5d2fb29fb7d3cfee444a200298f468908cc942";
198
const manaPaymentToken = await client.api.getPaymentToken(manaAddress);
209
assert.isNotNull(manaPaymentToken);
21-
assert.equal(manaPaymentToken.name, "Decentraland MANA");
10+
assert.equal(manaPaymentToken.name, "Decentraland");
2211
assert.equal(manaPaymentToken.address, manaAddress);
2312
assert.equal(manaPaymentToken.decimals, 18);
2413

2514
const daiAddress = "0x6b175474e89094c44da98b954eedeac495271d0f";
2615
const daiPaymentToken = await client.api.getPaymentToken(daiAddress);
2716
assert.isNotNull(daiPaymentToken);
28-
assert.equal(daiPaymentToken.name, "Dai Stablecoin");
17+
assert.equal(daiPaymentToken.name, "Dai");
2918
assert.equal(daiPaymentToken.decimals, 18);
3019
});
3120
});

test/utils/constants.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { ethers } from "ethers";
2+
import { OpenSeaSDK } from "../../src";
23
import { OpenSeaAPI } from "../../src/api";
34
import { Chain } from "../../src/types";
45

5-
export const MAINNET_API_KEY = process.env.OPENSEA_API_KEY;
6+
require("dotenv").config();
7+
8+
export const OPENSEA_API_KEY = process.env.OPENSEA_API_KEY;
69
export const WALLET_PRIV_KEY = process.env.WALLET_PRIV_KEY;
710

811
const ALCHEMY_API_KEY_MAINNET = process.env.ALCHEMY_API_KEY;
@@ -15,23 +18,35 @@ export const RPC_PROVIDER_POLYGON = new ethers.JsonRpcProvider(
1518
`https://polygon-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY_POLYGON}`,
1619
);
1720

18-
export const OFFER_AMOUNT = process.env.OFFER_AMOUNT ?? "0.004";
19-
export const DAPPER_ADDRESS = "0x4819352bd7fadcCFAA8A2cDA4b2825a9ec51417c";
20-
export const BAYC_CONTRACT_ADDRESS =
21-
"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d";
22-
export const BAYC_TOKEN_IDS = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
23-
24-
export const mainAPI = new OpenSeaAPI(
21+
export const client = new OpenSeaSDK(
22+
RPC_PROVIDER_MAINNET,
2523
{
26-
apiKey: MAINNET_API_KEY,
2724
chain: Chain.Mainnet,
25+
apiKey: OPENSEA_API_KEY,
2826
},
29-
process.env.DEBUG ? console.log : undefined,
27+
(line) => console.info(`MAINNET: ${line}`),
3028
);
3129

32-
export const testnetAPI = new OpenSeaAPI(
30+
export const mainAPI = new OpenSeaAPI(
3331
{
34-
chain: Chain.Sepolia,
32+
apiKey: OPENSEA_API_KEY,
33+
chain: Chain.Mainnet,
3534
},
3635
process.env.DEBUG ? console.log : undefined,
3736
);
37+
38+
export const OFFER_AMOUNT = process.env.OFFER_AMOUNT ?? "0.004";
39+
40+
export const BAYC_CONTRACT_ADDRESS =
41+
"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d";
42+
export const BAYC_TOKEN_IDS = [
43+
"9703",
44+
"4049",
45+
"5340",
46+
"7354",
47+
"2352",
48+
"7112",
49+
"3255",
50+
"5532",
51+
"4610",
52+
];

0 commit comments

Comments
 (0)