Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 3767b15

Browse files
committed
tests for http-api id with js-ipfs-api
1 parent bf727b1 commit 3767b15

File tree

4 files changed

+35
-25
lines changed

4 files changed

+35
-25
lines changed

tests/test-http-api/test-bootstrap.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* globals describe, it */
2-
3-
'use strict'
1+
/* eslint-env mocha */
42

53
// const expect = require('chai').expect
64

tests/test-http-api/test-config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* globals describe, it */
2-
3-
'use strict'
1+
/* eslint-env mocha */
42

53
// const expect = require('chai').expect
64
// const APIctl = require('ipfs-api')

tests/test-http-api/test-id.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/* globals describe, it */
2-
3-
'use strict'
1+
/* eslint-env mocha */
42

53
const expect = require('chai').expect
4+
const APIctl = require('ipfs-api')
65

76
describe('id', () => {
87
describe('api', () => {
@@ -18,25 +17,42 @@ describe('id', () => {
1817
method: 'GET',
1918
url: '/api/v0/id'
2019
}, (res) => {
21-
expect(res.result).to.deep.equal({
22-
ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',
23-
PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',
24-
Addresses: {
25-
Swarm: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],
26-
API: '/ip4/127.0.0.1/tcp/6001',
27-
Gateway: '/ip4/127.0.0.1/tcp/9090'
28-
},
29-
AgentVersion: 'js-ipfs',
30-
ProtocolVersion: '9000'
31-
})
20+
expect(res.result).to.deep.equal(idResult)
3221
done()
3322
})
3423
})
3524
})
3625

37-
describe('gateway', () => {})
26+
describe('gateway', () => {
27+
// TODO
28+
})
3829

3930
describe('using js-ipfs-api', () => {
40-
// TODO
31+
var ctl
32+
33+
it('start IPFS API ctl', (done) => {
34+
ctl = APIctl('/ip4/127.0.0.1/tcp/6001')
35+
done()
36+
})
37+
38+
it('get the id', (done) => {
39+
ctl.id((err, result) => {
40+
expect(err).to.not.exist
41+
expect(result).to.deep.equal(idResult)
42+
done()
43+
})
44+
})
4145
})
4246
})
47+
48+
const idResult = {
49+
ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',
50+
PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',
51+
Addresses: {
52+
Swarm: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],
53+
API: '/ip4/127.0.0.1/tcp/6001',
54+
Gateway: '/ip4/127.0.0.1/tcp/9090'
55+
},
56+
AgentVersion: 'js-ipfs',
57+
ProtocolVersion: '9000'
58+
}

tests/test-http-api/test-version.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* globals describe, it */
2-
3-
'use strict'
1+
/* eslint-env mocha */
42

53
const expect = require('chai').expect
64
const APIctl = require('ipfs-api')

0 commit comments

Comments
 (0)