Skip to content

feat(ethexe/rpc): black-box tests for RPC service#5399

Open
playX18 wants to merge 1 commit intomasterfrom
ap/rpc-blackbox-test
Open

feat(ethexe/rpc): black-box tests for RPC service#5399
playX18 wants to merge 1 commit intomasterfrom
ap/rpc-blackbox-test

Conversation

@playX18
Copy link
Copy Markdown
Member

@playX18 playX18 commented May 1, 2026

No description provided.

@playX18 playX18 requested review from ecol-master and grishasobol May 1, 2026 01:01
@playX18 playX18 self-assigned this May 1, 2026
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented May 1, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  Cargo.lock Unsupported file format
  ethexe/rpc/Cargo.toml Unsupported file format
  ethexe/rpc/tests/blackbox.rs  0% smaller
  utils/gear-workspace-hack/Cargo.toml Unsupported file format

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 enhances the reliability of the RPC service by implementing a comprehensive black-box testing suite. By utilizing property-based testing, the new tests ensure that the RPC interface correctly handles various inputs and edge cases, improving overall system stability and API contract adherence.

Highlights

  • Black-box testing: Introduced a new black-box testing suite for the RPC service to ensure robust API behavior.
  • Dependency updates: Added proptest to the project dependencies to facilitate property-based testing.
  • Workspace configuration: Updated gear-workspace-hack to simplify dependency management by removing target-specific constraints.
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.

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
Copy Markdown
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 introduces black-box integration tests for the ethexe RPC server, including property-based tests for transaction retrieval. It also updates the workspace hack configuration. Key feedback includes a warning that removing wasm32 target restrictions in Cargo.toml may break WASM contract compilation due to incompatible dependencies. In the new tests, issues were identified regarding a port-binding race condition, the use of sleep for synchronization, inefficient server restarts within property test loops, and a potential logic error in SCALE-encoded bytecode assertions.


### BEGIN HAKARI SECTION
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
[dependencies]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Removing the cfg(not(target_arch = "wasm32")) target restriction from the workspace hack is likely to break the compilation of WASM smart contracts. Many of the dependencies listed here (e.g., alloy, tokio, aes) are not no_std compatible and should not be included when building for the wasm32-unknown-unknown target. Since this file is managed by hakari, please verify if the hakari configuration was unintentionally altered or if this manual change is necessary.

Suggested change
[dependencies]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]


// The RPC method registers its promise waiter after the service accepts
// the transaction, so publish from the next task turn.
tokio::time::sleep(Duration::from_millis(10)).await;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using tokio::time::sleep to handle race conditions in tests is a known anti-pattern that leads to flakiness. It is better to use a synchronization primitive, such as tokio::sync::Notify or a channel, to ensure the RPC service has registered its promise waiter before the test continues.

}
}

fn unused_local_addr() -> SocketAddr {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The unused_local_addr function has a race condition: it binds to a port and then immediately drops the listener, releasing the port. Another process could bind to the same port before the RPC server starts. A more reliable approach is to let the server bind to port 0 and then query the assigned address, or pass a pre-bound TcpListener to the server.

.await
.expect("stored original code must be returned");

assert_eq!(returned_code.0, code.to_vec().encode());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The assertion assert_eq!(returned_code.0, code.to_vec().encode()) might be incorrect. Encode::encode on a Vec<u8> adds a SCALE length prefix. If the RPC method code_getOriginal returns the raw WASM bytecode, the assertion will fail due to this extra prefix. It should likely be compared against code directly.

Suggested change
assert_eq!(returned_code.0, code.to_vec().encode());
assert_eq!(returned_code.0, code.to_vec());

})
.collect();

let rpc = BlackBoxRpc::start_with_db(db).await;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Starting and stopping a full RpcServer inside every iteration of a proptest is extremely inefficient and will significantly slow down the test suite. Consider initializing the server once outside the runner.run loop and reusing it, or using a more lightweight approach for property-based testing of the RPC logic.

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.

2 participants