Skip to content

Commit

Permalink
evm test
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Feb 15, 2024
1 parent 4beda88 commit 1b0e0f1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/utils/evm.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { describe, expect, test } from "bun:test";
import {
coinTypeToEvmChainId,
evmChainIdToCoinType,
isEvmCoinType,
} from "./evm.js";

describe("isEvmCoinType()", () => {
test("non evm coin type", () => {
expect(isEvmCoinType(1000)).toBeFalse();
});
test("evm coin type", () => {
expect(isEvmCoinType(2147483658)).toBeTrue();
});
});

describe("evmChainIdToCoinType()", () => {
test("normal chainId", () => {
expect(evmChainIdToCoinType(10)).toBe(2147483658);
});
test("chainId too large", () => {
expect(() => evmChainIdToCoinType(2147483648)).toThrow("Invalid chainId");
});
});

describe("coinTypeToEvmChainId()", () => {
test("non evm coin type", () => {
expect(() => coinTypeToEvmChainId(1000)).toThrow(
"Coin type is not an EVM chain"
);
});
test("evm coin type", () => {
expect(coinTypeToEvmChainId(2147483658)).toBe(10);
});
});

0 comments on commit 1b0e0f1

Please sign in to comment.