Let's follow the below mentioned steps to test the createNewBlock method:
- Firstly, underneath where we created our bitcoin variable, type in the following highlighted line of code:
const Blockchain = require('./blockchain');const bitcoin = new Blockchain();bitcoin.createNewBlock();console.log(bitcoin);
- This createNewBlock() method requires three parameters, such as nonce, previousBlockHash, and a hash. For test purposes, we can just pass in whatever we want for now. Here, the nonce will just be a number. Then we will create a dummy hash for our previousBlockHash, followed by another hash for our hash parameter, as follows:
bitcoin.createNewBlock(2389,'OIUOEREDHKHKD','78s97d4x6dsf');
Right now, we are ...