Skip to content
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

Better testing for blockchain #23

Merged
merged 10 commits into from
May 20, 2017
Merged

Better testing for blockchain #23

merged 10 commits into from
May 20, 2017

Conversation

jordanschalm
Copy link
Member

No description provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-6.6%) to 34.545% when pulling ba4cb3b on 19-blockchain-tests into 59bd054 on dev.

@coveralls
Copy link

Coverage Status

Coverage increased (+36.9%) to 77.976% when pulling 1a6a1e2 on 19-blockchain-tests into 59bd054 on dev.

@coveralls
Copy link

Coverage Status

Coverage increased (+41.3%) to 82.386% when pulling c41b527 on 19-blockchain-tests into 59bd054 on dev.

@jordanschalm jordanschalm changed the title [WIP] Better testing for blockchain Better testing for blockchain May 19, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+41.2%) to 82.336% when pulling 843708c on 19-blockchain-tests into 59bd054 on dev.

@coveralls
Copy link

Coverage Status

Coverage increased (+41.2%) to 82.336% when pulling 793d893 on 19-blockchain-tests into 59bd054 on dev.

Copy link
Contributor

@chadlagore chadlagore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me. But I'm a bit concerned about the validity of creating randomized test fixtures, makes replication of errors non-deterministic.

It would be nice to have the option to pass parameters to some of these fixtures as well (validating inputs and outputs).

}
}

func newTxOutput() TxOutput {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These helpers are great, but perhaps we could expose a parameter generate this TxOutput fixture in a way that is not random? Im thinking about testing valid transaction inputs and outputs 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point

Copy link
Member

@bfbachmann bfbachmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work my guy!

```

## Testing

```
go test ./...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

miner Wallet
BlockNumber uint32
LastBlock Hash
Miner Address
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of address will this be?

gob.NewDecoder(r).Decode(b)
err := gob.NewEncoder(w).Encode(b)
if err != nil {
fmt.Println(err.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably change this to a Log statement at some point.

func (bc *BlockChain) Decode(r io.Reader) {
gob.NewDecoder(r).Decode(bc)
// DecodeBlockChain reads the marshalled blockchain from the given io.Reader
func DecodeBlockChain(r io.Reader) *BlockChain {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we have to implement our own Blockchain io Reader to handle the format of the Blockchain in byte array format?

}

// Marshaller is any type that can convert itself to a byte slice
type Marshaller interface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

mrand "math/rand"
)

func newHash() Hash {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does't one of the imports have a function that can do this for us?

}

// Len returns the length of a transaction body
func (tb TxBody) Len() int {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps func (tb *TxBody) Len() int would be better here? Not sure about the semantics, but something to think about.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This goes for other exported functions on structs as well.

@jordanschalm jordanschalm merged commit 6adcba1 into dev May 20, 2017
@jordanschalm jordanschalm deleted the 19-blockchain-tests branch June 2, 2017 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants