@ledgerhq/coin-tezos
Version: 
60 lines • 2 kB
JavaScript
import { estimateFees } from "./estimateFees";
import coinConfig from "../config";
import { mockConfig } from "../test/config";
describe("estimateFees", () => {
    beforeAll(() => {
        coinConfig.setCoinConfig(() => mockConfig);
    });
    const accounts = [
        {
            xpub: "02389ffd73423626894cb151416e51c72ec285376673daf83545eb5edb45b261ce",
            address: "tz1UHux4ijk2Qu6Ee3dDpka4vnAiEhiDLZMa",
            balance: BigInt("2000000"),
            revealed: false,
        },
        {
            // No xpub provided
            address: "tz1UHux4ijk2Qu6Ee3dDpka4vnAiEhiDLZMa",
            balance: BigInt("2000000"),
            revealed: false,
        },
    ];
    it.each(accounts)("returns correct value", async (account) => {
        // Given
        const transaction = {
            mode: "send",
            recipient: "tz1PWFt4Ym6HedY78MgUP2kVDtSampGwprs5",
            amount: BigInt(1_000_000),
        };
        // When
        const result = await estimateFees({ account, transaction });
        // Then
        expect(result).toEqual({
            estimatedFees: BigInt("825"),
            fees: BigInt("491"),
            gasLimit: BigInt("2169"),
            storageLimit: BigInt("277"),
            amount: BigInt("1000000"),
        });
    });
    it.each(accounts)("returns correct value when useAllAmount", async (account) => {
        // Given
        const transaction = {
            mode: "send",
            recipient: "tz1PWFt4Ym6HedY78MgUP2kVDtSampGwprs5",
            amount: BigInt(1_000_000),
            useAllAmount: true,
        };
        // When
        const result = await estimateFees({ account, transaction });
        // Then
        expect(result).toEqual({
            estimatedFees: BigInt("823"),
            fees: BigInt("489"),
            gasLimit: BigInt("2169"),
            storageLimit: BigInt("277"),
            amount: BigInt("1934629"),
        });
    });
});
//# sourceMappingURL=estimateFees.integ.test.js.map