Skip to content

Commit

Permalink
feat: add unit test for cryptokitties netAssetTransfers
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyjackal committed Feb 27, 2024
1 parent 90c2a91 commit e5f28ba
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/transformers/_common/netAssetTransfers.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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',
},
]);
}
});
});
1 change: 0 additions & 1 deletion src/transformers/ethereum/assetTransfersOldNFTs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e5f28ba

Please sign in to comment.