This repository has been archived by the owner on Apr 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
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
eec7b80
commit b9c3774
Showing
18 changed files
with
116 additions
and
99 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
5 changes: 5 additions & 0 deletions
5
...s/vvisp-utils/src/mnemonicToPrivateKey.js → packages/vvisp-utils/src/getPrivateKey.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const chai = require('chai'); | ||
const expect = chai.expect; | ||
chai.should(); | ||
|
||
const { getPrivateKey } = require('../src'); | ||
|
||
const MNEMONIC = | ||
'away clutch still element short tooth spy hood army split stomach sail'; | ||
|
||
describe('# getPrivateKey test', function() { | ||
describe('# input arguments', function() { | ||
it('should reject when mnemonic is not string', function() { | ||
expect(() => getPrivateKey(undefined)).to.throw(TypeError); | ||
expect(() => getPrivateKey(null)).to.throw(TypeError); | ||
expect(() => getPrivateKey(123)).to.throw(TypeError); | ||
expect(() => getPrivateKey({ a: 1 })).to.throw(TypeError); | ||
expect(() => getPrivateKey(['hello', 'there'])).to.throw(TypeError); | ||
}); | ||
it('should reject when length of mnemonic is not 12', function() { | ||
const mnemonic11 = | ||
'away clutch still element short tooth spy hood army split stomach'; | ||
const mnemonic13 = | ||
'away clutch still element short tooth spy hood army split stomach sail still'; | ||
expect(() => getPrivateKey('')).to.throw(TypeError); | ||
expect(() => getPrivateKey(mnemonic11)).to.throw(TypeError); | ||
expect(() => getPrivateKey(mnemonic13)).to.throw(TypeError); | ||
}); | ||
it('should reject when index is not number except undefined and null', function() { | ||
expect(() => getPrivateKey(MNEMONIC, '123')).to.throw(TypeError); | ||
expect(() => getPrivateKey(MNEMONIC, { a: 1 })).to.throw(TypeError); | ||
expect(() => getPrivateKey(MNEMONIC, ['hello', 'there'])).to.throw( | ||
TypeError | ||
); | ||
}); | ||
it('should set 0 when index is undefined or null', function() { | ||
const nullIndex = getPrivateKey(MNEMONIC, null); | ||
const undefinedIndex = getPrivateKey(MNEMONIC, undefined); | ||
const noIndex = getPrivateKey(MNEMONIC); | ||
const normalIndex = getPrivateKey(MNEMONIC, 0); | ||
nullIndex.should.equal(normalIndex); | ||
undefinedIndex.should.equal(normalIndex); | ||
noIndex.should.equal(normalIndex); | ||
}); | ||
}); | ||
describe('# return value', function() { | ||
it('should be a string', function() { | ||
const result = getPrivateKey(MNEMONIC); | ||
result.should.a('string'); | ||
}); | ||
it('should have 64 length', function() { | ||
const result = getPrivateKey(MNEMONIC); | ||
result.should.have.lengthOf(64); | ||
}); | ||
it('should be different when indexes are different', function() { | ||
const result0 = getPrivateKey(MNEMONIC, 0); | ||
const result1 = getPrivateKey(MNEMONIC, 1); | ||
result0.should.not.equal(result1); | ||
}); | ||
}); | ||
describe('private key enable', function() { | ||
before(function() { | ||
process.env.MNEMONIC = ''; | ||
process.env.PRIVATE_KEY = | ||
'9741fa712a6912b862c9043f8752ffae513cb01895985998c61620da5aaf2d2d'; | ||
}); | ||
it('should pass when private key given', function() { | ||
const result = getPrivateKey(); | ||
result.should.equal(process.env.PRIVATE_KEY); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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
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
11 changes: 2 additions & 9 deletions
11
packages/vvisp/test/dummy/testContractApis/back/js/HaechiV1.js
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.