forked from pranikamassey/FabricCare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-bn-util.js
44 lines (38 loc) · 1.03 KB
/
test-bn-util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
/**
* Part of a course on Hyperledger Fabric:
* http://ACloudFan.com
*
* Composer 0.19.0
*
* This is for testing the bn-connection-util.js
*
* Shows how to use the bn-connection-util in your
*/
const bnUtil = require('./bn-connection-util');
// This creates the business network connection object
// and calls connect() on it. Calls the callback method
// 'main' with error
bnUtil.connect(main);
// Callback function passed to the BN Connection utility
// Error has value if there was an error in connect()
function main(error){
// 1. Check for the connection error
if(error){
console.log(error);
process.exit(1);
}
console.log("1. Successfully Connected !!!");
// 2. Lets ping
bnUtil.ping((response, error)=>{
if(error){
console.log(error);
} else {
console.log("2. Received Ping Response:");
console.log(response);
}
// 3. Disconnect
bnUtil.disconnect();
console.log("3. Disconnected");
});
}