From fd2094b1e55d9cf4b0fbd4ddf2237a91dee4935a Mon Sep 17 00:00:00 2001 From: JoshuaSchmidt-OpenSea Date: Fri, 12 May 2023 14:49:23 -0500 Subject: [PATCH 1/2] Add integration test --- src/__integration_tests__/postOrder.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/__integration_tests__/postOrder.ts b/src/__integration_tests__/postOrder.ts index db3488142..cea83f871 100644 --- a/src/__integration_tests__/postOrder.ts +++ b/src/__integration_tests__/postOrder.ts @@ -35,8 +35,21 @@ const sdk = new OpenSeaSDK( ); suite("SDK: order posting", () => { + test("Post Buy Order", async () => { + const postBuyOrder = { + accountAddress: WALLET_ADDRESS ? WALLET_ADDRESS : "", + startAmount: "0.004", + asset: { + tokenAddress: "0x1a92f7381b9f03921564a437210bb9396471050c", + tokenId: "2288", + }, + }; + + await sdk.createBuyOrder(postBuyOrder); + }); test("Post collection offer", async () => { const collection = await sdk.api.getCollection("cool-cats-nft"); + const postOrderRequest = { collectionSlug: collection.slug, accountAddress: WALLET_ADDRESS ? WALLET_ADDRESS : "", @@ -44,6 +57,7 @@ suite("SDK: order posting", () => { quantity: 1, paymentTokenAddress: WETH_ADDRESS, }; + await sdk.createCollectionOffer(postOrderRequest); }); }); From 336882a4418625d8271b08c0712eb1c495723419 Mon Sep 17 00:00:00 2001 From: JoshuaSchmidt-OpenSea Date: Fri, 12 May 2023 15:11:47 -0500 Subject: [PATCH 2/2] Add assertions to integration tests --- src/__integration_tests__/postOrder.ts | 15 ++++++++++++--- src/__tests__/constants.ts | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/__integration_tests__/postOrder.ts b/src/__integration_tests__/postOrder.ts index cea83f871..f3d2cd270 100644 --- a/src/__integration_tests__/postOrder.ts +++ b/src/__integration_tests__/postOrder.ts @@ -1,3 +1,4 @@ +import { expect } from "chai"; import { ethers } from "ethers"; import { suite, test } from "mocha"; import Web3 from "web3"; @@ -7,7 +8,9 @@ import { WALLET_PRIV_KEY, ALCHEMY_API_KEY, WETH_ADDRESS, + OFFER_AMOUNT, } from "../__tests__/constants"; +import { expectValidOrder } from "../__tests__/utils"; import { OpenSeaSDK } from "../index"; import { Network } from "../types"; @@ -38,15 +41,18 @@ suite("SDK: order posting", () => { test("Post Buy Order", async () => { const postBuyOrder = { accountAddress: WALLET_ADDRESS ? WALLET_ADDRESS : "", - startAmount: "0.004", + startAmount: OFFER_AMOUNT ? OFFER_AMOUNT : "0.004", asset: { tokenAddress: "0x1a92f7381b9f03921564a437210bb9396471050c", tokenId: "2288", }, }; - await sdk.createBuyOrder(postBuyOrder); + const order = await sdk.createBuyOrder(postBuyOrder); + + expectValidOrder(order); }); + test("Post collection offer", async () => { const collection = await sdk.api.getCollection("cool-cats-nft"); @@ -58,6 +64,9 @@ suite("SDK: order posting", () => { paymentTokenAddress: WETH_ADDRESS, }; - await sdk.createCollectionOffer(postOrderRequest); + const offerResponse = await sdk.createCollectionOffer(postOrderRequest); + + expect(offerResponse).to.exist; + expect(offerResponse).to.exist.and.to.have.property("protocol_data"); }); }); diff --git a/src/__tests__/constants.ts b/src/__tests__/constants.ts index 5f122607f..ae5890cec 100644 --- a/src/__tests__/constants.ts +++ b/src/__tests__/constants.ts @@ -5,6 +5,7 @@ export const MAINNET_API_KEY = process.env.API_KEY; export const WALLET_ADDRESS = process.env.WALLET_ADDRESS; export const WALLET_PRIV_KEY = process.env.WALLET_PRIV_KEY; export const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY; +export const OFFER_AMOUNT = process.env.OFFER_AMOUNT; export const mainApi = new OpenSeaAPI( {