Debugging Transaction Code

醉酒当歌 提交于 2019-12-06 11:42:31
SamS

One of the easiest ways to debug your transaction code is to deploy your business network into an embedded fabric which basically means that your code is run as any other NodeJS app is and you can use the node debugger to step through your code or even simple console.log statements if that suffices.

To get an insight into how to achieve this, have a look at the code here: UPDATED LINK https://github.com/hyperledger/composer-sample-networks/blob/master/packages/carauction-network/test/CarAuction.js#L31-L49

This is the beforeEach method of a unit test for the sample network and as you'll see, it deploys the network to the 'embedded' fabric.

The code then goes on to perform tests that include calling the submitTransaction API on the embedded businessNetworkConnection which then causes the Transaction script code to be eval'ed by the embedded fabric.

So it's all happening within a single Node app and is much easier to debug.

HTH

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!