After using SetEvent() in the chaincode, how is possible to test it?
Does exist some working example?
You could create an application which is listening on the chaincode event.
I suggest you to have a look at the "Chaincode event listener" section of this link, which is the official Hyperledger Fabric Nodejs SDK.
https://fabric-sdk-node.github.io/tutorial-channel-events.html
First is necessary to configure the client correctly. Once it has been configured:
//... client configuration
var channel = fabric_client.getChannel();
var eventHub = channel.getChannelEventHubsForOrg(<NAME OF YOUR ORG>)[0];
eventHub.connect(true);
eventHub.registerChaincodeEvent(CHAINCODE_ID,EVENT_NAME,
(event, block_num, txnid, status)=>{
console.log('Successfully got a chaincode event with transid:'+ txnid + ' with status:'+status);
console.log('Successfully received the chaincode event on block number '+ block_num);
console.log(event);
},
(error)=>{
console.log('Failed to receive the chaincode event ::'+error);
}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With