- Learn Blockchain Programming with JavaScript
- Eric Traub
- 133字
- 2021-06-10 18:40:36
Testing the createNewBlock method
Now lets test the createNewBlock method that we created in the preceding section:
- 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;
- 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.
推薦閱讀
- 復(fù)雜軟件設(shè)計(jì)之道:領(lǐng)域驅(qū)動(dòng)設(shè)計(jì)全面解析與實(shí)戰(zhàn)
- Arduino開(kāi)發(fā)實(shí)戰(zhàn)指南:LabVIEW卷
- Three.js開(kāi)發(fā)指南:基于WebGL和HTML5在網(wǎng)頁(yè)上渲染3D圖形和動(dòng)畫(huà)(原書(shū)第3版)
- SQL語(yǔ)言從入門(mén)到精通
- Julia機(jī)器學(xué)習(xí)核心編程:人人可用的高性能科學(xué)計(jì)算
- R語(yǔ)言編程指南
- Python編程與幾何圖形
- Drupal 8 Module Development
- Spring快速入門(mén)
- Python極簡(jiǎn)講義:一本書(shū)入門(mén)數(shù)據(jù)分析與機(jī)器學(xué)習(xí)
- 時(shí)空數(shù)據(jù)建模及其應(yīng)用
- MySQL程序員面試筆試寶典
- WCF技術(shù)剖析(卷1)
- Raspberry Pi開(kāi)發(fā)實(shí)戰(zhàn)
- 計(jì)算機(jī)視覺(jué)實(shí)戰(zhàn):基于TensorFlow 2