-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-expressions */ | ||
import { expect } from "chai" | ||
import { ZeroAddress } from "ethers" | ||
|
||
import { isNonZeroAddress } from "../helpers/address" | ||
|
||
const ADDRESS_1: string = "0xb894c3967CFb58A5c55f1de4131d126B1eFA1EE0" | ||
const ADDRESS_1_LOWERCASE: string = ADDRESS_1.toLowerCase() | ||
const ADDRESS_1_NO_PREFIX: string = ADDRESS_1.substring(2) | ||
const ADDRESS_INVALID: string = "0xXYZ4c3967CFb58A5c55f1de4131d126B1eFA1EE0" | ||
const ADDRESS_ZERO: string = ZeroAddress | ||
|
||
describe("Helpers", () => { | ||
describe("address", () => { | ||
describe("isNonZeroAddress", () => { | ||
it("should return true for valid checksumed address", () => { | ||
expect(isNonZeroAddress(ADDRESS_1)).to.be.true | ||
}) | ||
|
||
it("should return true for lowercase address", () => { | ||
expect(isNonZeroAddress(ADDRESS_1_LOWERCASE)).to.be.true | ||
}) | ||
|
||
it("should return true for address without 0x prefix", () => { | ||
expect(isNonZeroAddress(ADDRESS_1_NO_PREFIX)).to.be.true | ||
}) | ||
|
||
it("should return false for zero address", () => { | ||
expect(isNonZeroAddress(ADDRESS_ZERO)).to.be.false | ||
}) | ||
|
||
it("should throw an error for address containing invalid character", () => { | ||
expect(() => { | ||
isNonZeroAddress(ADDRESS_INVALID) | ||
}).to.throw("invalid address") | ||
}) | ||
}) | ||
}) | ||
}) |