Compliance tests for implementations of the libp2p Connection interface
$ npm i @libp2p/interface-connection-compliance-tests
This is a test suite and interface you can use to implement a connection. The connection interface contains all the metadata associated with it, as well as an array of the streams opened through this connection. In the same way as the connection, a stream contains properties with its metadata, plus an iterable duplex object that offers a mechanism for writing and reading data, with back pressure. This module and test suite were heavily inspired by abstract-blob-store and interface-stream-muxer.
The primary goal of this module is to enable developers to pick, swap or upgrade their connection without losing the same API expectations and mechanisms such as back pressure and the ability to half close a connection.
Publishing a test suite as a module lets multiple modules ensure compatibility since they use the same test suite.
import tests from '@libp2p/interface-connection-compliance-tests'
describe('your connection', () => {
tests({
// Options should be passed to your connection
async setup (options) {
return YourConnection
},
async teardown () {
// cleanup resources created by setup()
}
})
})
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.