From e5f28badd1b12e2a0e2cc8b72561f98ee82dcdbc Mon Sep 17 00:00:00 2001 From: ponyjackal Date: Tue, 27 Feb 2024 12:34:59 -0800 Subject: [PATCH] feat: add unit test for cryptokitties netAssetTransfers --- .../_common/netAssetTransfers.spec.ts | 34 +++++++++++++++++++ .../ethereum/assetTransfersOldNFTs.spec.ts | 1 - 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/transformers/_common/netAssetTransfers.spec.ts b/src/transformers/_common/netAssetTransfers.spec.ts index 6d26733..63b0e56 100644 --- a/src/transformers/_common/netAssetTransfers.spec.ts +++ b/src/transformers/_common/netAssetTransfers.spec.ts @@ -1,4 +1,5 @@ import { transform as transactionAssetTransfers } from './assetTransfers'; +import { transform as transactionAssetTransfersOldNFTs } from './../ethereum/assetTransfersOldNFTs'; import { transform } from './netAssetTransfers'; import { loadBlockFixture } from '../../helpers/utils'; import { KNOWN_ADDRESSES } from '../../helpers/constants'; @@ -28,4 +29,37 @@ describe('transactionNetAssetTransfers', () => { ]); } }); + + it('should return net asset transfers for old nfts', () => { + const cryptoKittiesBlock = loadBlockFixture('ethereum', '18815007_decoded'); + const cryptoKittiesAssetResult = + transactionAssetTransfers(cryptoKittiesBlock); + const cryptoKittiesResult = transactionAssetTransfersOldNFTs( + cryptoKittiesAssetResult, + ); + const assetResult = transform(cryptoKittiesResult); + const cryptoKittiesTx = assetResult.transactions.find( + (tx) => + tx.hash === + '0x76a07f3f822f6235372804b2ffab705a79b89dbe6a15ad086b6879aa97d60321', + ); + expect(cryptoKittiesTx).toBeDefined(); + if (cryptoKittiesTx) { + const ckTransfers = cryptoKittiesTx.netAssetTransfers; + expect(Object.keys(ckTransfers).length).toBe(2); + expect( + ckTransfers['0x82f8cb7e198972e2ef89e0c0cc10ffbd878792a6'].sent.length, + ).toBe(0); + expect( + ckTransfers['0x82f8cb7e198972e2ef89e0c0cc10ffbd878792a6'].received, + ).toStrictEqual([ + { + asset: '0x06012c8cf97bead5deae237070f9587f8e7a266d', + id: '0x06012c8cf97bead5deae237070f9587f8e7a266d-2020925', + tokenId: '2020925', + type: 'erc721', + }, + ]); + } + }); }); diff --git a/src/transformers/ethereum/assetTransfersOldNFTs.spec.ts b/src/transformers/ethereum/assetTransfersOldNFTs.spec.ts index 11b8cc1..feb2568 100644 --- a/src/transformers/ethereum/assetTransfersOldNFTs.spec.ts +++ b/src/transformers/ethereum/assetTransfersOldNFTs.spec.ts @@ -101,7 +101,6 @@ describe('transactionAssetTransfersOldNFTs', () => { }); it('should return asset transfers for Cryptokitties transactions', () => { - // Sorted combo transfers const cryptoKittiesBlock = loadBlockFixture('ethereum', '18815007_decoded'); const cryptoKittiesAssetResult = transactionAssetTransfers(cryptoKittiesBlock);