2014-10-18 01:42:33 -07:00
|
|
|
package consensus
|
|
|
|
|
|
|
|
import (
|
2014-12-17 01:37:13 -08:00
|
|
|
"bytes"
|
2014-10-18 01:42:33 -07:00
|
|
|
"testing"
|
|
|
|
|
2015-05-17 15:54:45 -07:00
|
|
|
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
2015-04-01 17:30:16 -07:00
|
|
|
"github.com/tendermint/tendermint/types"
|
2014-10-18 01:42:33 -07:00
|
|
|
)
|
|
|
|
|
2014-10-21 01:18:46 -07:00
|
|
|
func TestRunActionProposeNoPrivValidator(t *testing.T) {
|
2014-12-22 18:49:37 -08:00
|
|
|
cs, _ := randConsensusState()
|
2014-10-21 01:18:46 -07:00
|
|
|
cs.RunActionPropose(1, 0)
|
2014-10-18 01:42:33 -07:00
|
|
|
rs := cs.GetRoundState()
|
2014-10-20 19:02:10 -07:00
|
|
|
if rs.Proposal != nil {
|
|
|
|
t.Error("Expected to make no proposal, since no privValidator")
|
2014-10-18 01:42:33 -07:00
|
|
|
}
|
|
|
|
}
|
2014-10-20 19:02:10 -07:00
|
|
|
|
2014-10-21 01:18:46 -07:00
|
|
|
func TestRunActionPropose(t *testing.T) {
|
2014-12-22 18:49:37 -08:00
|
|
|
cs, privValidators := randConsensusState()
|
2014-12-17 01:37:13 -08:00
|
|
|
val0 := privValidators[0]
|
|
|
|
cs.SetPrivValidator(val0)
|
2014-10-20 19:02:10 -07:00
|
|
|
|
2014-10-21 01:18:46 -07:00
|
|
|
cs.RunActionPropose(1, 0)
|
2014-10-20 19:02:10 -07:00
|
|
|
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
|