-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
15 implement verification #44
Conversation
Add tests
…lement-verification
29 makefile
…ment-verification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor things. Awesome tests
blockchain/block.go
Outdated
|
||
// ContainsTransaction returns true and the transaction itself if the Block | ||
// contains the transaction. | ||
func (b *Block) ContainsTransaction(t *Transaction) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -70,3 +70,14 @@ func DecodeBlock(r io.Reader) *Block { | |||
gob.NewDecoder(r).Decode(&b) | |||
return &b | |||
} | |||
|
|||
// ContainsTransaction returns true and the transaction itself if the Block | |||
// contains the transaction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"and the transaction itself"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the right thing to do doesn't it. Breaks my if block.ContainsTransaction(t) then
idiom 😢 Forgot the comment in there 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡
blockchain/blockchain.go
Outdated
hash := HashSum(t.TxBody) | ||
if !ecdsa.Verify(t.Sender.Key(), hash.Marshal(), t.Sig.R, t.Sig.S) { | ||
return false | ||
} | ||
|
||
// Validate chain from input block to last block. | ||
// Test if identical transaction already exits in chain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exists
@@ -123,7 +123,8 @@ func newTransactionValue(s, r Wallet, a uint64) (*Transaction, error) { | |||
return tbody.Sign(s, crand.Reader) | |||
} | |||
|
|||
func newValidBlockChainFixture() *BlockChain { | |||
// newValidBlockChainFixture creates a valid blockchain of two blocks. | |||
func newValidBlockChainFixture() (*BlockChain, Wallet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test utils are awesome 🥇
Status: Ready for review.
What Changed
BlockChain
(respend attack) - test caseTestTransactionRespend
.BlockChain.AppendBlock
andBlock.ContainsTransaction
.How To Test Drive This PR
go test