Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Charterhouse/in-memory-composer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

Quickly create an in-memory Hyperledger Composer instance for testing

Resources

License

Stars

Watchers

Forks

Packages

No packages published