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.

47 lines
1.2 KiB

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