Skip to content

Conversation

@chatton
Copy link
Contributor

@chatton chatton commented Jan 27, 2026

Overview

part of #3019

This PR extracts out some common helper functionality that will be able to be used in some follow up compatibility tests.

Extract common EVM test infrastructure to reusable helpers:
- RethSetup struct and SetupRethNode() for Reth node setup
- SetupCelestiaAndDABridge() returns DA address
- WaitForEVMHealthy() for evmsingle health checks
- SetupEthClient() creates and verifies eth client
- WaitForTxIncluded() waits for transaction inclusion

Refactor EVMSingleUpgradeTestSuite to use the shared helpers,
reducing code duplication and enabling future test reuse.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 27, 2026

The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedJan 28, 2026, 8:15 AM

@claude
Copy link
Contributor

claude bot commented Jan 27, 2026

Claude finished @chatton's task in 1m 39s —— View job


Code Review Complete

I've performed a comprehensive review of this refactoring PR. Overall, this is excellent work that significantly improves code organization and reusability. The extraction of common test infrastructure into DockerTestSuite helpers is well-executed and will make future test development much easier.


Summary

Changes:

  • ✅ Extracted 5 reusable helper functions from EVMSingleUpgradeTestSuite to DockerTestSuite
  • ✅ Introduced RethSetup struct to encapsulate Reth node configuration
  • ✅ Reduced code duplication: removed ~120 lines from upgrade_test.go
  • ✅ Improved test readability and maintainability

Net Impact: +135 additions, -138 deletions across 2 files


Detailed Review

🟢 Strengths

1. Excellent Abstraction Design

The new helpers follow the single responsibility principle perfectly:

  • SetupRethNode() - Reth lifecycle management
  • SetupCelestiaAndDABridge() - DA infrastructure setup
  • WaitForEVMHealthy() - Health check polling
  • SetupEthClient() - Client creation + verification
  • WaitForTxIncluded() - Transaction confirmation

Each function is focused, testable, and reusable.

2. Strong Return Value Design

The RethSetup struct (lines 254-262 in docker_test.go) is well-designed:

type RethSetup struct {
    Node           *reth.Node
    EngineURL      string // internal container-to-container URL
    EthURL         string // internal container-to-container URL
    EthURLExternal string // host-accessible URL
    JWTSecret      string
    GenesisHash    string
}
  • Clear documentation distinguishes internal vs. external URLs
  • All necessary configuration in one place
  • Eliminates multiple field assignments

3. Improved Test Readability

The refactored test (upgrade_test.go:55-98) reads like documentation:

s.Run("setup_celestia_and_DA_bridge", func() {
    s.daAddress = s.SetupCelestiaAndDABridge(ctx)
    s.T().Log("DA bridge node started and funded")
})

Before: 20+ lines of setup code
After: 2 lines with clear intent

4. Proper Resource Management

  • All helpers use s.Require() for early failure detection
  • defer resp.Body.Close() in HTTP requests (line 336)
  • conn.Close() after connectivity checks (line 284)
  • Appropriate use of Eventually() for async operations

5. Good Go Idioms

  • Context propagation throughout
  • Proper error handling patterns
  • Meaningful timeout values (60s for Reth startup, 120s for EVM health)
  • Clean separation of concerns

🟡 Minor Issues & Suggestions

1. Unhandled Error in WaitForEVMHealthy() (Priority: Low)

Location: test/docker-e2e/docker_test.go:331

Issue: Gemini Code Assist correctly identified that http.NewRequestWithContext() error is ignored:

req, _ := http.NewRequestWithContext(ctx, http.MethodGet, healthURL, nil)

Why it matters: While this error is extremely unlikely (invalid URL or method), defensive error handling is a Go best practice, especially in test infrastructure that might be used in unexpected contexts.

Recommendation:

s.Require().Eventually(func() bool {
    req, err := http.NewRequestWithContext(ctx, http.MethodGet, healthURL, nil)
    if err != nil {
        return false // or s.T().Logf("unexpected error creating request: %v", err)
    }
    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        return false
    }
    defer resp.Body.Close()
    return resp.StatusCode == http.StatusOK
}, 120*time.Second, 2*time.Second, "evm node did not become healthy")

Fix this error handling →


2. Inconsistent Timeout Values

Observation: Different timeouts for similar operations:

  • WaitForEVMHealthy(): 120s timeout (line 338)
  • Original waitForEVMSingleHealthy(): 60s timeout (removed code)

Impact: Low - the longer timeout is more conservative and likely correct for CI environments.

Note: No action required unless 120s is too long for typical use cases.


3. Documentation Opportunities

