in-memory-composer

0.1.1 • Public • Published

In-memory Hyperledger Composer

For testing, you might want to quickly create an in-memory instance of your Business Network in Hyperledger Composer. This NodeJS module enables you to do just that.

Installation

Using NPM:

npm install --save-dev in-memory-composer

or, if you're using Yarn:

yarn add --dev in-memory-composer

Usage

Importing the module:

const { InMemoryComposer } = require('in-memory-composer')

Create new instance of in-memory composer, and connect to it:

const composer = new InMemoryComposer()
const composerConnection = await composer.connect()

Start a business network from a local path. When writing tests for a business network, you typically want to load the business network from a parent directory of the tests:

const path = require('path')
const networkPath = path.resolve(__dirname, '..')
const network = await composerConnection.startBusinessNetwork({ networkPath })

Login as the network admin:

const businessNetworkConnection = await network.connectAdmin()

Login as someone else:

const johnsCard = await network.createCard{ name: 'John Doe' }
const johnsConnection = await network.connect({ card: johnsCard })

Retrieve the Factory associated with the business network:

const factory = network.getFactory()

/in-memory-composer/

    Package Sidebar

    Install

    npm i in-memory-composer

    Weekly Downloads

    1

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    7.64 kB

    Total Files

    12

    Last publish

    Collaborators

    • markspanbroek