From e1b7badc2d41defde1ead8d7497d6ca32a1ebfe4 Mon Sep 17 00:00:00 2001 From: David Dias Date: Wed, 16 Sep 2015 17:32:10 +0100 Subject: [PATCH] landing --- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 18 +++++++++++++ tests/base-test.js | 8 ++++++ tests/index.js | 6 +++++ 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 package.json create mode 100644 tests/base-test.js create mode 100644 tests/index.js diff --git a/README.md b/README.md index c2b5110..3140d22 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,61 @@ -# abstract-transport -A test suite and interface you can use to implement a transport interface. +abstract-transport +================== + +[![](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 transport. A transport is understood as something that offers mechanism for writing and reading data, back pressure, half and full duplex streams. This module and test suite were heavily inspired by abstract-blob-store and abstract-stream-muxer. + +The primary goal of module is to enable developers to pick, swap or upgrade their transport without loosing the same API expectations and mechanisms such as back pressure and the hability to half close a stream. + +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. + +> **IMPORTANT** - Tests are still not finished nor the interface + + +# 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. + +![](https://raw.githubusercontent.com/diasdavid/abstract-transport/master/img/badge.png) + +# How to use the battery of tests + +## Node.js + +``` +var tape = require('tape') +var tests = require('abstract-transport/tests') +var YourTransportHandler = require('../src') + +var common = { + setup: function (t, cb) { + cb(null, YourTransportHandler) + }, + teardown: function (t, cb) { + cb() + } +} + +tests(tape, common) +``` + +## Go + +> WIP + +# API + +A valid (read: that follows this abstraction) connection, must implement the following API. + +notes: + - should have backpressure into account + - should enable half duplex streams (close from one side, but still open for the other) + - should support full duplex + - tests should be performed by passing two streams + diff --git a/package.json b/package.json new file mode 100644 index 0000000..2705582 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "abstract-transport", + "version": "0.0.0", + "description": "A test suite and interface you can use to implement a transport interface.", + "repository": { + "type": "git", + "url": "https://github.com/diasdavid/abstract-transport.git" + }, + "keywords": [ + "IPFS" + ], + "author": "David Dias ", + "license": "MIT", + "bugs": { + "url": "https://github.com/diasdavid/abstract-transport/issues" + }, + "homepage": "https://github.com/diasdavid/abstract-transport" +} diff --git a/tests/base-test.js b/tests/base-test.js new file mode 100644 index 0000000..4d42a06 --- /dev/null +++ b/tests/base-test.js @@ -0,0 +1,8 @@ +module.exports.all = function (test, common) { + test('a test', function (t) { + common.setup(test, function (err, conn) { + t.ifError(err) + t.end() + }) + }) +} diff --git a/tests/index.js b/tests/index.js new file mode 100644 index 0000000..b232406 --- /dev/null +++ b/tests/index.js @@ -0,0 +1,6 @@ +var timed = require('timed-tape') + +module.exports = function (test, common) { + test = timed(test) + require('./base-test.js').all(test, common) +}