官术网_书友最值得收藏!

Testing the createNewBlock method

Now lets test the createNewBlock method that we created in the preceding section:

  1. The first thing that we need to do is export our Blockchain constructor function because we are going to use this function in our test.js file. So, to export the constructor function, we will go to the bottom of the blockchain.js file, type the following line of code, and then save the file: 
module.exports = Blockchain;
  1. Next, go to the dev/test.js file, as this is where we will be testing our createNewBlock method. Now, the first thing that we want to do in our dev/test.js file is import our Blockchain constructor function, so type the following: 
const Blockchain = require('./blockchain');

This preceding line of code simply requires or calls the blockchain.js file.

主站蜘蛛池模板: 江西省| 通州市| 海安县| 沅江市| 佛冈县| 临泉县| 兴化市| 焉耆| 宁都县| 扬州市| 洪洞县| 和硕县| 东阿县| 吕梁市| 张家界市| 常熟市| 中江县| 凤台县| 中江县| 临城县| 上饶市| 达孜县| 崇文区| 奉新县| 郓城县| 周至县| 五台县| 德格县| 榆社县| 南丹县| 榆社县| 沭阳县| 金山区| 南昌市| 朔州市| 额尔古纳市| 阳信县| 抚松县| 丹阳市| 达尔| 宁城县|