tendermint/consensus/state_test.go

39 lines
872 B
Go
Raw Normal View History

2014-10-18 01:42:33 -07:00
package consensus
import (
"testing"
_ "github.com/tendermint/tendermint/config/tendermint_test"
2014-10-18 01:42:33 -07:00
)
2015-06-24 14:04:40 -07:00
func TestEnterProposeNoPrivValidator(t *testing.T) {
cs, _ := randConsensusState()
2015-06-24 14:04:40 -07:00
cs.EnterPropose(1, 0)
2014-10-18 01:42:33 -07:00
rs := cs.GetRoundState()
if rs.Proposal != nil {
t.Error("Expected to make no proposal, since no privValidator")
2014-10-18 01:42:33 -07:00
}
}
2015-06-24 14:04:40 -07:00
func TestEnterPropose(t *testing.T) {
cs, privValidators := randConsensusState()
2014-12-17 01:37:13 -08:00
val0 := privValidators[0]
cs.SetPrivValidator(val0)
2015-06-24 14:04:40 -07:00
cs.EnterPropose(1, 0)
rs := cs.GetRoundState()
2014-10-26 13:26:27 -07:00
// Check that Proposal, ProposalBlock, ProposalBlockParts are set.
2014-10-21 01:18:46 -07:00
if rs.Proposal == nil {
t.Error("rs.Proposal should be set")
}
if rs.ProposalBlock == nil {
t.Error("rs.ProposalBlock should be set")
}
2014-10-26 13:26:27 -07:00
if rs.ProposalBlockParts.Total() == 0 {
t.Error("rs.ProposalBlockParts should be set")
2014-10-21 01:18:46 -07:00
}
}
2015-06-05 14:15:40 -07:00
// TODO write better consensus state tests