@ledgerhq/coin-tezos
Version:
78 lines (69 loc) • 2.15 kB
text/typescript
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
// SPDX-License-Identifier: Apache-2.0
import type { TezosCoinConfig, TezosContext } from '../config'
import type { CoreTransactionInfo } from './estimateFees'
import { mockConfig } from '../test/config'
import { estimateFees } from './estimateFees'
describe('estimateFees', () => {
const context: TezosContext = {
config: async () => mockConfig as TezosCoinConfig,
logger: () => undefined,
}
const accounts = [
{
xpub: '02389ffd73423626894cb151416e51c72ec285376673daf83545eb5edb45b261ce',
address: 'tz1UHux4ijk2Qu6Ee3dDpka4vnAiEhiDLZMa',
balance: BigInt('2000000'),
revealed: false,
},
{
// No xpub provided
address: 'tz1UHux4ijk2Qu6Ee3dDpka4vnAiEhiDLZMa',
balance: BigInt('2000000'),
revealed: false,
},
]
it.each([
[accounts[0], 'with xpub'],
[accounts[1], 'without xpub'],
])('returns correct value %s', async (account, _description) => {
// Given
const transaction = {
mode: 'send',
recipient: 'tz1PWFt4Ym6HedY78MgUP2kVDtSampGwprs5',
amount: BigInt(1_000_000),
} satisfies CoreTransactionInfo
// When
const result = await estimateFees(context, { account, transaction })
// Then
expect(result).toEqual({
estimatedFees: BigInt('825'),
fees: BigInt('491'),
gasLimit: BigInt('2169'),
storageLimit: BigInt('277'),
amount: BigInt('1000000'),
})
})
it.each([
[accounts[0], 'with xpub'],
[accounts[1], 'without xpub'],
])('returns correct value when useAllAmount %s', async (account, _description) => {
// Given
const transaction = {
mode: 'send',
recipient: 'tz1PWFt4Ym6HedY78MgUP2kVDtSampGwprs5',
amount: BigInt(1_000_000),
useAllAmount: true,
} satisfies CoreTransactionInfo
// When
const result = await estimateFees(context, { account, transaction })
// Then
expect(result).toEqual({
estimatedFees: BigInt('823'),
fees: BigInt('489'),
gasLimit: BigInt('2169'),
storageLimit: BigInt('277'),
amount: BigInt('1934629'),
})
})
})