You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
872 B

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. package consensus
  2. import (
  3. "testing"
  4. _ "github.com/tendermint/tendermint/config/tendermint_test"
  5. )
  6. func TestEnterProposeNoPrivValidator(t *testing.T) {
  7. cs, _ := randConsensusState()
  8. cs.EnterPropose(1, 0)
  9. rs := cs.GetRoundState()
  10. if rs.Proposal != nil {
  11. t.Error("Expected to make no proposal, since no privValidator")
  12. }
  13. }
  14. func TestEnterPropose(t *testing.T) {
  15. cs, privValidators := randConsensusState()
  16. val0 := privValidators[0]
  17. cs.SetPrivValidator(val0)
  18. cs.EnterPropose(1, 0)
  19. rs := cs.GetRoundState()
  20. // Check that Proposal, ProposalBlock, ProposalBlockParts are set.
  21. if rs.Proposal == nil {
  22. t.Error("rs.Proposal should be set")
  23. }
  24. if rs.ProposalBlock == nil {
  25. t.Error("rs.ProposalBlock should be set")
  26. }
  27. if rs.ProposalBlockParts.Total() == 0 {
  28. t.Error("rs.ProposalBlockParts should be set")
  29. }
  30. }
  31. // TODO write better consensus state tests