Skip to content

chore: remove duplicate package import#3331

Open
caltechustc wants to merge 1 commit into
evstack:mainfrom
caltechustc:main
Open

chore: remove duplicate package import#3331
caltechustc wants to merge 1 commit into
evstack:mainfrom
caltechustc:main

Conversation

@caltechustc
Copy link
Copy Markdown

@caltechustc caltechustc commented May 21, 2026

Overview

remove duplicate package import

Summary by CodeRabbit

  • Refactor
    • Internal code cleanup improving consistency in client import handling and initialization patterns. No user-facing changes.

Review Change Stack

Signed-off-by: caltechustc <caltechustc@outlook.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

📝 Walkthrough

Walkthrough

The PR refactors a single E2E test file to remove an unnecessary import alias. The rpcclient alias for github.com/evstack/ev-node/pkg/rpc/client is dropped, and all internal references to RPC client types and initialization are updated to use the direct client import and client.Client type throughout the nodeDetails helper struct.

Changes

RPC client import consolidation

Layer / File(s) Summary
RPC client import alias removal
test/e2e/failover_e2e_test.go
The rpcclient import alias is removed. nodeDetails.xRPCClient type, nodeDetails.rpcClient() return type, and initExtClients initialization all switch to the non-aliased client.Client type and client.NewClient constructor.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🐰 A tidy import, clean and bright,
No alias to confuse the sight.
One client name rings true and clear,
As harmless as the morning cheer.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description lacks required detail; it only contains the template comment and minimal explanation without context, background, goal, or rationale for the change. Add an Overview section explaining why the import was duplicated, what the change accomplishes, and any relevant context or linked issues.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: remove duplicate package import' accurately describes the main change—removing the redundant rpcclient import alias in favor of the client import already in use.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/e2e/failover_e2e_test.go (1)

881-889: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: variable client shadows the client package, breaking the build.

On line 882, the local variable client (an *ethclient.Client) shadows the imported github.com/evstack/ev-node/pkg/rpc/client package. Line 886 then calls client.NewClient(d.rpcAddr) which resolves to a method call on the local *ethclient.Client variable rather than the package — *ethclient.Client has no NewClient method, so this will fail to compile. The previous rpcclient alias is exactly what avoided this collision.

🛠️ Proposed fix: rename the local variable to avoid the shadow
 	d.extClientOnce.Do(func() {
-		client, err := ethclient.Dial(d.ethAddr)
+		ethClient, err := ethclient.Dial(d.ethAddr)
 		require.NoError(t, err)
-		d.xEthClient.Store(client)
-		t.Cleanup(client.Close)
+		d.xEthClient.Store(ethClient)
+		t.Cleanup(ethClient.Close)
 		rpcClient := client.NewClient(d.rpcAddr)
 		require.NotNil(t, rpcClient)
 		d.xRPCClient.Store(rpcClient)
 	})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/failover_e2e_test.go` around lines 881 - 889, The local variable
named `client` in the extClientOnce.Do closure shadows the imported `client`
package and causes the call to `client.NewClient(d.rpcAddr)` to resolve
incorrectly; rename the local variable (e.g., to `ethClient`) returned by
`ethclient.Dial(d.ethAddr)` and update subsequent uses (`d.xEthClient.Store`,
`t.Cleanup(ethClient.Close)`) so the package call uses the imported package name
(e.g., `rpcclient.NewClient(d.rpcAddr)`) instead of the shadowed identifier;
ensure `rpcClient` stays the result stored by `d.xRPCClient.Store`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@test/e2e/failover_e2e_test.go`:
- Around line 881-889: The local variable named `client` in the extClientOnce.Do
closure shadows the imported `client` package and causes the call to
`client.NewClient(d.rpcAddr)` to resolve incorrectly; rename the local variable
(e.g., to `ethClient`) returned by `ethclient.Dial(d.ethAddr)` and update
subsequent uses (`d.xEthClient.Store`, `t.Cleanup(ethClient.Close)`) so the
package call uses the imported package name (e.g.,
`rpcclient.NewClient(d.rpcAddr)`) instead of the shadowed identifier; ensure
`rpcClient` stays the result stored by `d.xRPCClient.Store`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c2c464f7-2a6b-4a06-afd3-513e26570081

📥 Commits

Reviewing files that changed from the base of the PR and between 53c5669 and 65262cc.

📒 Files selected for processing (1)
  • test/e2e/failover_e2e_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant