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

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.

主站蜘蛛池模板: 藁城市| 北辰区| 阿拉善右旗| 油尖旺区| 都江堰市| 桐庐县| 元谋县| 克山县| 门源| 马鞍山市| 江西省| 西畴县| 平乡县| 泸西县| 隆子县| 高清| 石台县| 襄城县| 东源县| 姚安县| 柘荣县| 洪泽县| 饶河县| 凤翔县| 德安县| 靖远县| 石泉县| 金川县| 富裕县| 安阳市| 沁源县| 金川县| 页游| 呼和浩特市| 曲松县| 丹巴县| 荆州市| 保定市| 黑山县| 楚雄市| 丹寨县|