Skip to content

Commit

Permalink
feat: mock hiro ft requests
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Aug 26, 2024
1 parent 56d021b commit c8a2620
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/mocks/mock-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { json } from '@tests/utils';

import { mockMainnetTestAccountStacksBnsNameRequest } from './mock-stacks-bns';
import { mockStacksFeeRequests } from './mock-stacks-fees';
import { mockMainnetTestAccountStacksFTsRequest } from './mock-stacks-fts';
import { mockMainnetTestAccountStacksNFTsRequest } from './mock-stacks-nfts';
import { mockMainnetTestAccountStacksTxsRequests } from './mock-stacks-txs';
import { mockMainnetTestAccountBitcoinRequests } from './mock-utxos';
Expand All @@ -18,5 +19,6 @@ export async function setupMockApis(page: Page) {
mockMainnetTestAccountStacksBnsNameRequest(page),
mockMainnetTestAccountStacksTxsRequests(page),
mockMainnetTestAccountStacksNFTsRequest(page),
mockMainnetTestAccountStacksFTsRequest(page),
]);
}
46 changes: 46 additions & 0 deletions tests/mocks/mock-stacks-fts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { Page } from '@playwright/test';

const mockedLongFtMetadata = {
name: 'LONGcoin',
symbol: 'LONG',
decimals: 6,
total_supply: '888888888888888888',
token_uri: 'https://storage.googleapis.com/longcoin/LONGcoin-metadata.json',
description:
"$LONG will bring prosperity and BDE, Big Dragon Energy, to the Stacks blockchain. It's the first and most auspicious memecoin of the year of the dragon!",
image_uri:
'https://assets.hiro.so/api/mainnet/token-metadata-api/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin/1.png',
image_thumbnail_uri:
'https://assets.hiro.so/api/mainnet/token-metadata-api/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin/1-thumb.png',
image_canonical_uri: 'https://storage.googleapis.com/longcoin/LONGcoin-image.png',
tx_id: '0x170498fd9b2762242b833a92c87adb12dea471bb0dfa4584462af7e05ac85ce2',
sender_address: 'SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3',
metadata: {
sip: 16,
name: 'LONGcoin',
description:
"$LONG will bring prosperity and BDE, Big Dragon Energy, to the Stacks blockchain. It's the first and most auspicious memecoin of the year of the dragon!",
image: 'https://storage.googleapis.com/longcoin/LONGcoin-image.png',
cached_image:
'https://assets.hiro.so/api/mainnet/token-metadata-api/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin/1.png',
cached_thumbnail_image:
'https://assets.hiro.so/api/mainnet/token-metadata-api/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin/1-thumb.png',
},
};

export async function mockMainnetTestAccountStacksFTsRequest(page: Page) {
await page.route(`**/api.hiro.so/metadata/v1/ft/**`, route =>
route.fulfill({
json: {},
})
);

// Mock one supported FT token metadata request
await page.route(
'https://api.hiro.so/metadata/v1/ft/SP265WBWD4NH7TVPYQTVD23X3607NNK4484DTXQZ3.longcoin',
route =>
route.fulfill({
json: mockedLongFtMetadata,
})
);
}

0 comments on commit c8a2620

Please sign in to comment.