This repository has been archived by the owner on Mar 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
129 additions
and
4 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
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,2 +1,62 @@ | ||
# interface-content-routing | ||
A test suite and interface you can use to implement a Content Routing for libp2p. | ||
interface-content-routing | ||
===================== | ||
|
||
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) | ||
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) | ||
|
||
> A test suite and interface you can use to implement a Content Routing module for libp2p. | ||
The primary goal of this module is to enable developers to pick and swap their Content Routing module as they see fit for their libp2p installation, without having to go through shims or compatibility issues. This module and test suite were heavily inspired by abstract-blob-store and interface-stream-muxer. | ||
|
||
Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite. | ||
|
||
The API is presented with both Node.js and Go primitives, however, there is not actual limitations for it to be extended for any other language, pushing forward the cross compatibility and interop through diferent stacks. | ||
|
||
# Modules that implement the interface | ||
|
||
- [JavaScript libp2p-kad-dht](https://github.com/libp2p/js-libp2p-kad-dht) | ||
- [JavaScript libp2p-delegated-peer-routing](https://github.com/libp2p/js-libp2p-delegated-peer-routing) | ||
- [JavaScript libp2p-kad-routing](https://github.com/libp2p/js-libp2p-kad-routing) | ||
|
||
# Badge | ||
|
||
Include this badge in your readme if you make a module that is compatible with the interface-content-routing API. You can validate this by running the tests. | ||
|
||
![](https://raw.githubusercontent.com/libp2p/interface-content-routing/master/img/badge.png) | ||
|
||
# How to use the battery of tests | ||
|
||
## Node.js | ||
|
||
```javascript | ||
var tape = require('tape') | ||
var tests = require('interface-content-routing/tests') | ||
var yourImpl = require('../src') | ||
|
||
var common = { | ||
setup: function (t, cb) { | ||
cb(null, yourImpl) | ||
}, | ||
teardown: function (t, cb) { | ||
cb() | ||
} | ||
} | ||
|
||
tests(tape, common) | ||
``` | ||
|
||
## Go | ||
|
||
> WIP - The go-libp2p implementation does not have a test suite to be used, yet. | ||
# API | ||
|
||
A valid (read: that follows this abstraction) Peer Routing module must implement the following API. | ||
|
||
### `.findProviders` | ||
|
||
- `JavaScript` peerRouting.findProviders | ||
|
||
### `.provide` | ||
|
||
- `JavaScript` peerRouting.provide |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,22 @@ | ||
{ | ||
"name": "interface-content-routing", | ||
"version": "0.0.0", | ||
"description": "A test suite and interface you can use to implement a Content Routing for libp2p.", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/libp2p/interface-content-routing.git" | ||
}, | ||
"keywords": [ | ||
"IPFS" | ||
], | ||
"author": "David Dias <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/libp2p/interface-content-routing/issues" | ||
}, | ||
"homepage": "https://github.com/libp2p/interface-content-routing", | ||
"devDependencies": {}, | ||
"dependencies": { | ||
"timed-tape": "^0.1.1" | ||
} | ||
} |
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,10 @@ | ||
'use strict' | ||
|
||
module.exports.all = function (test, common) { | ||
test('test', function (t) { | ||
common.setup(test, function (err, pr) { | ||
if (err) {} | ||
common.teardown() | ||
}) | ||
}) | ||
} |
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,7 @@ | ||
'use strict' | ||
const timed = require('timed-tape') | ||
|
||
module.exports = function (test, common) { | ||
test = timed(test) | ||
require('./base-test.js').all(test, common) | ||
} |