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.

50 lines
1.4 KiB

  1. package main
  2. import (
  3. "fmt"
  4. "math/rand"
  5. "testing"
  6. "github.com/stretchr/testify/require"
  7. e2e "github.com/tendermint/tendermint/test/e2e/pkg"
  8. )
  9. func TestGenerator(t *testing.T) {
  10. manifests, err := Generate(rand.New(rand.NewSource(randomSeed)), Options{})
  11. require.NoError(t, err)
  12. require.True(t, len(manifests) >= 24, "insufficient combinations %d", len(manifests))
  13. // this just means that the numbers reported by the test
  14. // failures map to the test cases that you'd see locally.
  15. e2e.SortManifests(manifests, false /* ascending */)
  16. for idx, m := range manifests {
  17. t.Run(fmt.Sprintf("Case%04d", idx), func(t *testing.T) {
  18. numStateSyncs := 0
  19. for name, node := range m.Nodes {
  20. if node.StateSync != e2e.StateSyncDisabled {
  21. numStateSyncs++
  22. }
  23. t.Run(name, func(t *testing.T) {
  24. t.Run("StateSync", func(t *testing.T) {
  25. if node.StartAt > m.InitialHeight+5 && !node.Stateless() {
  26. require.NotEqual(t, node.StateSync, e2e.StateSyncDisabled)
  27. }
  28. if node.StateSync != e2e.StateSyncDisabled {
  29. require.Zero(t, node.Seeds, node.StateSync)
  30. require.True(t, len(node.PersistentPeers) >= 2 || len(node.PersistentPeers) == 0,
  31. "peers: %v", node.PersistentPeers)
  32. }
  33. })
  34. if e2e.Mode(node.Mode) != e2e.ModeLight {
  35. t.Run("PrivvalProtocol", func(t *testing.T) {
  36. require.NotZero(t, node.PrivvalProtocol)
  37. })
  38. }
  39. })
  40. }
  41. require.True(t, numStateSyncs <= 2)
  42. })
  43. }
  44. }