-
Notifications
You must be signed in to change notification settings - Fork 92
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
1 parent
0aadc13
commit 98eba36
Showing
11 changed files
with
191 additions
and
183 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
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
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,132 @@ | ||
import { bip32ToAddressNList } from "."; | ||
import { describeETHPath, ETHAddressDerivationScheme } from "./ethereum"; | ||
|
||
describe("describeETHPath", () => { | ||
it("works with BIP44 derivation", async () => { | ||
const describePath = (x: string) => | ||
describeETHPath(bip32ToAddressNList(x), ETHAddressDerivationScheme.BIP44).verbose; | ||
|
||
expect(describePath("m/1/2/3")).toMatchInlineSnapshot(`"m/1/2/3"`); | ||
expect(describePath("m/44'/123")).toMatchInlineSnapshot(`"m/44'/123"`); | ||
expect(describePath("m/44'/123'")).toMatchInlineSnapshot(`"m/44'/123'"`); | ||
expect(describePath("m/44'/123'/0")).toMatchInlineSnapshot(`"m/44'/123'/0"`); | ||
expect(describePath("m/44'/123'/0'")).toMatchInlineSnapshot(`"m/44'/123'/0'"`); | ||
expect(describePath("m/44'/123'/0'/0")).toMatchInlineSnapshot(`"m/44'/123'/0'/0"`); | ||
expect(describePath("m/44'/123'/0'/0/0")).toMatchInlineSnapshot(`"m/44'/123'/0'/0/0"`); | ||
expect(describePath("m/44'/0'/0'/0/0")).toMatchInlineSnapshot(`"m/44'/0'/0'/0/0"`); | ||
|
||
expect(describePath("m/44'/60'/0'/0/0")).toMatchInlineSnapshot(`"Ethereum Account #0"`); | ||
expect(describePath("m/44'/60'/1'/0/0")).toMatchInlineSnapshot(`"Ethereum Account #1"`); | ||
expect(describePath("m/44'/60'/2'/0/0")).toMatchInlineSnapshot(`"Ethereum Account #2"`); | ||
expect(describePath("m/44'/60'/3'/0/0")).toMatchInlineSnapshot(`"Ethereum Account #3"`); | ||
|
||
expect(describePath("m/44'/60'/0'/0/1")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/1"`); | ||
expect(describePath("m/44'/60'/0'/0/2")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/2"`); | ||
expect(describePath("m/44'/60'/0'/0/3")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/3"`); | ||
|
||
expect(describePath("m/44'/60'/1'/0/1")).toMatchInlineSnapshot(`"m/44'/60'/1'/0/1"`); | ||
expect(describePath("m/44'/60'/1'/2/3")).toMatchInlineSnapshot(`"m/44'/60'/1'/2/3"`); | ||
expect(describePath("m/44'/60'/0'/0")).toMatchInlineSnapshot(`"m/44'/60'/0'/0"`); | ||
expect(describePath("m/44'/60'/0'/1")).toMatchInlineSnapshot(`"m/44'/60'/0'/1"`); | ||
expect(describePath("m/44'/60'/0'/2")).toMatchInlineSnapshot(`"m/44'/60'/0'/2"`); | ||
expect(describePath("m/44'/60'/0'/3")).toMatchInlineSnapshot(`"m/44'/60'/0'/3"`); | ||
expect(describePath("m/44'/60'/1'/0")).toMatchInlineSnapshot(`"m/44'/60'/1'/0"`); | ||
expect(describePath("m/44'/60'/1'/2")).toMatchInlineSnapshot(`"m/44'/60'/1'/2"`); | ||
}); | ||
|
||
it("works with Metamask derivation", async () => { | ||
const describePath = (x: string) => | ||
describeETHPath(bip32ToAddressNList(x), ETHAddressDerivationScheme.Metamask).verbose; | ||
|
||
expect(describePath("m/1/2/3")).toMatchInlineSnapshot(`"m/1/2/3"`); | ||
expect(describePath("m/44'/123")).toMatchInlineSnapshot(`"m/44'/123"`); | ||
expect(describePath("m/44'/123'")).toMatchInlineSnapshot(`"m/44'/123'"`); | ||
expect(describePath("m/44'/123'/0")).toMatchInlineSnapshot(`"m/44'/123'/0"`); | ||
expect(describePath("m/44'/123'/0'")).toMatchInlineSnapshot(`"m/44'/123'/0'"`); | ||
expect(describePath("m/44'/123'/0'/0")).toMatchInlineSnapshot(`"m/44'/123'/0'/0"`); | ||
expect(describePath("m/44'/123'/0'/0/0")).toMatchInlineSnapshot(`"m/44'/123'/0'/0/0"`); | ||
expect(describePath("m/44'/0'/0'/0/0")).toMatchInlineSnapshot(`"m/44'/0'/0'/0/0"`); | ||
|
||
expect(describePath("m/44'/60'/0'/0/0")).toMatchInlineSnapshot(`"Ethereum Account #0"`); | ||
expect(describePath("m/44'/60'/1'/0/0")).toMatchInlineSnapshot(`"m/44'/60'/1'/0/0"`); | ||
expect(describePath("m/44'/60'/2'/0/0")).toMatchInlineSnapshot(`"m/44'/60'/2'/0/0"`); | ||
expect(describePath("m/44'/60'/3'/0/0")).toMatchInlineSnapshot(`"m/44'/60'/3'/0/0"`); | ||
|
||
expect(describePath("m/44'/60'/0'/0/1")).toMatchInlineSnapshot(`"Ethereum Account #1"`); | ||
expect(describePath("m/44'/60'/0'/0/2")).toMatchInlineSnapshot(`"Ethereum Account #2"`); | ||
expect(describePath("m/44'/60'/0'/0/3")).toMatchInlineSnapshot(`"Ethereum Account #3"`); | ||
|
||
expect(describePath("m/44'/60'/1'/0/1")).toMatchInlineSnapshot(`"m/44'/60'/1'/0/1"`); | ||
expect(describePath("m/44'/60'/1'/2/3")).toMatchInlineSnapshot(`"m/44'/60'/1'/2/3"`); | ||
expect(describePath("m/44'/60'/0'/0")).toMatchInlineSnapshot(`"m/44'/60'/0'/0"`); | ||
expect(describePath("m/44'/60'/0'/1")).toMatchInlineSnapshot(`"m/44'/60'/0'/1"`); | ||
expect(describePath("m/44'/60'/0'/2")).toMatchInlineSnapshot(`"m/44'/60'/0'/2"`); | ||
expect(describePath("m/44'/60'/0'/3")).toMatchInlineSnapshot(`"m/44'/60'/0'/3"`); | ||
expect(describePath("m/44'/60'/1'/0")).toMatchInlineSnapshot(`"m/44'/60'/1'/0"`); | ||
expect(describePath("m/44'/60'/1'/2")).toMatchInlineSnapshot(`"m/44'/60'/1'/2"`); | ||
}); | ||
|
||
it("works with OldLedger derivation", async () => { | ||
const describePath = (x: string) => | ||
describeETHPath(bip32ToAddressNList(x), ETHAddressDerivationScheme.OldLedger).verbose; | ||
|
||
expect(describePath("m/1/2/3")).toMatchInlineSnapshot(`"m/1/2/3"`); | ||
expect(describePath("m/44'/123")).toMatchInlineSnapshot(`"m/44'/123"`); | ||
expect(describePath("m/44'/123'")).toMatchInlineSnapshot(`"m/44'/123'"`); | ||
expect(describePath("m/44'/123'/0")).toMatchInlineSnapshot(`"m/44'/123'/0"`); | ||
expect(describePath("m/44'/123'/0'")).toMatchInlineSnapshot(`"m/44'/123'/0'"`); | ||
expect(describePath("m/44'/123'/0'/0")).toMatchInlineSnapshot(`"m/44'/123'/0'/0"`); | ||
expect(describePath("m/44'/123'/0'/0/0")).toMatchInlineSnapshot(`"m/44'/123'/0'/0/0"`); | ||
expect(describePath("m/44'/0'/0'/0/0")).toMatchInlineSnapshot(`"m/44'/0'/0'/0/0"`); | ||
|
||
expect(describePath("m/44'/60'/0'/0/0")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/0"`); | ||
expect(describePath("m/44'/60'/1'/0/0")).toMatchInlineSnapshot(`"m/44'/60'/1'/0/0"`); | ||
expect(describePath("m/44'/60'/2'/0/0")).toMatchInlineSnapshot(`"m/44'/60'/2'/0/0"`); | ||
expect(describePath("m/44'/60'/3'/0/0")).toMatchInlineSnapshot(`"m/44'/60'/3'/0/0"`); | ||
|
||
expect(describePath("m/44'/60'/0'/0/1")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/1"`); | ||
expect(describePath("m/44'/60'/0'/0/2")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/2"`); | ||
expect(describePath("m/44'/60'/0'/0/3")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/3"`); | ||
|
||
expect(describePath("m/44'/60'/1'/0/1")).toMatchInlineSnapshot(`"m/44'/60'/1'/0/1"`); | ||
expect(describePath("m/44'/60'/1'/2/3")).toMatchInlineSnapshot(`"m/44'/60'/1'/2/3"`); | ||
expect(describePath("m/44'/60'/0'/0")).toMatchInlineSnapshot(`"Ethereum Account #0"`); | ||
expect(describePath("m/44'/60'/0'/1")).toMatchInlineSnapshot(`"Ethereum Account #1"`); | ||
expect(describePath("m/44'/60'/0'/2")).toMatchInlineSnapshot(`"Ethereum Account #2"`); | ||
expect(describePath("m/44'/60'/0'/3")).toMatchInlineSnapshot(`"Ethereum Account #3"`); | ||
expect(describePath("m/44'/60'/1'/0")).toMatchInlineSnapshot(`"m/44'/60'/1'/0"`); | ||
expect(describePath("m/44'/60'/1'/2")).toMatchInlineSnapshot(`"m/44'/60'/1'/2"`); | ||
}); | ||
|
||
it("works with Ledger derivation", async () => { | ||
const describePath = (x: string) => | ||
describeETHPath(bip32ToAddressNList(x), ETHAddressDerivationScheme.Ledger).verbose; | ||
|
||
expect(describePath("m/1/2/3")).toMatchInlineSnapshot(`"m/1/2/3"`); | ||
expect(describePath("m/44'/123")).toMatchInlineSnapshot(`"m/44'/123"`); | ||
expect(describePath("m/44'/123'")).toMatchInlineSnapshot(`"m/44'/123'"`); | ||
expect(describePath("m/44'/123'/0")).toMatchInlineSnapshot(`"m/44'/123'/0"`); | ||
expect(describePath("m/44'/123'/0'")).toMatchInlineSnapshot(`"m/44'/123'/0'"`); | ||
expect(describePath("m/44'/123'/0'/0")).toMatchInlineSnapshot(`"m/44'/123'/0'/0"`); | ||
expect(describePath("m/44'/123'/0'/0/0")).toMatchInlineSnapshot(`"m/44'/123'/0'/0/0"`); | ||
expect(describePath("m/44'/0'/0'/0/0")).toMatchInlineSnapshot(`"m/44'/0'/0'/0/0"`); | ||
|
||
expect(describePath("m/44'/60'/0'/0/0")).toMatchInlineSnapshot(`"Ethereum Account #0"`); | ||
expect(describePath("m/44'/60'/1'/0/0")).toMatchInlineSnapshot(`"Ethereum Account #1"`); | ||
expect(describePath("m/44'/60'/2'/0/0")).toMatchInlineSnapshot(`"Ethereum Account #2"`); | ||
expect(describePath("m/44'/60'/3'/0/0")).toMatchInlineSnapshot(`"Ethereum Account #3"`); | ||
|
||
expect(describePath("m/44'/60'/0'/0/1")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/1"`); | ||
expect(describePath("m/44'/60'/0'/0/2")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/2"`); | ||
expect(describePath("m/44'/60'/0'/0/3")).toMatchInlineSnapshot(`"m/44'/60'/0'/0/3"`); | ||
|
||
expect(describePath("m/44'/60'/1'/0/1")).toMatchInlineSnapshot(`"m/44'/60'/1'/0/1"`); | ||
expect(describePath("m/44'/60'/1'/2/3")).toMatchInlineSnapshot(`"m/44'/60'/1'/2/3"`); | ||
expect(describePath("m/44'/60'/0'/0")).toMatchInlineSnapshot(`"Ethereum Account #0 (Legacy)"`); | ||
expect(describePath("m/44'/60'/0'/1")).toMatchInlineSnapshot(`"Ethereum Account #1 (Legacy)"`); | ||
expect(describePath("m/44'/60'/0'/2")).toMatchInlineSnapshot(`"Ethereum Account #2 (Legacy)"`); | ||
expect(describePath("m/44'/60'/0'/3")).toMatchInlineSnapshot(`"Ethereum Account #3 (Legacy)"`); | ||
expect(describePath("m/44'/60'/1'/0")).toMatchInlineSnapshot(`"m/44'/60'/1'/0"`); | ||
expect(describePath("m/44'/60'/1'/2")).toMatchInlineSnapshot(`"m/44'/60'/1'/2"`); | ||
}); | ||
}); |
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
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
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
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
Oops, something went wrong.