@ledgerhq/coin-stellar
Version:
Ledger Stellar Coin integration
49 lines (43 loc) • 1.14 kB
text/typescript
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
// SPDX-License-Identifier: Apache-2.0
import {
Keypair,
TransactionBuilder,
Networks,
Operation,
BASE_FEE,
Asset,
Account,
} from '@stellar/stellar-sdk'
import coinConfig from '../config'
import { StellarBroadcastFailedError } from '../types'
import { broadcast } from './broadcast'
describe('Broadcast', () => {
beforeAll(() => {
coinConfig.setCoinConfig(() => ({
status: { type: 'active' },
explorer: {
url: 'https://stellar.coin.ledger.com',
},
}))
})
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(tx.toXDR())).rejects.toThrow(StellarBroadcastFailedError)
})
})