Testing path derivation
I am taking description field for the path.
This commit is contained in:
parent
7defe6fe4c
commit
7a61526705
2 changed files with 38 additions and 2 deletions
test
|
@ -272,6 +272,7 @@ describe('HDNode', function () {
|
|||
fixtures.valid.forEach(function (f) {
|
||||
var network = NETWORKS[f.network]
|
||||
var hd = HDNode.fromSeedHex(f.master.seed, network)
|
||||
var master = hd
|
||||
|
||||
// FIXME: test data is only testing Private -> private for now
|
||||
f.children.forEach(function (c, i) {
|
||||
|
@ -285,6 +286,41 @@ describe('HDNode', function () {
|
|||
verifyVector(hd, c, i + 1)
|
||||
})
|
||||
})
|
||||
|
||||
// testing deriving path from master
|
||||
f.children.forEach(function (c) {
|
||||
it(c.description + ' from ' + f.master.fingerprint + ' by path', function () {
|
||||
var path = c.description
|
||||
var child = master.derivePath(path)
|
||||
|
||||
var pathSplit = path.split('/').slice(1)
|
||||
var pathNotM = pathSplit.join('/')
|
||||
var childNotM = master.derivePath(pathNotM)
|
||||
|
||||
verifyVector(child, c, pathSplit.length)
|
||||
verifyVector(childNotM, c, pathSplit.length)
|
||||
})
|
||||
})
|
||||
|
||||
// testing deriving path from the first child
|
||||
var firstChild = master.derivePath(f.children[0].description)
|
||||
|
||||
f.children.slice(1).forEach(function (c) {
|
||||
it(c.description + ' from ' + f.children[0].fingerprint + ' by path', function () {
|
||||
var path = c.description
|
||||
|
||||
var pathSplit = path.split('/').slice(2)
|
||||
var pathEnd = pathSplit.join('/')
|
||||
var pathEndM = 'm/' + path
|
||||
|
||||
var child = firstChild.derivePath(pathEnd)
|
||||
verifyVector(child, c, pathSplit.length + 1)
|
||||
|
||||
assert.throws(function () {
|
||||
firstChild.derivePath(pathEndM)
|
||||
}, /Not a master node/)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('works for Private -> public (neutered)', function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue