// SPDX-FileCopyrightText: © 2026 LEDGER SAS // SPDX-License-Identifier: Apache-2.0 import type { StellarContext } from '../../config' import { Keypair, TransactionBuilder, Networks, Operation, BASE_FEE, Asset, Account, } from '@stellar/stellar-sdk' import { StellarBroadcastFailedError } from '../../types' import { broadcast } from '../broadcast' describe('Broadcast', () => { const context: StellarContext = { config: async () => ({ name: 'Stellar', unit: { name: 'Lumen', code: 'XLM', magnitude: 7 }, status: { type: 'active' }, explorer: { url: 'https://stellar.coin.ledger.com', }, }), logger: jest.fn(), } it('throws on insufficient funds', async () => { const source = Keypair.random() const account = new Account(source.publicKey(), '0') const tx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.PUBLIC, }) .addOperation( Operation.payment({ destination: source.publicKey(), asset: Asset.native(), amount: '1', }) ) .setTimeout(0) .build() tx.sign(source) await expect(broadcast(context, tx.toXDR())).rejects.toThrow(StellarBroadcastFailedError) }) })