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 e2e_test
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/stretchr/testify/require"
  6. e2e "github.com/tendermint/tendermint/test/e2e/pkg"
  7. )
  8. // Tests that all nodes have peered with each other, regardless of discovery method.
  9. func TestNet_Peers(t *testing.T) {
  10. // FIXME Skip test since nodes aren't always able to fully mesh
  11. t.SkipNow()
  12. testNode(t, func(ctx context.Context, t *testing.T, node e2e.Node) {
  13. client, err := node.Client()
  14. require.NoError(t, err)
  15. netInfo, err := client.NetInfo(ctx)
  16. require.NoError(t, err)
  17. require.Equal(t, len(node.Testnet.Nodes)-1, netInfo.NPeers,
  18. "node is not fully meshed with peers")
  19. seen := map[string]bool{}
  20. for _, n := range node.Testnet.Nodes {
  21. seen[n.Name] = (n.Name == node.Name) // we've clearly seen ourself
  22. }
  23. for _, peerInfo := range netInfo.Peers {
  24. id := peerInfo.ID
  25. peer := node.Testnet.LookupNode(string(id))
  26. require.NotNil(t, peer, "unknown node %v", id)
  27. require.Contains(t, peerInfo.URL, peer.IP.String(),
  28. "unexpected IP address for peer %v", id)
  29. seen[string(id)] = true
  30. }
  31. for name := range seen {
  32. require.True(t, seen[name], "node %v not peered with %v", node.Name, name)
  33. }
  34. })
  35. }