mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-25 06:02:21 +00:00
readme till API
This commit is contained in:
parent
549395cd56
commit
c255edbca3
58
README.md
58
README.md
@ -1,2 +1,56 @@
|
||||
# abstract-socket
|
||||
A test suite and interface you can use to implement a socket.
|
||||
abstract-connection
|
||||
===================
|
||||
|
||||
[](http://ipn.io) [](http://webchat.freenode.net/?channels=%23ipfs)
|
||||
|
||||
> A test suite and interface you can use to implement a connection. A connection is understood as something that offers a dial+listen interface
|
||||
|
||||
The primary goal of this module is to enable developers to pick and swap their Record Store 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 abstract-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
|
||||
|
||||
- [node-libp2p-tcp](https://github.com/diasdavid/node-libp2p-tcp)
|
||||
|
||||
# Badge
|
||||
|
||||
Include this badge in your readme if you make a module that is compatible with the abstract-connection API. You can validate this by running the tests.
|
||||
|
||||

|
||||
|
||||
# How to use the battery of tests
|
||||
|
||||
## Node.js
|
||||
|
||||
```
|
||||
var tape = require('tape')
|
||||
var tests = require('abstract-connection/tests')
|
||||
var YourConnectionHandler = require('../src')
|
||||
|
||||
var common = {
|
||||
setup: function (t, cb) {
|
||||
cb(null, YourConnectionHandler)
|
||||
},
|
||||
teardown: function (t, cb) {
|
||||
cb()
|
||||
}
|
||||
}
|
||||
|
||||
tests(tape, common)
|
||||
```
|
||||
|
||||
## Go
|
||||
|
||||
> WIP
|
||||
|
||||
# API
|
||||
|
||||
A valid (read: that follows this abstraction) connection, must implement the following API.
|
||||
|
||||
note: a `stream` should be a stream that implements the [abstract-stream](https://github.com/diasdavid/abstract-stream) interface.
|
||||
|
||||
|
||||
|
25
package.json
Normal file
25
package.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "abstract-connection",
|
||||
"version": "0.0.0",
|
||||
"description": "A test suite and interface you can use to implement a connection.",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/diasdavid/abstract-connection.git"
|
||||
},
|
||||
"keywords": [
|
||||
"IPFS"
|
||||
],
|
||||
"author": "David Dias <daviddias@ipfs.io>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/diasdavid/abstract-connection/issues"
|
||||
},
|
||||
"homepage": "https://github.com/diasdavid/abstract-connection"
|
||||
}
|
9
tests/base-test.js
Normal file
9
tests/base-test.js
Normal file
@ -0,0 +1,9 @@
|
||||
module.exports.all = function (test, common) {
|
||||
test('a test', function (t) {
|
||||
common.setup(test, function (err, Connection) {
|
||||
t.ifError(err)
|
||||
t.pass('woot!')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
}
|
6
tests/index.js
Normal file
6
tests/index.js
Normal file
@ -0,0 +1,6 @@
|
||||
var timed = require('timed-tape')
|
||||
|
||||
module.exports = function (test, common) {
|
||||
test = timed(test)
|
||||
require('./base-test.js').all(test, common)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user