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

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.

主站蜘蛛池模板: 天气| 翼城县| 年辖:市辖区| 大厂| 延寿县| 沙田区| 喀喇| 金阳县| 石狮市| 关岭| 奉化市| 芜湖县| 弋阳县| 南和县| 当涂县| 麻栗坡县| 宁城县| 大埔县| 房山区| 禄劝| 榆社县| 崇文区| 清徐县| 壤塘县| 东莞市| 朔州市| 化州市| 洞口县| 北海市| 平陆县| 鄱阳县| 富裕县| 饶平县| 长岭县| 神池县| 海宁市| 崇仁县| 洞头县| 大宁县| 当涂县| 江源县|