Additional tests for hdValidatePath (#897)

* Additional tests for hdValidatePath

* Additional

* slip for Polkadot
This commit is contained in:
Jaco Greeff
2021-02-26 10:43:55 +01:00
committed by GitHub
parent 2e0b8e4d11
commit 46bfe643a6
3 changed files with 36 additions and 6 deletions
@@ -0,0 +1,28 @@
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { hdValidatePath } from '.';
const VECTORS: [string, boolean][] = [
["m/44'/60'/0'/0/0", true],
['m/0', true],
["m/123'", true],
["n/44'/60'/0'/0/0", false],
['m', false],
['m/', false],
["m/xyz'", false],
['m/123x', false],
['m/123"', false],
["m/123''", false],
["m/123'0'", false],
[`m/${0x80000000}`, false],
['m/-1', false]
];
describe('hdValidatePath', (): void => {
VECTORS.forEach(([path, result]): void => {
it(`validates ${path} as ${result.toString()}`, (): void => {
expect(hdValidatePath(path)).toEqual(result);
});
});
});