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.

43 lines
1.2 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. if node.StartAt > m.InitialHeight+5 && !node.Stateless() {
  25. require.NotEqual(t, node.StateSync, e2e.StateSyncDisabled)
  26. }
  27. if node.StateSync != e2e.StateSyncDisabled {
  28. require.Zero(t, node.Seeds, node.StateSync)
  29. require.True(t, len(node.PersistentPeers) >= 2 || len(node.PersistentPeers) == 0,
  30. "peers: %v", node.PersistentPeers)
  31. }
  32. })
  33. }
  34. require.True(t, numStateSyncs <= 2)
  35. })
  36. }
  37. }