This repository was 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
Test IPFS using ipfs-api with the same interface-ipfs-core tests #432
Merged
daviddias
merged 7 commits into
master
from
feat/interface-ipfs-core-over-ipfs-api-tests
Aug 25, 2016
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
08a4b19
feat(tests): factory-http
daviddias 5f02303
feat(object-http): support protobuf encoded values
daviddias f7a668d
feat(config-http): return error if value is invalid
daviddias 5e6387d
feat(block-core): add compliance with interface-ipfs-core on block-API
daviddias a4071f0
feat(block-http): tests passing according with compliance
daviddias 44dba6c
feat(tests): all tests running
daviddias 4fce10f
refactor(CR)
daviddias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -68,7 +68,7 @@ describe('block', () => { | |
}) | ||
}) | ||
|
||
describe('api running', () => { | ||
describe.skip('api running', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why you skip me? |
||
let httpAPI | ||
before((done) => { | ||
httpAPI = new HttpAPI(repoPath) | ||
|
This file contains hidden or 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 hidden or 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,77 +1,20 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const base58 = require('bs58') | ||
const fs = require('fs') | ||
const IPFS = require('../../../src/core') | ||
const Block = require('ipfs-block') | ||
const path = require('path') | ||
|
||
const isNode = require('detect-node') | ||
|
||
const fileA = isNode | ||
? fs.readFileSync(path.join(__dirname, '../../go-ipfs-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data')) | ||
: require('buffer!./../../go-ipfs-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data') | ||
|
||
// TODO use arrow funtions again when https://github.com/webpack/webpack/issues/1944 is fixed | ||
describe('block', function () { | ||
var ipfs | ||
|
||
before((done) => { | ||
ipfs = new IPFS(require('../../utils/repo-path')) | ||
ipfs.load(done) | ||
}) | ||
'use strict' | ||
|
||
it('get', function (done) { | ||
const b58mh = 'QmVtU7ths96fMgZ8YSZAbKghyieq7AjxNdcqyVzxTt3qVe' | ||
const mh = new Buffer(base58.decode(b58mh)) | ||
ipfs.block.get(mh, (err, block) => { | ||
expect(err).to.not.exist | ||
const eq = fileA.equals(block.data) | ||
expect(eq).to.equal(true) | ||
done() | ||
}) | ||
}) | ||
const test = require('interface-ipfs-core') | ||
const IPFSFactory = require('../../utils/factory-core') | ||
|
||
it('put', (done) => { | ||
var b = new Block('random data') | ||
ipfs.block.put(b, function (err) { | ||
expect(err).to.not.exist | ||
ipfs.block.get(b.key, function (err, block) { | ||
expect(err).to.not.exist | ||
expect(b.data.equals(block.data)).to.equal(true) | ||
expect(b.key.equals(block.key)).to.equal(true) | ||
done() | ||
}) | ||
}) | ||
}) | ||
let factory | ||
|
||
it('rm', (done) => { | ||
var b = new Block('I will not last long enough') | ||
ipfs.block.put(b, function (err) { | ||
expect(err).to.not.exist | ||
ipfs.block.get(b.key, function (err, block) { | ||
expect(err).to.not.exist | ||
ipfs.block.del(b.key, function (err) { | ||
expect(err).to.not.exist | ||
ipfs.block.get(b.key, function (err, block) { | ||
expect(err).to.exist | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
const common = { | ||
setup: function (cb) { | ||
factory = new IPFSFactory() | ||
cb(null, factory) | ||
}, | ||
teardown: function (cb) { | ||
factory.dismantle(cb) | ||
} | ||
} | ||
|
||
it('stat', function (done) { | ||
const mh = new Buffer(base58 | ||
.decode('QmVtU7ths96fMgZ8YSZAbKghyieq7AjxNdcqyVzxTt3qVe')) | ||
ipfs.block.stat(mh, (err, stats) => { | ||
expect(err).to.not.exist | ||
expect(stats.Key.equals(mh)).to.equal(true) | ||
expect(stats.Size).to.equal(309) | ||
done() | ||
}) | ||
}) | ||
}) | ||
test.block(common) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a lot of duplication, would be nice to simplify this to something like this