-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathgetServerTransactionsByHashes.test.ts
More file actions
50 lines (44 loc) · 1.43 KB
/
getServerTransactionsByHashes.test.ts
File metadata and controls
50 lines (44 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { server, rest, testNetwork, mockPendingTransaction } from '__mocks__';
import { TRANSACTIONS_ENDPOINT } from 'apiCalls/endpoints';
import { getServerTransactionsByHashes } from '../getServerTransactionsByHashes';
const tx = {
...mockPendingTransaction,
gasUsed: 50000,
miniBlockHash:
'a8881b2bd43bb452383b17dd49728ee9508a0a82d1aaea3a3bdbf4b858e91d55',
round: 11159447,
epoch: 4623,
fee: '50000000000000',
timestamp: 1760956682,
timestampMs: 1760956682000,
function: 'transfer',
price: 0,
status: 'success'
};
describe('getServerTransactionsByHashes', () => {
afterEach(() => {
server.resetHandlers();
});
it('returns transactions for provided hashes', async () => {
const hash = tx.txHash;
// Mock the API response using MSW for the GET /transactions endpoint
server.use(
rest.get(
`${testNetwork.apiAddress}/${TRANSACTIONS_ENDPOINT}`,
(req, res, ctx) => {
const hashesParam = req.url.searchParams.get('hashes');
expect(hashesParam).toBe(hash);
expect(req.url.searchParams.get('withScResults')).toBe('true');
return res(ctx.status(200), ctx.json([tx]));
}
)
);
const result = await getServerTransactionsByHashes([hash], {
apiAddress: testNetwork.apiAddress
});
expect(result).toHaveLength(1);
expect(result[0]).toEqual(
expect.objectContaining({ txHash: hash, status: 'success' })
);
});
});