Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Update ugly integration test for NFTs
Browse files Browse the repository at this point in the history
  • Loading branch information
lambertkevin committed Sep 22, 2021
1 parent a393771 commit 40bf2f7
Showing 1 changed file with 43 additions and 9 deletions.
52 changes: 43 additions & 9 deletions src/families/ethereum/test-specifics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,51 @@ export default (): void => {
.pipe(reduce((a, f) => f(a), account))
.toPromise();

const openSeaRes = await axios
.get(
`https://api.opensea.io/api/v1/assets?limit=50&owner=${nftAccount.freshAddress}`
)
.then(({ data }) =>
data?.assets.filter(
(a) => a?.asset_contract?.schema_name === "ERC721"
)
const getPaginatedOpenSeaRes = async (assets = []) => {
const { data } = await axios.get(
`https://api.opensea.io/api/v1/assets?offset=${assets.length}&limit=50&owner=${nftAccount.freshAddress}`
);

expect(synced.NFT?.length).toBe(openSeaRes.length);
assets.push(...((data?.assets ?? []) as []));

if (data?.assets?.length === 50) {
await getPaginatedOpenSeaRes(assets);
}

return assets;
};

const openSeaList: any = await getPaginatedOpenSeaRes().then(
(assets: any) =>
// removes lazy minting from open sea
assets
?.filter(
(a) =>
!(
a?.is_presale &&
a?.num_sales === 0 &&
a?.creator?.address === nftAccount.freshAddress
)
)
.map((n) => ({
contract: n.asset_contract.address,
tokenId: n.token_id,
}))
);

const ourList =
synced.NFT?.map((n) => ({
contract: n.collection.contract,
tokenId: n.tokenId,
})) || [];

expect(ourList?.length).toEqual(openSeaList?.length);
expect(
_.isEqual(
_.sortBy(openSeaList, ["contract", "tokenId"]),
_.sortBy(ourList, ["contract", "tokenId"])
)
).toBe(true);
}
);
});
Expand Down

0 comments on commit 40bf2f7

Please sign in to comment.