Skip to content

Commit

Permalink
test(nodekey): add test suite for node key
Browse files Browse the repository at this point in the history
This creates a unit test suite for the node key module. Currently the
only test verifies that it will generate a valid node key.
  • Loading branch information
sangaman committed Nov 18, 2018
1 parent 2431685 commit 03fdd41
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/unit/NodeKey.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from 'chai';
import chaiAsPromised = require('chai-as-promised');
import NodeKey from '../../lib/nodekey/NodeKey';
import secp256k1 from 'secp256k1';

describe('NodeKey', () => {
it('should generate a valid node key', async () => {
const nodeKey = await NodeKey['generate']();
expect(nodeKey.nodePubKey).to.have.length(66);
expect(secp256k1.privateKeyVerify(nodeKey['privKey'])).to.be.true;
expect(secp256k1.publicKeyVerify(Buffer.from(nodeKey.nodePubKey, 'hex'))).to.be.true;
});
});

0 comments on commit 03fdd41

Please sign in to comment.