Current state: Good inline comments, but could be enhanced.

Suggestion: Consider adding godoc comments for the public helper methods to explain:

  • Prerequisites (e.g., setupDockerEnvironment() must be called first)
  • What resources are created/started
  • Expected failure modes

Example:

// SetupRethNode creates, starts, and waits for a Reth execution client node.
// It polls for TCP connectivity and retrieves network info before returning.
// Requires setupDockerEnvironment() to have been called.
// Returns RethSetup with internal/external URLs, JWT secret, and genesis hash.
func (s *DockerTestSuite) SetupRethNode(ctx context.Context) RethSetup {
    // ...
}

Add godoc comments →


✅ What This PR Does Well

  1. Zero Breaking Changes - All existing tests continue to work
  2. Proper Separation - Helpers in base suite, specific logic in test suite
  3. Type Safety - Strong typing with RethSetup struct
  4. Future-Proof - Easy to add more helpers as needed
  5. Test Coverage - No reduction in coverage (maintained at 57.98%)
  6. CI Passing - All checks green (buf, linting, tests)

🔍 Code Quality Assessment

Aspect Rating Notes
Architecture ⭐⭐⭐⭐⭐ Excellent abstraction and separation of concerns
Error Handling ⭐⭐⭐⭐ Very good, one minor unhandled error
Reusability ⭐⭐⭐⭐⭐ Perfect for future compatibility tests
Readability ⭐⭐⭐⭐⭐ Significantly improved test clarity
Go Idioms ⭐⭐⭐⭐⭐ Follows community best practices
Documentation ⭐⭐⭐⭐ Good inline comments, could add godoc

Recommendation

✅ APPROVE - This refactoring achieves its goal and sets up the codebase well for future compatibility tests. The single minor issue with error handling is not blocking and can be addressed in a follow-up if desired.

The code quality is high, the abstraction choices are sound, and the implementation follows Go best practices. This is exactly the kind of refactoring that makes a codebase more maintainable.


@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chatton, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on refactoring the end-to-end (e2e) tests by extracting common infrastructure setup and utility functions into reusable helpers within the DockerTestSuite. This change aims to reduce code duplication, improve maintainability, and facilitate the creation of new tests by providing a set of pre-built tools for setting up and interacting with the testing environment.

Highlights

  • Refactoring: Extracts common EVM test infrastructure into reusable helper functions within the DockerTestSuite.
  • New Helpers: Introduces RethSetup struct and SetupRethNode() for Reth node setup, SetupCelestiaAndDABridge() to return the DA address, WaitForEVMHealthy() for EVM health checks, SetupEthClient() to create and verify an Ethereum client, and WaitForTxIncluded() to wait for transaction inclusion.
  • Code Reduction: Refactors EVMSingleUpgradeTestSuite to utilize the shared helpers, reducing code duplication and promoting reuse in future tests.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively refactors common test helper functionality into the DockerTestSuite, which significantly cleans up the EVMSingleUpgradeTestSuite and improves code reuse. The extraction of setup logic for Reth, Celestia, and DA bridges into shared helpers is well-executed. I have one minor suggestion to improve error handling in one of the new helper functions.

Comment on lines +331 to +337
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, healthURL, nil)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return false
}
defer resp.Body.Close()
return resp.StatusCode == http.StatusOK
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

It's good practice to handle all errors, even those that seem unlikely. The error from http.NewRequestWithContext is currently ignored. Checking it would make the code more robust. The suggested change also renames an error variable to avoid a redeclaration conflict that would arise from handling this new error.

		req, reqErr := http.NewRequestWithContext(ctx, http.MethodGet, healthURL, nil)
		if reqErr != nil {
			return false
		}
		resp, err := http.DefaultClient.Do(req)
		if err != nil {
			return false
		}
		defer resp.Body.Close()
		return resp.StatusCode == http.StatusOK

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.55%. Comparing base (9c61f18) to head (814c6f0).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3017      +/-   ##
==========================================
- Coverage   55.66%   55.55%   -0.12%     
==========================================
  Files         116      116              
  Lines       11477    11477              
==========================================
- Hits         6389     6376      -13     
- Misses       4389     4401      +12     
- Partials      699      700       +1     
Flag Coverage Δ
combined 55.55% <ø> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatton chatton marked this pull request as ready for review January 28, 2026 08:15
@chatton chatton added this pull request to the merge queue Jan 28, 2026
Merged via the queue into main with commit 1b69313 Jan 28, 2026
32 checks passed
@chatton chatton deleted the cian/refactor-docker-e2e-helpers branch January 28, 2026 09:06
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.

4 participants