carauction-network
Advanced tools
Comparing version 0.1.12-20171123162500 to 0.1.13-20171124120624
{ | ||
"engines": { | ||
"composer": "^0.15.0" | ||
"composer": "^0.15.2" | ||
}, | ||
"name": "carauction-network", | ||
"version": "0.1.12-20171123162500", | ||
"version": "0.1.13-20171124120624", | ||
"description": "Car Auction Business Network", | ||
@@ -34,8 +34,8 @@ "networkImage": "https://hyperledger.github.io/composer-sample-networks/packages/carauction-network/networkimage.svg", | ||
"devDependencies": { | ||
"browserfs": "^1.2.0", | ||
"chai": "^3.5.0", | ||
"composer-admin": "^0.14.0-0", | ||
"composer-cli": "^0.14.0-0", | ||
"composer-client": "^0.14.0-0", | ||
"composer-connector-embedded": "^0.14.0-0", | ||
"composer-admin": "^0.15.2", | ||
"composer-cli": "^0.15.2", | ||
"composer-client": "^0.15.2", | ||
"composer-common": "^0.15.2", | ||
"composer-connector-embedded": "^0.15.2", | ||
"eslint": "^3.6.1", | ||
@@ -42,0 +42,0 @@ "istanbul": "^0.4.5", |
@@ -18,5 +18,6 @@ /* | ||
const AdminConnection = require('composer-admin').AdminConnection; | ||
const BrowserFS = require('browserfs/dist/node/index'); | ||
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection; | ||
const BusinessNetworkDefinition = require('composer-common').BusinessNetworkDefinition; | ||
const IdCard = require('composer-common').IdCard; | ||
const MemoryCardStore = require('composer-common').MemoryCardStore; | ||
const path = require('path'); | ||
@@ -26,31 +27,71 @@ | ||
const bfs_fs = BrowserFS.BFSRequire('fs'); | ||
const NS = 'org.acme.vehicle.auction'; | ||
describe('CarAuction', () => { | ||
// let adminConnection; | ||
// In-memory card store for testing so cards are not persisted to the file system | ||
const cardStore = new MemoryCardStore(); | ||
let adminConnection; | ||
let businessNetworkConnection; | ||
beforeEach(() => { | ||
BrowserFS.initialize(new BrowserFS.FileSystem.InMemory()); | ||
const adminConnection = new AdminConnection({ fs: bfs_fs }); | ||
return adminConnection.createProfile('defaultProfile', { | ||
before(() => { | ||
// Embedded connection used for local testing | ||
const connectionProfile = { | ||
name: 'embedded', | ||
type: 'embedded' | ||
}) | ||
.then(() => { | ||
return adminConnection.connect('defaultProfile', 'admin', 'Xurw3yU9zI0l'); | ||
}) | ||
.then(() => { | ||
return BusinessNetworkDefinition.fromDirectory(path.resolve(__dirname, '..')); | ||
}) | ||
.then((businessNetworkDefinition) => { | ||
return adminConnection.deploy(businessNetworkDefinition); | ||
}) | ||
.then(() => { | ||
businessNetworkConnection = new BusinessNetworkConnection({ fs: bfs_fs }); | ||
return businessNetworkConnection.connect('defaultProfile', 'carauction-network', 'admin', 'Xurw3yU9zI0l'); | ||
}); | ||
}; | ||
// Embedded connection does not need real credentials | ||
const credentials = { | ||
certificate: 'FAKE CERTIFICATE', | ||
privateKey: 'FAKE PRIVATE KEY' | ||
}; | ||
// PeerAdmin identity used with the admin connection to deploy business networks | ||
const deployerMetadata = { | ||
version: 1, | ||
userName: 'PeerAdmin', | ||
roles: [ 'PeerAdmin', 'ChannelAdmin' ] | ||
}; | ||
const deployerCard = new IdCard(deployerMetadata, connectionProfile); | ||
deployerCard.setCredentials(credentials); | ||
const deployerCardName = 'PeerAdmin'; | ||
adminConnection = new AdminConnection({ cardStore: cardStore }); | ||
return adminConnection.importCard(deployerCardName, deployerCard).then(() => { | ||
return adminConnection.connect(deployerCardName); | ||
}); | ||
}); | ||
beforeEach(() => { | ||
businessNetworkConnection = new BusinessNetworkConnection({ cardStore: cardStore }); | ||
const adminUserName = 'admin'; | ||
let adminCardName; | ||
let businessNetworkDefinition; | ||
return BusinessNetworkDefinition.fromDirectory(path.resolve(__dirname, '..')).then(definition => { | ||
businessNetworkDefinition = definition; | ||
// Install the Composer runtime for the new business network | ||
return adminConnection.install(businessNetworkDefinition.getName()); | ||
}).then(() => { | ||
// Start the business network and configure an network admin identity | ||
const startOptions = { | ||
networkAdmins: [ | ||
{ | ||
userName: adminUserName, | ||
enrollmentSecret: 'adminpw' | ||
} | ||
] | ||
}; | ||
return adminConnection.start(businessNetworkDefinition, startOptions); | ||
}).then(adminCards => { | ||
// Import the network admin identity for us to use | ||
adminCardName = `${adminUserName}@${businessNetworkDefinition.getName()}`; | ||
return adminConnection.importCard(adminCardName, adminCards.get(adminUserName)); | ||
}).then(() => { | ||
// Connect to the business network using the network admin identity | ||
return businessNetworkConnection.connect(adminCardName); | ||
}); | ||
}); | ||
describe('#makeOffer', () => { | ||
@@ -57,0 +98,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66507
436