This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
789ef7e
commit d1b2f5d
Showing
5 changed files
with
136 additions
and
12 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
Empty file.
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' | ||
|
||
require('./index') | ||
require('./repo') |
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,76 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const waterfall = require('async/waterfall') | ||
const bl = require('bl') | ||
const crypto = require('crypto') | ||
const os = require('os') | ||
|
||
const GoDaemon = require('./daemons/go') | ||
const JsDaemon = require('./daemons/js') | ||
|
||
function catAndCheck (daemon, hash, data, callback) { | ||
waterfall([ | ||
(cb) => daemon.api.cat(hash, cb), | ||
(stream, cb) => stream.pipe(bl(cb)) | ||
], (err, file) => { | ||
console.log('got file') | ||
expect(err).to.not.exist | ||
expect(file).to.be.eql(data) | ||
callback() | ||
}) | ||
} | ||
|
||
// TODO: these are not working, will need to figure out why | ||
describe.skip('interop - repo', () => { | ||
it('read repo: go -> js', (done) => { | ||
const dir = os.tmpdir() + '/' + Math.ceil(Math.random() * 10000) | ||
const data = crypto.randomBytes(1024 * 5) | ||
|
||
const goDaemon = new GoDaemon({init: true, disposable: false, path: dir}) | ||
let jsDaemon | ||
|
||
let hash | ||
waterfall([ | ||
(cb) => goDaemon.start(cb), | ||
(cb) => goDaemon.api.add(data, cb), | ||
(res, cb) => { | ||
hash = res[0].hash | ||
catAndCheck(goDaemon, hash, data, cb) | ||
}, | ||
(cb) => goDaemon.stop(cb), | ||
(cb) => { | ||
jsDaemon = new JsDaemon({init: false, disposable: false, path: dir}) | ||
jsDaemon.start(cb) | ||
}, | ||
(cb) => catAndCheck(goDaemon, hash, data, cb), | ||
(cb) => jsDaemon.stop(cb) | ||
], done) | ||
}) | ||
|
||
it.only('read repo: js -> go', (done) => { | ||
const dir = os.tmpdir() + '/' + Math.ceil(Math.random() * 10000) | ||
const data = crypto.randomBytes(1024 * 5) | ||
|
||
const jsDaemon = new JsDaemon({init: true, disposable: false, path: dir}) | ||
let goDaemon | ||
|
||
let hash | ||
waterfall([ | ||
(cb) => jsDaemon.start(cb), | ||
(cb) => jsDaemon.api.add(data, cb), | ||
(res, cb) => { | ||
hash = res[0].hash | ||
catAndCheck(jsDaemon, hash, data, cb) | ||
}, | ||
(cb) => jsDaemon.stop(cb), | ||
(cb) => { | ||
goDaemon = new GoDaemon({init: false, disposable: false, path: dir}) | ||
goDaemon.start(cb) | ||
}, | ||
(cb) => catAndCheck(goDaemon, hash, data, cb), | ||
(cb) => goDaemon.stop(cb) | ||
], done) | ||
}) | ||
}) |