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.

45 lines
1.3 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. peer := node.Testnet.LookupNode(peerInfo.NodeInfo.Moniker)
  28. require.NotNil(t, peer, "unknown node %v", peerInfo.NodeInfo.Moniker)
  29. require.Equal(t, peer.IP.String(), peerInfo.RemoteIP,
  30. "unexpected IP address for peer %v", peer.Name)
  31. seen[peerInfo.NodeInfo.Moniker] = true
  32. }
  33. for name := range seen {
  34. require.True(t, seen[name], "node %v not peered with %v", node.Name, name)
  35. }
  36. })
  37. }