Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 077749c

Browse files
feat(swarm): expose PeerInfo for addrs command
1 parent 88d6002 commit 077749c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

API/swarm/README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Swarm API
99

1010
##### `JavaScript` - ipfs.swarm.addrs([callback])
1111

12-
`callback` must follow `function (err, addrs) {}` signature, where `err` is an error if the operation was not successful. `addrs` will be an array of multiaddrs.
12+
`callback` must follow `function (err, addrs) {}` signature, where `err` is an error if the operation was not successful. `addrs` will be an array of [`PeerInfo`](https://github.com/libp2p/js-peer-info)s.
1313

1414
If no `callback` is passed, a promise is returned.
1515

@@ -29,7 +29,7 @@ ipfs.swarm.addrs(function (err, addrs) {})
2929

3030
Where `addr` is of type [multiaddr](https://github.com/multiformats/js-multiaddr)
3131

32-
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful.
32+
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful.
3333

3434
If no `callback` is passed, a promise is returned.
3535

@@ -51,7 +51,7 @@ ipfs.swarm.connect(addr, function (err) {
5151

5252
Where `addr` is of type [multiaddr](https://github.com/multiformats/js-multiaddr)
5353

54-
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.
54+
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.
5555

5656
If no `callback` is passed, a promise is returned.
5757

@@ -111,7 +111,7 @@ ipfs.swarm.filters(function (err, filters) {})
111111

112112
Where `filter` is of type [multiaddr]()
113113

114-
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.
114+
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.
115115

116116
If no `callback` is passed, a promise is returned.
117117

@@ -140,5 +140,3 @@ Example:
140140
```JavaScript
141141
ipfs.swarm.filters.rm(filter, function (err) {})
142142
```
143-
144-

src/swarm.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports = (common) => {
4646
it('.connect', (done) => {
4747
ipfsB.id((err, id) => {
4848
expect(err).to.not.exist
49+
4950
const ipfsBAddr = id.addresses[0]
5051
ipfsA.swarm.connect(ipfsBAddr, done)
5152
})
@@ -62,7 +63,9 @@ module.exports = (common) => {
6263
it('.addrs', (done) => {
6364
ipfsA.swarm.addrs((err, multiaddrs) => {
6465
expect(err).to.not.exist
65-
expect(multiaddrs).to.have.length.above(0)
66+
expect(multiaddrs).to.not.be.empty
67+
expect(multiaddrs).to.be.an('array')
68+
expect(multiaddrs[0].constructor.name).to.be.eql('Peer')
6669
done()
6770
})
6871
})

0 commit comments

Comments
 (0)