consensus: test validator set change

This commit is contained in:
Ethan Buchman
2016-11-23 18:20:46 -05:00
parent 65496ace20
commit 2f9063c1d6
8 changed files with 464 additions and 283 deletions

View File

@@ -21,6 +21,7 @@ type Block struct {
LastCommit *Commit `json:"last_commit"`
}
// TODO: version
func MakeBlock(height int, chainID string, txs []Tx, commit *Commit,
prevBlockID BlockID, valHash, appHash []byte, partSize int) (*Block, *PartSet) {
block := &Block{
@@ -150,9 +151,10 @@ func (b *Block) StringShort() string {
type Header struct {
ChainID string `json:"chain_id"`
Version string `json:"version"` // TODO:
Height int `json:"height"`
Time time.Time `json:"time"`
NumTxs int `json:"num_txs"`
NumTxs int `json:"num_txs"` // XXX: Can we get rid of this?
LastBlockID BlockID `json:"last_block_id"`
LastCommitHash []byte `json:"last_commit_hash"` // commit from validators from the last block
DataHash []byte `json:"data_hash"` // transactions
@@ -291,6 +293,8 @@ func (commit *Commit) ValidateBasic() error {
return errors.New("No precommits in commit")
}
height, round := commit.Height(), commit.Round()
// validate the precommits
for _, precommit := range commit.Precommits {
// It's OK for precommits to be missing.
if precommit == nil {