- 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.
推薦閱讀
- Docker進(jìn)階與實(shí)戰(zhàn)
- HTML5+CSS3基礎(chǔ)開(kāi)發(fā)教程(第2版)
- Java Web基礎(chǔ)與實(shí)例教程
- RISC-V體系結(jié)構(gòu)編程與實(shí)踐(第2版)
- Windows Embedded CE 6.0程序設(shè)計(jì)實(shí)戰(zhàn)
- Python語(yǔ)言科研繪圖與學(xué)術(shù)圖表繪制從入門到精通
- PyQt編程快速上手
- Moodle 3 Administration(Third Edition)
- 寫給大家看的Midjourney設(shè)計(jì)書(shū)
- 物聯(lián)網(wǎng)系統(tǒng)架構(gòu)設(shè)計(jì)與邊緣計(jì)算(原書(shū)第2版)
- C語(yǔ)言程序設(shè)計(jì)實(shí)踐
- 程序員的成長(zhǎng)課
- 零基礎(chǔ)學(xué)Java第2版
- Python編程入門(第3版)
- 編寫高質(zhì)量代碼之Java(套裝共2冊(cè))