-
Notifications
You must be signed in to change notification settings - Fork 22
test: coin-support-utils createAccount #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jhasuraj01
wants to merge
32
commits into
develop
Choose a base branch
from
test/coin-support-utils
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
0b4acac
test: create account support functions
jhasuraj01 66fcdb3
fix: undo createDerivationPathGenerator logic
jhasuraj01 12ed23d
test: added name generator test for random schemeName
jhasuraj01 58a7f5a
test: mapDerivationPath, generate Address Per Scheme
jhasuraj01 3784704
test: makeCreateAccountsObservable
jhasuraj01 8d68574
test: improved branch coverage
jhasuraj01 b8999ec
test: improved makeCreateAccountsObservable test
jhasuraj01 da86830
test: makeCreateAccountsObservable
jhasuraj01 b20ec44
test: don't run coin-support-utils test
jhasuraj01 06d03a6
test: undo don't run coin-support-utils test
jhasuraj01 a1bd014
ci: changed ubuntu version to 22.04
jhasuraj01 0a39584
ci: undo changed ubuntu version to 22.04
jhasuraj01 fcec490
chore: skip turbo cache for test
jhasuraj01 89b8a07
chore: undo skip turbo cache for test
jhasuraj01 0c640f3
test: removed unwanted files and imporved branch coverage
jhasuraj01 0777687
chore: skip turbo cache for test
jhasuraj01 66181f2
chore: undo skip turbo cache for test
jhasuraj01 5e88f83
refactor: write the output in terms of 0x80000000 to make it more rea…
jhasuraj01 1dc62b6
fix: spelling mistakes
jhasuraj01 216280d
refactor: corrected order of statements
jhasuraj01 c22e01f
refactor: updating desc to func name
jhasuraj01 e10660a
refactor: updated test description
jhasuraj01 3c43eda
refactor: updated test description
jhasuraj01 28f71d4
refactor: updated import path
jhasuraj01 dbbaa27
refactor: updated test description
jhasuraj01 8a2dae7
refactor: updated test description
jhasuraj01 b5232d3
refactor: updated import path
jhasuraj01 30174fd
refactor: updated import path
jhasuraj01 950eb96
refactor: updated test description
jhasuraj01 21663ee
test: expect generator func
jhasuraj01 7385e20
refactor: removed duplicate type def
jhasuraj01 de036aa
test: removed type def
jhasuraj01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
6 changes: 6 additions & 0 deletions
6
packages/coin-support-utils/tests/01.common/01.mapDerivationPath/__fixtures__/index.ts
This file contains hidden or 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,6 @@ | ||
| import { IFixtures } from './types'; | ||
| import { valid } from './valid'; | ||
|
|
||
| export const fixtures: IFixtures = { | ||
| valid, | ||
| }; |
9 changes: 9 additions & 0 deletions
9
packages/coin-support-utils/tests/01.common/01.mapDerivationPath/__fixtures__/types.ts
This file contains hidden or 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,9 @@ | ||
| export interface MapDerivationPathTestCases { | ||
| name: string; | ||
| input: string; | ||
| output: number[]; | ||
| } | ||
|
|
||
| export interface IFixtures { | ||
| valid: MapDerivationPathTestCases[]; | ||
| } |
19 changes: 19 additions & 0 deletions
19
packages/coin-support-utils/tests/01.common/01.mapDerivationPath/__fixtures__/valid.ts
This file contains hidden or 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,19 @@ | ||
| import { MapDerivationPathTestCases } from './types'; | ||
|
|
||
| export const valid: MapDerivationPathTestCases[] = [ | ||
| { | ||
| name: 'should map derivation path with single index', | ||
| input: "m/44'", | ||
| output: [0x80000000 + 44], | ||
| }, | ||
| { | ||
| name: 'should map derivation path with multiple index', | ||
| input: "m/44'/0'/0'/0/0", | ||
| output: [2147483692, 2147483648, 2147483648, 0, 0], | ||
| }, | ||
| { | ||
| name: 'should map derivation path with multiple index without m prefix', | ||
| input: "44'/0'/0'/0/0", | ||
| output: [2147483692, 2147483648, 2147483648, 0, 0], | ||
| }, | ||
| ]; |
12 changes: 12 additions & 0 deletions
12
packages/coin-support-utils/tests/01.common/01.mapDerivationPath/index.ts
This file contains hidden or 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,12 @@ | ||
| import { describe, test } from '@jest/globals'; | ||
| import { fixtures } from './__fixtures__'; | ||
| import { mapDerivationPath } from '../../../src'; | ||
|
|
||
| describe('01. mapDerivationPath', () => { | ||
| fixtures.valid.forEach(({ name, input, output }) => { | ||
| test(name, () => { | ||
| const result = mapDerivationPath(input); | ||
| expect(result).toStrictEqual(output); | ||
| }); | ||
| }); | ||
| }); | ||
6 changes: 6 additions & 0 deletions
6
...pport-utils/tests/02.createAccount/01.createDerivationPathGenerator/__fixtures__/index.ts
This file contains hidden or 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,6 @@ | ||
| import { IFixtures } from './types'; | ||
| import { valid } from './valid'; | ||
|
|
||
| export const fixtures: IFixtures = { | ||
| valid, | ||
| }; |
15 changes: 15 additions & 0 deletions
15
...pport-utils/tests/02.createAccount/01.createDerivationPathGenerator/__fixtures__/types.ts
This file contains hidden or 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,15 @@ | ||
| import { createDerivationPathGenerator } from '../../../../src'; | ||
|
|
||
| export interface DerivationPathGeneratorTestCases { | ||
| name: string; | ||
| input: { | ||
| basePath: string; | ||
| existingDerivationPaths: string[]; | ||
| limit: number; | ||
| }; | ||
| output: ReturnType<ReturnType<typeof createDerivationPathGenerator>>; | ||
| } | ||
|
|
||
| export interface IFixtures { | ||
| valid: DerivationPathGeneratorTestCases[]; | ||
| } |
67 changes: 67 additions & 0 deletions
67
...pport-utils/tests/02.createAccount/01.createDerivationPathGenerator/__fixtures__/valid.ts
This file contains hidden or 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,67 @@ | ||
| import { DerivationPathGeneratorTestCases } from './types'; | ||
|
|
||
| export const valid: DerivationPathGeneratorTestCases[] = [ | ||
| { | ||
| name: 'should generate derivation path from zero index', | ||
| input: { | ||
| basePath: "m/44'/0'/0'/0/i", | ||
| existingDerivationPaths: [], | ||
| limit: 3, | ||
| }, | ||
| output: [ | ||
| { | ||
| derivationPath: "m/44'/0'/0'/0/0", | ||
| index: 0, | ||
| }, | ||
| { | ||
| derivationPath: "m/44'/0'/0'/0/1", | ||
| index: 1, | ||
| }, | ||
| { | ||
| derivationPath: "m/44'/0'/0'/0/2", | ||
| index: 2, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| name: 'should generate derivation path excluding existing derivation path', | ||
| input: { | ||
| basePath: "m/44'/0'/0'/0/i", | ||
| existingDerivationPaths: ["m/44'/0'/0'/0/1"], | ||
| limit: 2, | ||
| }, | ||
| output: [ | ||
| { | ||
| derivationPath: "m/44'/0'/0'/0/0", | ||
| index: 0, | ||
| }, | ||
| { | ||
| derivationPath: "m/44'/0'/0'/0/2", | ||
| index: 2, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| name: 'should return basePath if it does not include i', | ||
| input: { | ||
| basePath: "m/44'/0'/0'/0/0", | ||
| existingDerivationPaths: [], | ||
| limit: 2, | ||
| }, | ||
| output: [ | ||
| { | ||
| derivationPath: "m/44'/0'/0'/0/0", | ||
| index: 0, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| name: 'should return return empty array if base path is already derived and it does not include i', | ||
| input: { | ||
| basePath: "m/44'/0'/0'/0/0", | ||
| existingDerivationPaths: ["m/44'/0'/0'/0/0"], | ||
| limit: 2, | ||
| }, | ||
| output: [], | ||
| }, | ||
| ]; |
14 changes: 14 additions & 0 deletions
14
packages/coin-support-utils/tests/02.createAccount/01.createDerivationPathGenerator/index.ts
This file contains hidden or 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,14 @@ | ||
| import { describe, test } from '@jest/globals'; | ||
| import { createDerivationPathGenerator } from '../../../src'; | ||
| import { fixtures } from './__fixtures__'; | ||
|
|
||
| describe('01. createDerivationPathGenerator', () => { | ||
| fixtures.valid.forEach(({ name, input, output }) => { | ||
| test(name, () => { | ||
| const generator = createDerivationPathGenerator(input.basePath); | ||
| expect(generator).toBeInstanceOf(Function); | ||
| const result = generator(input.existingDerivationPaths, input.limit); | ||
| expect(result).toStrictEqual(output); | ||
| }); | ||
| }); | ||
| }); |
6 changes: 6 additions & 0 deletions
6
...ort-utils/tests/02.createAccount/02.generateDerivationPathPerScheme/__fixtures__/index.ts
This file contains hidden or 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,6 @@ | ||
| import { IFixtures } from './types'; | ||
| import { valid } from './valid'; | ||
|
|
||
| export const fixtures: IFixtures = { | ||
| valid, | ||
| }; |
14 changes: 14 additions & 0 deletions
14
...ort-utils/tests/02.createAccount/02.generateDerivationPathPerScheme/__fixtures__/types.ts
This file contains hidden or 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,14 @@ | ||
| import { | ||
| IGenerateDerivationPathsPerSchemeParams, | ||
| generateDerivationPathsPerScheme, | ||
| } from '../../../../src'; | ||
|
|
||
| export interface DerivationPathPerSchemeGeneratorTestCases { | ||
| name: string; | ||
| input: IGenerateDerivationPathsPerSchemeParams; | ||
| output: ReturnType<typeof generateDerivationPathsPerScheme>; | ||
| } | ||
|
|
||
| export interface IFixtures { | ||
| valid: DerivationPathPerSchemeGeneratorTestCases[]; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs negative test cases as well