UNPKG

@ledgerhq/coin-hedera

Version:
73 lines (62 loc) 3.09 kB
import hederaCoinConfig from "../config"; import { getMockedConfig } from "../test/fixtures/config.fixture"; import { toEVMAddress } from "./utils"; describe("toEVMAddress", () => { const coinConfig = getMockedConfig(); beforeAll(() => { hederaCoinConfig.setCoinConfig(() => coinConfig); }); it("should resolve from an account id to a long-zero EVM address for an account without EVM alias", async () => { const address = await toEVMAddress({ configOrCurrencyId: coinConfig, accountId: "0.0.12345" }); expect(address).toEqual("0x0000000000000000000000000000000000003039"); }); it("should resolve from a long-zero EVM address to a long-zero EVM address for an account without EVM alias", async () => { const address = await toEVMAddress({ configOrCurrencyId: coinConfig, accountId: "0x0000000000000000000000000000000000003039", }); expect(address).toEqual("0x0000000000000000000000000000000000003039"); }); it("should resolve from a long-zero EVM address without prefix to a long-zero EVM address for an account without EVM alias", async () => { const address = await toEVMAddress({ configOrCurrencyId: coinConfig, accountId: "0000000000000000000000000000000000003039", }); expect(address).toEqual("0x0000000000000000000000000000000000003039"); }); it("should resolve from an account id to an EVM alias address for an account with an EVM alias", async () => { const address = await toEVMAddress({ configOrCurrencyId: coinConfig, accountId: "0.0.9806001", }); expect(address).toEqual("0xcf15538fa293ab04cdd7ce45bcdac8b6e2dc7ebc"); }); it("should resolve from an EVM alias address to an EVM alias address for an account with an EVM alias", async () => { const address = await toEVMAddress({ configOrCurrencyId: coinConfig, accountId: "0xcf15538fa293ab04cdd7ce45bcdac8b6e2dc7ebc", }); expect(address).toEqual("0xcf15538fa293ab04cdd7ce45bcdac8b6e2dc7ebc"); }); it("should resolve from an EVM alias address without prefix to an EVM alias address for an account with an EVM alias", async () => { const address = await toEVMAddress({ configOrCurrencyId: coinConfig, accountId: "cf15538fa293ab04cdd7ce45bcdac8b6e2dc7ebc", }); expect(address).toEqual("0xcf15538fa293ab04cdd7ce45bcdac8b6e2dc7ebc"); }); it("should resolve from a long-zero EVM address to an EVM alias address for an account with an EVM alias", async () => { const address = await toEVMAddress({ configOrCurrencyId: coinConfig, accountId: "0x000000000000000000000000000000000095a0b1", }); expect(address).toEqual("0xcf15538fa293ab04cdd7ce45bcdac8b6e2dc7ebc"); }); it("should resolve from a long-zero EVM address without prefix to an EVM alias address for an account with an EVM alias", async () => { const address = await toEVMAddress({ configOrCurrencyId: coinConfig, accountId: "000000000000000000000000000000000095a0b1", }); expect(address).toEqual("0xcf15538fa293ab04cdd7ce45bcdac8b6e2dc7ebc"); }); });