- 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.
推薦閱讀
- Learning Java Functional Programming
- Pandas Cookbook
- INSTANT Yii 1.1 Application Development Starter
- Learning Docker Networking
- Zabbix Performance Tuning
- Clojure for Java Developers
- Mastering Adobe Captivate 7
- Emotional Intelligence for IT Professionals
- Appcelerator Titanium:Patterns and Best Practices
- 超好玩的Scratch 3.5少兒編程
- Python機器學習開發實戰
- ArcPy and ArcGIS(Second Edition)
- CISSP in 21 Days(Second Edition)
- ServiceDesk Plus 8.x Essentials
- Learning Java Lambdas