调试交易代码 [英] Debugging Transaction Code

查看:40
本文介绍了调试交易代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在问自己,是否有一种简便的方法来调试事务的JavaScript代码. JS已经具有成熟的调试器,这只是如何轻松将其绑定到容器中运行的代码的问题.有人有线索吗? -谢谢.

I've been asking myself whether there is an easy way of debugging the JavaScript code of the transactions. JS already has mature debuggers, it is only a question of how to easily bind it to the code running in the container. Does anyone have a clue? -- Thx.

推荐答案

调试事务代码的最简单方法之一是将业务网络部署到嵌入式结构中,这基本上意味着您的代码可以像其他NodeJS应用程序一样运行是,您可以使用节点调试器单步执行您的代码,如果需要的话甚至可以使用简单的console.log语句.

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.

要深入了解如何实现此目标,请在此处查看代码:更新的链接 https: //github.com/hyperledger/composer-sample-networks/blob/master/packages/carauction-network/test/CarAuction.js#L31-L49

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

这是示例网络的单元测试的beforeEach方法,您将看到,它将网络部署到嵌入式"结构.

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.

然后,代码继续执行测试,包括在嵌入式businessNetworkConnection上调用submitTransaction API,然后使嵌入式结构评估事务"脚本代码.

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.

这一切都发生在单个Node应用程序中,并且更容易调试.

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

HTH

这篇关于调试交易代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