Skip to content

Commit

Permalink
Cleanup test
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl committed Sep 4, 2024
1 parent dc013c7 commit 19d09c2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
15 changes: 7 additions & 8 deletions test/BigNumberUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ethers } from "ethers";
import { toWei, toGWei, toBN } from "../src/utils/BigNumberUtils";
import { BigNumber, parseEther, parseUnits, toWei, toGWei, toBN } from "../src/utils/BigNumberUtils";
import { expect } from "./utils";

describe("BigNumberUtils", () => {
describe("toWei", () => {
it("should convert a stringified number to a BigNumber with 18 decimal places", () => {
const num = "123.456";
const expected = ethers.utils.parseEther(num);
const expected = parseEther(num);
const result = toWei(num);
expect(result).to.be.deep.includes(expected);
});
Expand All @@ -15,7 +14,7 @@ describe("BigNumberUtils", () => {
describe("toGWei", () => {
it("should convert a stringified number to a BigNumber with 9 decimal places", () => {
const num = "123.456";
const expected = ethers.utils.parseUnits(num, 9);
const expected = parseUnits(num, 9);
const result = toGWei(num);
expect(result).to.be.deep.includes(expected);
});
Expand All @@ -24,28 +23,28 @@ describe("BigNumberUtils", () => {
describe("toBN", () => {
it("should convert a stringified integer to a BigNumber", () => {
const num = "123456";
const expected = ethers.BigNumber.from(num);
const expected = BigNumber.from(num);
const result = toBN(num);
expect(result).to.be.deep.includes(expected);
});

it("should convert a stringified number with decimal places to a BigNumber and round down by default", () => {
const num = "123.456";
const expected = ethers.BigNumber.from("123");
const expected = BigNumber.from("123");
const result = toBN(num);
expect(result).to.be.deep.includes(expected);
});

it("should round up if rounding is set to 'ceil'", () => {
const num = "123.456";
const expected = ethers.BigNumber.from("124");
const expected = BigNumber.from("124");
const result = toBN(num, "ceil");
expect(result).to.be.deep.includes(expected);
});

it("should round up if rounding is set to 'round' and the first decimal is greater than or equal to 5", () => {
const num = "123.556";
const expected = ethers.BigNumber.from("124");
const expected = BigNumber.from("124");
const result = toBN(num, "round");
expect(result).to.be.deep.includes(expected);
});
Expand Down
2 changes: 1 addition & 1 deletion test/poolClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as poolClient from "../src/pool/poolClient";
import { BigNumber } from "ethers";
import { BigNumber } from "../src/utils";
import { expect } from "./utils";

describe("poolClient", function () {
Expand Down
4 changes: 3 additions & 1 deletion test/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as utils from "@across-protocol/contracts/dist/test-utils";
import { BigNumber, BigNumberish, Contract, providers } from "ethers";
import { Contract, providers } from "ethers";
import {
AcrossConfigStoreClient as ConfigStoreClient,
GLOBAL_CONFIG_STORE_KEYS,
Expand All @@ -15,6 +15,8 @@ import {
V2Fill,
} from "../../src/interfaces";
import {
BigNumber,
BigNumberish,
bnUint32Max,
bnOne,
getCurrentTime,
Expand Down

0 comments on commit 19d09c2

Please sign in to comment.