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

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.

主站蜘蛛池模板: 张家港市| 通城县| 屯门区| 若尔盖县| 屏东县| 当雄县| 棋牌| 河间市| 玛多县| 双柏县| 丹棱县| 保山市| 南岸区| 溆浦县| 新密市| 沂源县| 安新县| 镇原县| 田东县| 任丘市| 绥芬河市| 桓仁| 铅山县| 紫云| 泰兴市| 红原县| 张北县| 福州市| 晋中市| 孝昌县| 沿河| 平定县| 高密市| 康定县| 榕江县| 耒阳市| 望谟县| 米林县| 定襄县| 靖江市| 巴林左旗|