// SPDX-FileCopyrightText: © 2026 LEDGER SAS // SPDX-License-Identifier: Apache-2.0 import type { StellarCoinConfig, StellarContext } from '../../config' import { getLastBlock } from '../../network' import { registerHorizonInterceptors } from '../../network/horizon' import { getBlock } from '../getBlock' import { getBlockInfo } from '../getBlockInfo' const mainnetConfig: StellarCoinConfig = { status: { type: 'active' }, name: 'Stellar', unit: { name: 'Lumen', code: 'XLM', magnitude: 7 }, explorer: { url: 'https://stellar.coin.ledger.com', }, } const context: StellarContext = { config: async () => mainnetConfig, logger: jest.fn(), } describe('getBlock (integration)', () => { let lastBlockHeight: number let lastBlockHash: string let lastBlockTime: Date beforeAll(async () => { registerHorizonInterceptors(context) const { height, hash, time } = await getLastBlock(mainnetConfig) lastBlockHeight = height lastBlockHash = hash lastBlockTime = time }) it('fetches ledger metadata and a known payment transaction', async () => { const block = await getBlock(context, lastBlockHeight) expect(block.info).toMatchObject({ height: lastBlockHeight, hash: lastBlockHash, time: lastBlockTime, parent: { height: lastBlockHeight - 1, hash: expect.any(String), }, }) expect(block.transactions.length).toBeGreaterThan(0) }) it('returns consistent metadata between getBlockInfo and getBlock', async () => { const info = await getBlockInfo(context, lastBlockHeight) const block = await getBlock(context, lastBlockHeight) expect(info).toEqual(block.info) }) })