-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(faucet): isValidAddress should accept all bech32 addresses
- check length based on Bech32 from [BIP173](https://github.com/bitcoin/bips/blob/e1e7b77c027b3d40d07d306cc75c2b5859c91db2/bip-0173.mediawiki#bech32)
- Loading branch information
1 parent
f71cdc3
commit a65fd8b
Showing
2 changed files
with
28 additions
and
4 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,22 @@ | ||
import { isValidAddress } from "./addresses"; | ||
|
||
describe("isValidAddress", () => { | ||
it("accepts account address", () => { | ||
expect(isValidAddress("cosmos1h806c7khnvmjlywdrkdgk2vrayy2mmvf9rxk2r", "cosmos")).toBe(true); | ||
}); | ||
|
||
it("accepts an ics-27 address", () => { | ||
expect(isValidAddress("osmo1d6em9ea5y3dye6em0awqyss7ssp0a7sgjk792x8cx647cfs7a4msk0fr45", "osmo")).toBe( | ||
true, | ||
); | ||
}); | ||
|
||
it("rejects an invalid address", () => { | ||
expect(isValidAddress("cosmos1fail", "cosmos")).toBe(false); | ||
}); | ||
|
||
it("requires a prefix argument", () => { | ||
// @ts-expect-error intentionally omitting an argument | ||
expect(isValidAddress("cosmos1h806c7khnvmjlywdrkdgk2vrayy2mmvf9rxk2r")).toBe(false); | ||
}); | ||
}); |
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