Skip to content

Commit

Permalink
fixup: s/ID/NodeID/
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed Dec 15, 2023
1 parent 862e939 commit cb968e8
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/c/dynamic_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
ginkgo.By("initializing a coreth client")
node := privateNetwork.Nodes[0]
nodeURI := tmpnet.NodeURI{
ID: node.ID,
URI: node.URI,
NodeID: node.NodeID,
URI: node.URI,
}
ethClient := e2e.NewEthClient(nodeURI)

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/faultinjection/duplicate_node_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ func checkConnectedPeers(existingNodes []*tmpnet.Node, newNode *tmpnet.Node) {

for _, existingNode := range existingNodes {
// Check that the existing node is a peer of the new node
require.True(peerIDs.Contains(existingNode.ID))
require.True(peerIDs.Contains(existingNode.NodeID))

// Check that the new node is a peer
infoClient := info.NewClient(existingNode.URI)
peers, err := infoClient.Peers(e2e.DefaultContext())
require.NoError(err)
isPeer := false
for _, peer := range peers {
if peer.ID == newNode.ID {
if peer.ID == newNode.NodeID {
isPeer = true
break
}
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture/e2e/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func NewTestEnvironment(flagVars *FlagVars) *TestEnvironment {
func (te *TestEnvironment) GetRandomNodeURI() tmpnet.NodeURI {
r := rand.New(rand.NewSource(time.Now().Unix())) //#nosec G404
nodeURI := te.URIs[r.Intn(len(te.URIs))]
tests.Outf("{{blue}} targeting node %s with URI: %s{{/}}\n", nodeURI.ID, nodeURI.URI)
tests.Outf("{{blue}} targeting node %s with URI: %s{{/}}\n", nodeURI.NodeID, nodeURI.URI)
return nodeURI
}

Expand Down
8 changes: 4 additions & 4 deletions tests/fixture/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const (

// Create a new wallet for the provided keychain against the specified node URI.
func NewWallet(keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) primary.Wallet {
tests.Outf("{{blue}} initializing a new wallet for node %s with URI: %s {{/}}\n", nodeURI.ID, nodeURI.URI)
tests.Outf("{{blue}} initializing a new wallet for node %s with URI: %s {{/}}\n", nodeURI.NodeID, nodeURI.URI)
baseWallet, err := primary.MakeWallet(DefaultContext(), &primary.WalletConfig{
URI: nodeURI.URI,
AVAXKeychain: keychain,
Expand All @@ -81,7 +81,7 @@ func NewWallet(keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) primary.W

// Create a new eth client targeting the specified node URI.
func NewEthClient(nodeURI tmpnet.NodeURI) ethclient.Client {
tests.Outf("{{blue}} initializing a new eth client for node %s with URI: %s {{/}}\n", nodeURI.ID, nodeURI.URI)
tests.Outf("{{blue}} initializing a new eth client for node %s with URI: %s {{/}}\n", nodeURI.NodeID, nodeURI.URI)
nodeAddress := strings.Split(nodeURI.URI, "//")[1]
uri := fmt.Sprintf("ws://%s/ext/bc/C/ws", nodeAddress)
client, err := ethclient.Dial(uri)
Expand Down Expand Up @@ -136,7 +136,7 @@ func AddEphemeralNode(network *tmpnet.Network, flags tmpnet.FlagsMap) *tmpnet.No
// Ensure node is stopped on teardown. It's configuration is not removed to enable
// collection in CI to aid in troubleshooting failures.
ginkgo.DeferCleanup(func() {
tests.Outf("Shutting down ephemeral node %s\n", node.ID)
tests.Outf("Shutting down ephemeral node %s\n", node.NodeID)
require.NoError(node.Stop())
})

Expand Down Expand Up @@ -213,7 +213,7 @@ func CheckBootstrapIsPossible(network *tmpnet.Network) {
require.NoError(err)

defer func() {
tests.Outf("Shutting down ephemeral node %s\n", node.ID)
tests.Outf("Shutting down ephemeral node %s\n", node.NodeID)
require.NoError(node.Stop())
}()

Expand Down
10 changes: 5 additions & 5 deletions tests/fixture/tmpnet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ func (c *NetworkConfig) EnsureGenesis(networkID uint32, initialStakers []genesis

// NodeURI associates a node ID with its API URI.
type NodeURI struct {
ID ids.NodeID
URI string
NodeID ids.NodeID
URI string
}

// NodeConfig defines configuration for an AvalancheGo node.
type NodeConfig struct {
ID ids.NodeID
Flags FlagsMap
NodeID ids.NodeID
Flags FlagsMap
}

func NewNodeConfig() *NodeConfig {
Expand Down Expand Up @@ -306,7 +306,7 @@ func (nc *NodeConfig) EnsureNodeID() error {
return fmt.Errorf("failed to ensure node ID: failed to load tls cert: %w", err)
}
stakingCert := staking.CertificateFromX509(tlsCert.Leaf)
nc.ID = ids.NodeIDFromCert(stakingCert)
nc.NodeID = ids.NodeIDFromCert(stakingCert)

return nil
}
Expand Down
20 changes: 10 additions & 10 deletions tests/fixture/tmpnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (n *Network) PopulateNodeConfig(node *Node, nodeParentDir string) error {
dataDir := node.GetDataDir()
if len(dataDir) == 0 {
// NodeID will have been set by EnsureKeys
dataDir = filepath.Join(nodeParentDir, node.ID.String())
dataDir = filepath.Join(nodeParentDir, node.NodeID.String())
flags[config.DataDirKey] = dataDir
}

Expand Down Expand Up @@ -352,7 +352,7 @@ func (n *Network) Start(w io.Writer) error {
}

// Collect bootstrap nodes for subsequently started nodes to use
bootstrapIDs = append(bootstrapIDs, node.ID.String())
bootstrapIDs = append(bootstrapIDs, node.NodeID.String())
bootstrapIPs = append(bootstrapIPs, node.StakingAddress)
}

Expand All @@ -367,7 +367,7 @@ func (n *Network) WaitForHealthy(ctx context.Context, w io.Writer) error {
healthyNodes := set.NewSet[ids.NodeID](len(n.Nodes))
for healthyNodes.Len() < len(n.Nodes) {
for _, node := range n.Nodes {
if healthyNodes.Contains(node.ID) {
if healthyNodes.Contains(node.NodeID) {
continue
}

Expand All @@ -379,8 +379,8 @@ func (n *Network) WaitForHealthy(ctx context.Context, w io.Writer) error {
continue
}

healthyNodes.Add(node.ID)
if _, err := fmt.Fprintf(w, "%s is healthy @ %s\n", node.ID, node.URI); err != nil {
healthyNodes.Add(node.NodeID)
if _, err := fmt.Fprintf(w, "%s is healthy @ %s\n", node.NodeID, node.URI); err != nil {
return err
}
}
Expand All @@ -404,8 +404,8 @@ func (n *Network) GetURIs() []NodeURI {
// node.ReadProcessContext() was called.
if len(node.URI) > 0 {
uris = append(uris, NodeURI{
ID: node.ID,
URI: node.URI,
NodeID: node.NodeID,
URI: node.URI,
})
}
}
Expand All @@ -418,7 +418,7 @@ func (n *Network) Stop() error {
// Assume the nodes are loaded and the pids are current
for _, node := range n.Nodes {
if err := node.Stop(); err != nil {
errs = append(errs, fmt.Errorf("failed to stop node %s: %w", node.ID, err))
errs = append(errs, fmt.Errorf("failed to stop node %s: %w", node.NodeID, err))
}
}
if len(errs) > 0 {
Expand Down Expand Up @@ -691,7 +691,7 @@ func (n *Network) GetBootstrapIPsAndIDs() ([]string, []string, error) {
}

bootstrapIPs = append(bootstrapIPs, node.StakingAddress)
bootstrapIDs = append(bootstrapIDs, node.ID.String())
bootstrapIDs = append(bootstrapIDs, node.NodeID.String())
}

if len(bootstrapIDs) == 0 {
Expand Down Expand Up @@ -719,7 +719,7 @@ func stakersForNodes(networkID uint32, nodes []*Node) ([]genesis.UnparsedStaker,
return nil, fmt.Errorf("failed to derive proof of possession: %w", err)
}
initialStakers[i] = genesis.UnparsedStaker{
NodeID: node.ID,
NodeID: node.NodeID,
RewardAddress: rewardAddr,
DelegationFee: .01 * reward.PercentDenominator,
Signer: pop,
Expand Down
10 changes: 5 additions & 5 deletions tests/fixture/tmpnet/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ func (n *Node) Start(w io.Writer, defaultExecPath string) error {
}

// Determine appropriate level of node description detail
nodeDescription := fmt.Sprintf("node %q", n.ID)
nodeDescription := fmt.Sprintf("node %q", n.NodeID)
isEphemeralNode := filepath.Base(filepath.Dir(n.GetDataDir())) == defaultEphemeralDirName
if isEphemeralNode {
nodeDescription = "ephemeral " + nodeDescription
}
nonDefaultNodeDir := filepath.Base(n.GetDataDir()) != n.ID.String()
nonDefaultNodeDir := filepath.Base(n.GetDataDir()) != n.NodeID.String()
if nonDefaultNodeDir {
// Only include the data dir if its base is not the default (the node ID)
nodeDescription = fmt.Sprintf("%s with path: %s", nodeDescription, n.GetDataDir())
Expand Down Expand Up @@ -261,7 +261,7 @@ func (n *Node) Stop() error {

select {
case <-ctx.Done():
return fmt.Errorf("failed to see node process stop %q before timeout: %w", n.ID, ctx.Err())
return fmt.Errorf("failed to see node process stop %q before timeout: %w", n.NodeID, ctx.Err())
case <-ticker.C:
}
}
Expand Down Expand Up @@ -310,12 +310,12 @@ func (n *Node) WaitForProcessContext(ctx context.Context) error {
for len(n.URI) == 0 {
err := n.ReadProcessContext()
if err != nil {
return fmt.Errorf("failed to read process context for node %q: %w", n.ID, err)
return fmt.Errorf("failed to read process context for node %q: %w", n.NodeID, err)
}

select {
case <-ctx.Done():
return fmt.Errorf("failed to load process context for node %q before timeout: %w", n.ID, ctx.Err())
return fmt.Errorf("failed to load process context for node %q before timeout: %w", n.NodeID, ctx.Err())
case <-ticker.C:
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/fixture/tmpnet/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ var ErrNotRunning = errors.New("not running")
// WaitForHealthy blocks until Node.IsHealthy returns true or an error (including context timeout) is observed.
func WaitForHealthy(ctx context.Context, node *Node) error {
if _, ok := ctx.Deadline(); !ok {
return fmt.Errorf("unable to wait for health for node %q with a context without a deadline", node.ID)
return fmt.Errorf("unable to wait for health for node %q with a context without a deadline", node.NodeID)
}
ticker := time.NewTicker(DefaultNodeTickerInterval)
defer ticker.Stop()

for {
healthy, err := node.IsHealthy(ctx)
if err != nil && !errors.Is(err, ErrNotRunning) {
return fmt.Errorf("failed to wait for health of node %q: %w", node.ID, err)
return fmt.Errorf("failed to wait for health of node %q: %w", node.NodeID, err)
}
if healthy {
return nil
}

select {
case <-ctx.Done():
return fmt.Errorf("failed to wait for health of node %q before timeout: %w", node.ID, ctx.Err())
return fmt.Errorf("failed to wait for health of node %q before timeout: %w", node.NodeID, ctx.Err())
case <-ticker.C:
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var _ = ginkgo.Describe("[Upgrade]", func() {

ginkgo.By(fmt.Sprintf("restarting all nodes with %q binary", avalancheGoExecPathToUpgradeTo))
for _, node := range network.Nodes {
ginkgo.By(fmt.Sprintf("restarting node %q with %q binary", node.ID, avalancheGoExecPathToUpgradeTo))
ginkgo.By(fmt.Sprintf("restarting node %q with %q binary", node.NodeID, avalancheGoExecPathToUpgradeTo))
require.NoError(node.Stop())

// A node must start with sufficient bootstrap nodes to represent a quorum. Since the node's current
Expand All @@ -72,7 +72,7 @@ var _ = ginkgo.Describe("[Upgrade]", func() {
node.ExecPath = avalancheGoExecPathToUpgradeTo
require.NoError(node.Start(ginkgo.GinkgoWriter, "" /* defaultExecPath */))

ginkgo.By(fmt.Sprintf("waiting for node %q to report healthy after restart", node.ID))
ginkgo.By(fmt.Sprintf("waiting for node %q to report healthy after restart", node.NodeID))
e2e.WaitForHealthy(node)
}

Expand Down

0 comments on commit cb968e8

Please sign in to comment.