import * as chai from 'chai' ; import * as sinon from 'sinon' ; import * as sinonChai from 'sinon-chai' ; import * as chaiAsPromised from 'chai-as-promised' ; import { FabricSmartContractDefinition , FabricIdentity } from '../..' ; import { FabricCollectionDefinition } from '../../src/fabricModel/FabricCollectionDefinition' ; chai . should ( ) ; chai . use ( sinonChai ) ; chai . use ( chaiAsPromised ) ; describe ( 'fabricModel' , ( ) => { let sandbox ; beforeEach ( async ( ) => { sandbox = sinon . createSandbox ( ) ; } ) ; afterEach ( async ( ) => { sandbox . restore ( ) ; } ) ; it ( 'should create a fabric chaincode' , ( ) => { const collectionConfig = new FabricCollectionDefinition ( 'myCollection' , `OR('Org1MSP)` , 4 , 2 ) ; const myChaincode = new FabricSmartContractDefinition ( 'myChaincode' , '0.0.1' , 1 , 'myPackageId' , Buffer . from ( 'myPolicy' ) , [ collectionConfig ] ) ; myChaincode . name . should . equal ( 'myChaincode' ) ; myChaincode . version . should . equal ( '0.0.1' ) ; myChaincode . sequence . should . equal ( 1 ) ; myChaincode . endorsementPolicy . should . deep . equal ( Buffer . from ( 'myPolicy' ) ) ; myChaincode . collectionConfig . should . deep . equal ( [ collectionConfig ] ) ; } ) ; it ( 'should create a fabric identity' , ( ) => { const myIdentity = new FabricIdentity ( 'myIdentity' , 'myCert' , 'myKey' , 'mymspid' ) ; myIdentity . name . should . equal ( 'myIdentity' ) ; myIdentity . cert . should . equal ( 'myCert' ) ; myIdentity . private_key . should . equal ( 'myKey' ) ; myIdentity . msp_id . should . equal ( 'mymspid' ) ; } ) ; } ) ;