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.

40 lines
939 B

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