Testing the /consensus endpoint

Let's test the consensus endpoint that we just built. So, what should this /consensus endpoint do? When we call the /consensus endpoint on a specific node, it should confirm for us that that particular node has the correct blockchain data in it, and the node is in sync with the rest of the network. Let's get started with building the test:

  1. Our first step is to make a network that consists of the first four nodes. So let's go to Postman and hit the register-and-broadcast-node endpoint on the node that's hosted on 3001.
  2. Let's add the second node to the network, as seen in the following screenshot. We'll then click on the Send button, receiving the response, New node registered with network successfully

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.