Testing the proofOfWork method

Let's test our proofOfWork method to make sure that it works properly. We'll be testing the method in our test.js file. So, let's get started:

  1. Open up the test.js file. You might observe the data in a similar way to the following screenshot, which is present in the file from the previous section, Testing the hashBlock method:

  1. If you don't have any data in the test.js file, add this to your test.js file, as shown in the preceding screenshot, and then you can begin testing the data.   
  2. To test our proofOfWork method, we need the previousBlockHash and currentBlockData. So, in our test case, get rid of the nonce ...

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.