-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
License: MIT Signed-off-by: Jacob Heun <jacobheun@gmail.com>
- Loading branch information
Showing
5 changed files
with
80 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
'use strict' | ||
|
||
exports.ERR_REPO_NOT_INITIALIZED = 'ERR_REPO_NOT_INITIALIZED' | ||
exports.SWARM_KEY_NOT_FOUND = 'No swarm key found' |
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,3 @@ | ||
/key/swarm/psk/1.0.0/ | ||
/base16/ | ||
a4ec738d91ab0fbce75dfc29e8f5b6d75830aff1b76afeb51cd602a4b764aee8 |
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,55 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
chai.use(require('dirty-chai')) | ||
const expect = chai.expect | ||
const path = require('path') | ||
const ncp = require('ncp').ncp | ||
const rimraf = require('rimraf') | ||
const series = require('async/series') | ||
|
||
const Repo = require('../') | ||
const Errors = require('../').errors | ||
|
||
describe('private network', () => { | ||
describe('swarm key', () => { | ||
const repoPath = path.join(__dirname, 'slash', 'path') | ||
const swarmRepoPath = path.join(__dirname, 'fixtures/pnet-repo') | ||
|
||
afterEach(() => { | ||
rimraf.sync(repoPath) | ||
}) | ||
|
||
it('returns an error if no swarm key is found', (done) => { | ||
const repo = new Repo(repoPath) | ||
|
||
repo.swarmKey((err, swarmKeyBuffer) => { | ||
expect(swarmKeyBuffer).to.not.exist() | ||
expect(err).to.include({ | ||
message: Errors.SWARM_KEY_NOT_FOUND | ||
}) | ||
done() | ||
}) | ||
}) | ||
|
||
it('gets the swarm.key', (done) => { | ||
const repo = new Repo(repoPath) | ||
|
||
series([ | ||
(cb) => { | ||
// copy the swarm key to the repo root | ||
ncp(swarmRepoPath, repoPath, cb) | ||
}, | ||
(cb) => { | ||
repo.swarmKey((err, swarmKeyBuffer) => { | ||
expect(err).to.not.exist() | ||
expect(Buffer.isBuffer(swarmKeyBuffer)).to.equal(true) | ||
expect(swarmKeyBuffer.byteLength).to.equal(95) | ||
cb() | ||
}) | ||
} | ||
], done) | ||
}) | ||
}) | ||
}) |