Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print command error when failing, not output #321

Merged
merged 2 commits into from
Jun 26, 2024
Merged

Print command error when failing, not output #321

merged 2 commits into from
Jun 26, 2024

Conversation

m-Peter
Copy link
Collaborator

@m-Peter m-Peter commented Jun 26, 2024

Description


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling in test execution to use error messages directly for better debugging information.
  • Tests

    • Increased timeout value in eth_streaming_filters_test.js from 20 to 30 for more robust testing.
    • Temporarily disabled process exit call in eth_streaming_filters_test.js and eth_streaming_test.js to prevent premature termination during tests.

Copy link
Contributor

coderabbitai bot commented Jun 26, 2024

Warning

Review failed

The pull request is closed.

Walkthrough

The updates involve improvements to test handling across three files. In tests/helpers.go, the error handling is enhanced by directly using the error message rather than converting output to a string. The eth_streaming_filters_test.js file sees an increase in the timeout value from 20 to 30 and a commenting out of a setTimeout function call. Similarly, eth_streaming_test.js comments out a process.exit(1) call to prevent premature test terminations.

Changes

File Change Summary
tests/helpers.go Modified error handling in executeTest function to use err.Error() instead of string(out).
tests/web3js/eth_streaming_filters_test.js Changed timeout value from 20 to 30 and commented out the setTimeout function call.
tests/web3js/eth_streaming_test.js Commented out the process.exit(1) call to prevent early test termination.

Poem

Amid the code, a change so bright,
Errors now are clear in sight,
Time extended, faults delayed,
Testing paths where bugs once played,
Progress strides on this fair night.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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.

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
tests/helpers.go (1)

Line range hint 51-51: Security Issue: Hardcoded API Keys Detected.

Hardcoding API keys in the source code is a significant security risk. These keys can be accessed by anyone who has access to the repository, potentially leading to unauthorized access to services.

- servicePrivateKey = "61ceacbdce419e25ee8e7c2beceee170a05c9cab1e725a955b15ba94dcd747d2"
- eoaTestPrivateKey = "f6d5333177711e562cabf1f311916196ee6ffc2a07966d9d4628094073bd5442"
+ // Remove hardcoded keys. Use environment variables or a secure vault service.

Consider using environment variables or a secure vault service to manage sensitive information securely. Would you like assistance in implementing this change?

Also applies to: 54-54

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 98cb205 and 85cff76.

Files selected for processing (1)
  • tests/helpers.go (1 hunks)
Additional context used
Gitleaks
tests/helpers.go

51-51: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


54-54: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Additional comments not posted (1)
tests/helpers.go (1)

194-194: Improve error handling in test execution.

Changing the error reporting to use err.Error() instead of string(out) is a good practice as it focuses on the actual error message rather than potentially misleading output. This aligns with the PR's objectives to improve clarity in error handling.

Copy link
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.

Actionable comments posted: 0

Outside diff range and nitpick comments (4)
tests/web3js/eth_streaming_test.js (3)

Line range hint 33-46: Remove async from Promise executor functions to prevent potential unhandled rejections.

Using async functions as Promise executors can lead to unhandled promise rejections. This can make error handling and debugging more difficult.

- let doneBlocks = new Promise(async (res, rej) => {
+ let doneBlocks = new Promise((res, rej) => {

Line range hint 51-64: Remove async from Promise executor functions to improve error handling.

Similar to the previous comment, using async in Promise executors is not recommended. It should be refactored to handle asynchronous operations properly without risking unhandled rejections.

- let doneTxs = new Promise(async (res, rej) => {
+ let doneTxs = new Promise((res, rej) => {

Line range hint 71-84: Refactor Promise executor to remove async keyword.

Continuing the pattern from earlier comments, removing async from Promise executors is necessary to ensure that errors are handled correctly and not left uncaught.

- let doneAddressLogs = new Promise(async (res, rej) => {
+ let doneAddressLogs = new Promise((res, rej) => {
tests/helpers.go (1)

Line range hint 51-51: Remove hardcoded API key to enhance security.

Hardcoded secrets pose a significant security risk, especially in public repositories. Consider using environment variables or secure vault solutions to manage secrets.

- servicePrivateKey = "61ceacbdce419e25ee8e7c2beceee170a05c9cab1e725a955b15ba94dcd747d2"
+ servicePrivateKey = os.Getenv("SERVICE_PRIVATE_KEY")
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 85cff76 and 04d0941.

Files selected for processing (3)
  • tests/helpers.go (1 hunks)
  • tests/web3js/eth_streaming_filters_test.js (2 hunks)
  • tests/web3js/eth_streaming_test.js (1 hunks)
Files skipped from review due to trivial changes (1)
  • tests/web3js/eth_streaming_filters_test.js
Additional context used
Biome
tests/web3js/eth_streaming_test.js

[error] 33-46: Promise executor functions should not be async. (lint/suspicious/noAsyncPromiseExecutor)


[error] 51-64: Promise executor functions should not be async. (lint/suspicious/noAsyncPromiseExecutor)


[error] 71-84: Promise executor functions should not be async. (lint/suspicious/noAsyncPromiseExecutor)

Gitleaks
tests/helpers.go

51-51: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


54-54: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Additional comments not posted (1)
tests/helpers.go (1)

Line range hint 54-54: Remove hardcoded private key to prevent security vulnerabilities.

Similar to the previous comment, storing private keys in the source code can lead to security breaches. Use secure storage solutions instead.
[ISSURE]

- eoaTestPrivateKey = "f6d5333177711e562cabf1f311916196ee6ffc2a07966d9d4628094073bd5442"
+ eoaTestPrivateKey = os.Getenv("EOA_TEST_PRIVATE_KEY")

@@ -191,7 +191,7 @@ func executeTest(t *testing.T, testFile string) {
var exitError *exec.ExitError
if errors.As(err, &exitError) {
if exitError.ExitCode() == 1 {
require.Fail(t, string(out))
require.Fail(t, err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

can we print both, because I believe the output will have information from the execution

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

out, err := cmd.CombinedOutput()
t.Log(string(out))

The output is already printed, outside the condition.

setTimeout(() => process.exit(1), (timeout-1)*1000) // hack if the ws connection is not closed
// hack if the ws connection is not closed
// TMP: disable
// setTimeout(() => process.exit(1), (timeout - 1) * 1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think with mocha set timeout we could remove this completely

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch 👍
Removed in 7527958

Copy link
Contributor

@devbugging devbugging left a comment

Choose a reason for hiding this comment

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

Left comments

@m-Peter m-Peter merged commit 280a63c into main Jun 26, 2024
2 checks passed
@m-Peter m-Peter deleted the moar-ci-fixes branch June 26, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants