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 3b5f194 commit 3cfe758
Showing 1 changed file with 42 additions and 9 deletions.
51 changes: 42 additions & 9 deletions src/families/ethereum/test-specifics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,50 @@ 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 openSeaRes: any = await getPaginatedOpenSeaRes().then((assets) =>
// removes lazy minting from open sea
assets?.filter(
(a: any) =>
!(
a?.is_presale &&
a?.num_sales === 0 &&
a?.creator?.address === nftAccount.freshAddress
)
)
);

const openSeaList = openSeaRes.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 3cfe758

Please sign in to comment.