Reputation: 55
I am trying to use the Hyperledger Caliper framework to measure the performance of a blockchain network based on Hyperledger Fabric, containing 3 nodes and 1 orderer and solo consensus. I already have the network installed and functional with smart contracts responding correctly on different remote virtual machines. I know I have to create a network configuration file and one for testing configuration. At this point my doubts begin. In all the examples I saw, in this configuration file, javascripts files for testing are related, but my smart contract was written in golang. Must my tests be written using javascript? Can I reference a golang file in this file? Would anyone have an example to provide me? I've been researching for weeks but I can't understand the examples provided by the framework. Could anyone give me any help, even if it is a link that I haven't seen yet to search further.
Upvotes: 0
Views: 857
Reputation: 5868
All caliper workloads currently execute in node.js which is predominantly a javascript engine (Chaincode can be written in any fabric supported language). Support for other languages may come in the future either natively or maybe through alternative just a transpiling to javascript or compiling to wasm as the node.js engine increases it's wasm capabilities.
I would recommend looking at the latest tutorial for fabric which can be found here https://hyperledger.github.io/caliper/v0.4.2/fabric-tutorial/ As there are some big improvements to caliper (over the v0.3.2 version)
Upvotes: 0
Reputation: 2586
The key to caliper's javascript is to call the peer. In other words, it is not executed by directly connecting a specific smart contract (golang).
Caliper(javascript) <-> Peer <-> Chaincode(golang)
caliper requests the peer's chaincode (javascript) to peer, and the peer receives the request, executes chaincode (golang), and returns the result.
That mean, it is completely independent of the chaincode language.
See the link below. In the case of the code that calls the chaincode in the actual caliper's JavaScript, only the chaincode name, function, and input parameters are required.
hyperledger-caliper-fabric-tutorial
(ex)
...
const contractID = fabcar;
const chaincodeFunction = 'createCar';
const invokerIdentity = 'Admin@org1.example.com';
const chaincodeArguments = [assetID,'blue','ford','focus','jim'];
const result = await bc.bcObj.invokeSmartContract(ctx, contractID, version, myArgs);
console.log(result);
Upvotes: 0