-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathblockchain.service.spec.ts
More file actions
39 lines (30 loc) · 1.27 KB
/
blockchain.service.spec.ts
File metadata and controls
39 lines (30 loc) · 1.27 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
// Copyright 2020-2026 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0
import { BlockchainService } from './blockchain.service';
import { StellarApi, StellarApiService } from './stellar';
import { SorobanServer } from './stellar/soroban.server';
const HTTP_ENDPOINT = 'https://horizon-futurenet.stellar.org';
const SOROBAN_ENDPOINT = 'https://rpc-futurenet.stellar.org';
describe('BlockchainService', () => {
let blockchainService: BlockchainService;
beforeEach(() => {
const apiService = {
api: new StellarApi(HTTP_ENDPOINT, new SorobanServer(SOROBAN_ENDPOINT)),
} as StellarApiService;
blockchainService = new BlockchainService(apiService);
});
it('correctly calculates block timestamp', async () => {
//https://stellar.expert/explorer/testnet/ledger/1453893
const timestamp = await blockchainService.getBlockTimestamp(1453893);
expect(timestamp.toISOString()).toBe('2024-05-05T04:17:35.000Z');
});
it('correctly gets the header for a height', async () => {
const header = await blockchainService.getHeaderForHeight(1453893);
expect(header).toEqual({
blockHeight: 1453893,
blockHash: '1453893',
parentHash: '1453892',
timestamp: new Date('2024-05-05T04:17:35.000Z'),
});
});
});