This repository has been archived by the owner on Sep 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release-0.9.0: upgrade to js-ipfs 0.43.0 and go-ipfs 0.5.0, swarm api
- Loading branch information
Showing
18 changed files
with
7,266 additions
and
31,153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
version: 2.1 | ||
orbs: | ||
node: circleci/[email protected] | ||
jobs: | ||
build-and-test: | ||
test: | ||
executor: | ||
name: node/default | ||
tag: 'lts' | ||
steps: | ||
- checkout | ||
- node/with-cache: | ||
steps: | ||
- run: npm install | ||
- run: npm test | ||
- node/install-packages | ||
- run: | ||
command: npm run test | ||
orbs: | ||
node: 'circleci/[email protected]' | ||
version: 2.1 | ||
workflows: | ||
build-and-test: | ||
jobs: | ||
- build-and-test | ||
test_my_app: | ||
jobs: | ||
- test |
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 +1,2 @@ | ||
node_modules | ||
.nyc_output |
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,5 +1,75 @@ | ||
# OrbitDB Test Utils | ||
# OrbitDB Test Utils _(orbit-db-test-utils)_ | ||
> Shared test utilities for OrbitDB-related projects | ||
[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/orbitdb/Lobby) [![Matrix](https://img.shields.io/badge/matrix-%23orbitdb%3Apermaweb.io-blue.svg)](https://riot.permaweb.io/#/room/#orbitdb:permaweb.io) [![Discord](https://img.shields.io/discord/475789330380488707?color=blueviolet&label=discord)](https://discord.gg/cscuf5T) | ||
|
||
- Readme TBD | ||
This repository contains utilities to spin up IPFS nodes and swarms, as well | ||
as different `abstract-leveldown` implementations to use with `orbit-db-keystore` | ||
and `orbit-db-cache`. | ||
|
||
For examples on how this would be used, see the `test` folder in this repo, or | ||
read on! | ||
|
||
## Install | ||
|
||
```bash | ||
$ npm install orbit-db-test-utils -D | ||
``` | ||
|
||
## Usage | ||
|
||
### Spawn a single IPFS instance | ||
|
||
```JavaScript | ||
const { | ||
connectPeers, | ||
startIpfs, | ||
stopIpfs, | ||
testApis, | ||
getIpfsPeerId, | ||
waitForPeers | ||
} = require('../') | ||
|
||
;(async () => { | ||
// Create JS and Go nodes | ||
ipfsd1 = await startIpfs('js-ipfs') | ||
ipfsd2 = await startIpfs('go-ipfs') | ||
|
||
// Get the peer IDs | ||
const id1 = await getIpfsPeerId(ipfsd1.api) | ||
const id2 = await getIpfsPeerId(ipfsd2.api) | ||
|
||
// Helper function to connect the nodes | ||
await connectPeers(ipfsd1.api, ipfsd2.api) | ||
|
||
// Test that the nodes are pubsubbing with each other | ||
const topic = 'test-topic' | ||
await ipfsd1.api.pubsub.subscribe(topic, () => {}) | ||
await ipfsd2.api.pubsub.subscribe(topic, () => {}) | ||
await waitForPeers(ipfsd1.api, [id2], topic) | ||
})() | ||
``` | ||
|
||
### Spawn a swarm of connected IPFS instances | ||
|
||
```JavaScript | ||
const { swarm } = require('orbit-db-test-utils') | ||
|
||
// Enter an array of the node types you want, either 'js' or 'go' | ||
const nodeTypes = ['js', 'go', 'js'] | ||
|
||
swarm(nodeTypes).then(nodes => /* ... do stuff ... */) | ||
``` | ||
|
||
|
||
**Note:** The previously used `startIpfs` and `stopIpfs` functionality is **deprecated** | ||
and should be avoided and refactored away. | ||
|
||
## Contributing | ||
|
||
Issues and PRs are welcome. | ||
|
||
## License | ||
|
||
[MIT](./LICENSE.md) © OrbitDB Community | ||
>>>>>>> cf5458c... refactor: update deps and utilize new ipfsd-ctl |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
defaults: { | ||
type: 'proc', | ||
test: true, | ||
disposable: true, | ||
ipfsModule: require('ipfs'), | ||
init: false, | ||
start: false, | ||
ipfsOptions: { | ||
config: { | ||
Addresses: { | ||
API: '/ip4/127.0.0.1/tcp/0', | ||
Swarm: ['/ip4/0.0.0.0/tcp/0'], | ||
Gateway: '/ip4/0.0.0.0/tcp/0' | ||
}, | ||
Bootstrap: [] | ||
} | ||
} | ||
}, | ||
overrides: { | ||
go: { | ||
test: false, | ||
ipfsHttpModule: require('ipfs-http-client'), | ||
ipfsBin: require('go-ipfs-dep').path() | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
exports.config = require('./config') | ||
exports.testAPIs = require('./test-apis') | ||
exports.startIpfs = require('./start-ipfs') | ||
exports.stopIpfs = require('./stop-ipfs') | ||
exports.waitForPeers = require('./wait-for-peers') | ||
exports.connectPeers = require('./connect-peers') | ||
exports.getIpfsPeerId = require('./get-ipfs-peer-id') | ||
exports.MemStore = require('./mem-store') | ||
exports.swarm = require('./swarm') | ||
|
||
// Different abstract-leveldown implementations | ||
const implementations = require('./implementations') | ||
|
||
const properLevelModule = implementations.filter(i => i.key.indexOf('level') > -1).map(i => i.module)[0] | ||
const properLevelModule = implementations | ||
.filter(i => i.key.indexOf('level') > -1) | ||
.map(i => i.module)[0] | ||
const defaultStorage = require('orbit-db-storage-adapter')(properLevelModule) | ||
|
||
exports.implementations = implementations | ||
exports.defaultStorage = defaultStorage | ||
exports.implementations = implementations | ||
|
||
// Deprecated APIs | ||
// startIpfs and stopIpfs will throw console.warn-ings | ||
exports.config = require('./config') | ||
exports.connectPeers = require('./connect-peers') | ||
exports.getIpfsPeerId = require('./get-ipfs-peer-id') | ||
exports.startIpfs = require('./start-ipfs') | ||
exports.stopIpfs = require('./stop-ipfs') | ||
exports.testApis = require('./test-apis.js') | ||
exports.waitForPeers = require('./wait-for-peers') |
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
Oops, something went wrong.