Testing the chainIsValid method

Now let's test the chainIsValid method by implementing the following steps: 

  1. In the test.js file, let's import the blockchain data structure and create a new instance of the blockchain, called bitcoin:  
const Blockchain = require('./blockchain');const bitcoin = new Blockchain();
  1. Next, let's generate a blockchain for us to test. We'll do this by starting at one of the servers. So go to the terminal, type npn run node_1 and press Enter. Then you'll receive the response, Listening on port 3001.
  1. On node 3001, now let's create a blockchain and add some data to it so that we can test the new blockchain. Currently, the blockchain on node 3001 only has the genesis block in it. So, let's add a couple more blocks ...

Get Learn Blockchain Programming with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.