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.

42 lines
1.1 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. client, err := node.Client()
  13. require.NoError(t, err)
  14. netInfo, err := client.NetInfo(ctx)
  15. require.NoError(t, err)
  16. require.Equal(t, len(node.Testnet.Nodes)-1, netInfo.NPeers,
  17. "node is not fully meshed with peers")
  18. seen := map[string]bool{}
  19. for _, n := range node.Testnet.Nodes {
  20. seen[n.Name] = (n.Name == node.Name) // we've clearly seen ourself
  21. }
  22. for _, peerInfo := range netInfo.Peers {
  23. id := peerInfo.ID
  24. peer := node.Testnet.LookupNode(string(id))
  25. require.NotNil(t, peer, "unknown node %v", id)
  26. require.Contains(t, peerInfo.URL, peer.IP.String(),
  27. "unexpected IP address for peer %v", id)
  28. seen[string(id)] = true
  29. }
  30. for name := range seen {
  31. require.True(t, seen[name], "node %v not peered with %v", node.Name, name)
  32. }
  33. })
  34. }