Skip to content
This repository has been archived by the owner on Jan 22, 2020. It is now read-only.

When testing the Blockchain class, make sure the addBlock method correctly adds previousHash to the added block #96

Closed
azangru opened this issue Jun 23, 2018 · 1 comment
Labels
bug Something isn't working

Comments

@azangru
Copy link

azangru commented Jun 23, 2018

The addBlock method of the Blockchain class should pass the correct previousHash to the newly added block. This is not currently checked in the tests for the Blockchain class. So when I made the following typo:

  addBlock(transactions) {
    const previousHash = this.getHeadBlock().previousHash; // instead of this.getHeadBlock().hash;
    const newBlock = new Block(transactions, previousHash);
    this.blocks.push(newBlock);
  }

the tests didn’t catch that (although later tests did).

@delventhalz delventhalz self-assigned this Jun 25, 2018
@delventhalz delventhalz added the bug Something isn't working label Jun 25, 2018
delventhalz pushed a commit to delventhalz/education-cryptomoji that referenced this issue Aug 11, 2018
Fixes hyperledger-archives#96

Ensures that students set the previousHash properly when adding blocks
to the blockchain. Previously this was not checked.

Signed-off-by: Zac Delventhal <zac@bitwise.io>
delventhalz pushed a commit to delventhalz/education-cryptomoji that referenced this issue Aug 11, 2018
Fixes hyperledger-archives#96

Ensures that students set the previousHash properly when adding blocks
to the blockchain. Previously this was not checked.

Signed-off-by: Zac Delventhal <delventhalz@gmail.com>
@therobinkim
Copy link
Contributor

Fixed by #112

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants