From 587510218ea834b661499c3fa930205dbddd13e1 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 10 May 2021 21:13:14 +0100 Subject: [PATCH] chore: add test for get with rawLeaves - add interface-core test for get with rawLeaves: true - remove cli test for "raw" as core normalises the type to "file" so it was not testing a valid conditon License: MIT Signed-off-by: Oli Evans --- packages/interface-ipfs-core/src/get.js | 13 +++++++++++++ packages/ipfs-cli/test/get.js | 22 ---------------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/packages/interface-ipfs-core/src/get.js b/packages/interface-ipfs-core/src/get.js index 4f345954d1..c1f6e7671c 100644 --- a/packages/interface-ipfs-core/src/get.js +++ b/packages/interface-ipfs-core/src/get.js @@ -86,6 +86,19 @@ module.exports = (common, options) => { expect(uint8ArrayConcat(await all(output[0].content))).to.eql(input) }) + it('should get a file added as CIDv1 with rawLeaves', async () => { + const input = uint8ArrayFromString(`TEST${Math.random()}`) + + const res = await all(importer([{ content: input }], ipfs.block, { cidVersion: 1, rawLeaves: true })) + + const cidv1 = res[0].cid + expect(cidv1.version).to.equal(1) + + const output = await all(ipfs.get(cidv1)) + expect(output[0].type).to.eql('file') + expect(uint8ArrayConcat(await all(output[0].content))).to.eql(input) + }) + it('should get a BIG file', async () => { for await (const file of ipfs.get(fixtures.bigFile.cid)) { expect(file.path).to.equal(fixtures.bigFile.cid) diff --git a/packages/ipfs-cli/test/get.js b/packages/ipfs-cli/test/get.js index a6dc508cb4..0677d4cfb4 100644 --- a/packages/ipfs-cli/test/get.js +++ b/packages/ipfs-cli/test/get.js @@ -46,28 +46,6 @@ describe('get', () => { await clean(outPath) }) - it('should get file from a raw block', async () => { - const cid = new CID('bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e') - ipfs.get.withArgs(cid.toString(), defaultOptions).returns([{ - type: 'raw', - path: 'bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e', - content: function * () { - yield buf - } - }]) - - const outPath = path.join(process.cwd(), cid.toString()) - await clean(outPath) - - const out = await cli(`get ${cid}`, { ipfs }) - expect(out) - .to.equal(`Saving file(s) ${cid}\n`) - - expect(fs.readFileSync(outPath)).to.deep.equal(buf) - - await clean(outPath) - }) - it('get file with output option', async () => { ipfs.get.withArgs(cid.toString(), defaultOptions).returns([{ type: 'file',