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

test(evm): e2e tests configuration enhancements #2184

Merged
merged 4 commits into from
Jan 29, 2025
Merged

test(evm): e2e tests configuration enhancements #2184

merged 4 commits into from
Jan 29, 2025

Conversation

onikonychev
Copy link
Contributor

No description provided.

@onikonychev onikonychev requested a review from a team as a code owner January 29, 2025 14:43
Copy link
Contributor

coderabbitai bot commented Jan 29, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This pull request introduces configuration enhancements for end-to-end (e2e) tests in the Nibiru EVM repository. The changes primarily focus on adding configurable timeout constants (TEST_TIMEOUT and TX_WAIT_TIMEOUT) across multiple test files. These constants are centralized in the setup.ts module and can be configured through environment variables, providing more flexibility in test execution. The modifications span several test files, standardizing timeout handling and improving the overall test suite's configurability.

Changes

File Change Summary
CHANGELOG.md Added new entry for PR #2184 under "Unreleased" section
evm-e2e/.env_sample Added two new environment variables: TEST_TIMEOUT and TX_WAIT_TIMEOUT
evm-e2e/test/setup.ts Introduced TEST_TIMEOUT and TX_WAIT_TIMEOUT constants with default values
evm-e2e/test/contract_infinite_loop_gas.test.ts Updated test to use TEST_TIMEOUT for timeout duration and ensured promise is awaited
evm-e2e/test/contract_send_nibi.test.ts Replaced hardcoded timeouts with TEST_TIMEOUT and TX_WAIT_TIMEOUT constants
evm-e2e/test/debug_queries.test.ts Updated timeouts to use TEST_TIMEOUT and TX_WAIT_TIMEOUT constants
evm-e2e/test/erc20.test.ts Updated timeout to use TEST_TIMEOUT constant
evm-e2e/test/eth_queries.test.ts Replaced hardcoded values with TEST_TIMEOUT and TX_WAIT_TIMEOUT, updated assertions
evm-e2e/test/native_transfer.test.ts Updated timeouts to use TEST_TIMEOUT and TX_WAIT_TIMEOUT constants
evm-e2e/test/nibiru_oracle.test.ts Added TEST_TIMEOUT as a timeout parameter in the Jest test function
evm-e2e/test/tx_receipt.test.ts Updated timeout to use TEST_TIMEOUT constant and simplified deployment call
evm-e2e/test/utils.ts Removed TENPOW12, added numberToHex utility function

Possibly related PRs

Suggested labels

skip-changelog

Suggested reviewers

  • Unique-Divine

Poem

🐰 Timeouts dancing, tests so bright,
Configuration leaping with delight!
Constants hopping, flexibility's glee,
Nibiru's EVM, now more free!
Rabbit's code hops with testing might! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9e35b8 and a7cc552.

📒 Files selected for processing (11)
  • CHANGELOG.md (1 hunks)
  • evm-e2e/test/contract_infinite_loop_gas.test.ts (1 hunks)
  • evm-e2e/test/contract_send_nibi.test.ts (5 hunks)
  • evm-e2e/test/debug_queries.test.ts (2 hunks)
  • evm-e2e/test/erc20.test.ts (1 hunks)
  • evm-e2e/test/eth_queries.test.ts (7 hunks)
  • evm-e2e/test/native_transfer.test.ts (1 hunks)
  • evm-e2e/test/nibiru_oracle.test.ts (1 hunks)
  • evm-e2e/test/setup.ts (1 hunks)
  • evm-e2e/test/tx_receipt.test.ts (2 hunks)
  • evm-e2e/test/utils.ts (4 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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: 1

🧹 Nitpick comments (6)
evm-e2e/.env_sample (1)

3-4: LGTM! Consider adding comments to document the timeout units.

The timeout values look reasonable. Consider adding comments to clarify that these values are in milliseconds.

-TEST_TIMEOUT=15000
-TX_WAIT_TIMEOUT=5000
+# Test case timeout in milliseconds
+TEST_TIMEOUT=15000
+# Transaction wait timeout in milliseconds
+TX_WAIT_TIMEOUT=5000
evm-e2e/test/setup.ts (1)

11-11: Fix the export statement formatting.

There's a missing space before the closing curly brace.

-export { account, provider, TEST_TIMEOUT, TX_WAIT_TIMEOUT};
+export { account, provider, TEST_TIMEOUT, TX_WAIT_TIMEOUT };
evm-e2e/test/contract_send_nibi.test.ts (1)

14-14: LGTM! Consider documenting the timeout relationship.

Good use of TX_WAIT_TIMEOUT for transaction waits and a sensible approach to set test timeout as TX_WAIT_TIMEOUT * 2. Consider adding a comment explaining why the test timeout is set to double the transaction wait timeout.

-  const TIMEOUT_MS = TX_WAIT_TIMEOUT * 2;
+  // Double the transaction wait timeout to account for contract deployment and transaction execution
+  const TIMEOUT_MS = TX_WAIT_TIMEOUT * 2;

Also applies to: 26-26, 55-55

evm-e2e/test/utils.ts (2)

15-17: Consider adding input validation to hexify function.

The function should validate that the input is non-negative.

 export const hexify = (x: number): string => {
+    if (x < 0) throw new Error('Input must be non-negative');
     return '0x' + x.toString(16);
 };

57-65: Consider adding error handling to sendTestNibi.

The function should handle potential transaction failures.

 export const sendTestNibi = async () => {
     const transaction: TransactionRequest = {
         gasLimit: toBigInt(100e3),
         to: alice,
         value: parseEther('0.01'),
     };
-    const txResponse = await account.sendTransaction(transaction);
-    await txResponse.wait(1, TX_WAIT_TIMEOUT);
-    console.log(txResponse);
+    try {
+        const txResponse = await account.sendTransaction(transaction);
+        await txResponse.wait(1, TX_WAIT_TIMEOUT);
+        console.log(txResponse);
+        return txResponse;
+    } catch (error) {
+        console.error('Transaction failed:', error);
+        throw error;
+    }
-    return txResponse;
 };
evm-e2e/test/debug_queries.test.ts (1)

3-3: LGTM! Good improvement in test configurability.

The changes effectively centralize timeout configuration by replacing hardcoded values with environment-configurable constants. This enhances maintainability and flexibility of the test suite.

Consider adding a comment explaining the purpose of these timeouts:

 import {provider, TEST_TIMEOUT, TX_WAIT_TIMEOUT} from './setup';
+// TEST_TIMEOUT: Maximum time allowed for test execution
+// TX_WAIT_TIMEOUT: Maximum time to wait for transaction confirmation

Also applies to: 21-21, 28-28

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ecda4c1 and 4df641f.

📒 Files selected for processing (12)
  • CHANGELOG.md (1 hunks)
  • evm-e2e/.env_sample (1 hunks)
  • evm-e2e/test/contract_infinite_loop_gas.test.ts (2 hunks)
  • evm-e2e/test/contract_send_nibi.test.ts (3 hunks)
  • evm-e2e/test/debug_queries.test.ts (2 hunks)
  • evm-e2e/test/erc20.test.ts (2 hunks)
  • evm-e2e/test/eth_queries.test.ts (7 hunks)
  • evm-e2e/test/native_transfer.test.ts (3 hunks)
  • evm-e2e/test/nibiru_oracle.test.ts (2 hunks)
  • evm-e2e/test/setup.ts (1 hunks)
  • evm-e2e/test/tx_receipt.test.ts (2 hunks)
  • evm-e2e/test/utils.ts (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
evm-e2e/test/utils.ts

[error] 81-81: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: e2e-evm
🔇 Additional comments (11)
evm-e2e/test/setup.ts (1)

8-9: LGTM! The implementation looks correct.

Good use of Number() for safe type conversion and appropriate default values matching .env_sample.

evm-e2e/test/contract_infinite_loop_gas.test.ts (2)

10-10: LGTM! Good improvement in promise handling.

The change to use resolves for promise assertions is more correct and explicit.

Also applies to: 20-20


21-21: LGTM! Appropriate timeout adjustment.

Using TEST_TIMEOUT * 2 makes sense for this infinite loop test case, as it may require more time than standard tests.

evm-e2e/test/erc20.test.ts (1)

3-3: LGTM! Clean implementation of the timeout configuration.

The changes are consistent with the project-wide timeout standardization effort.

Also applies to: 24-24

evm-e2e/test/nibiru_oracle.test.ts (1)

4-4: LGTM! Standardized test timeout configuration.

The addition of TEST_TIMEOUT from the centralized setup improves test configuration management.

Also applies to: 41-41

evm-e2e/test/native_transfer.test.ts (1)

3-3: LGTM! Consistent timeout configuration applied.

Good use of both TEST_TIMEOUT and TX_WAIT_TIMEOUT constants for improved test configurability.

Also applies to: 21-21, 44-44

evm-e2e/test/tx_receipt.test.ts (1)

3-4: LGTM! Good cleanup and standardization.

The changes improve the code by:

  1. Using the standardized TEST_TIMEOUT constant
  2. Simplifying contract deployment by removing the unnecessary maxFeePerGas parameter

Also applies to: 8-8, 27-27

evm-e2e/test/eth_queries.test.ts (3)

2-3: LGTM! Good standardization of timeouts.

The changes properly integrate the standardized timeout constants.

Also applies to: 14-14


57-57: Good improvement in block number handling.

Replacing hardcoded block numbers with "latest" makes the tests more reliable and maintainable.

Also applies to: 69-69, 76-76


89-94: Good enhancement in filter setup.

The changes improve filter reliability by:

  1. Retrieving the current block number before creating filters
  2. Using numberToHex for proper block number formatting

Also applies to: 118-123, 144-149

CHANGELOG.md (1)

93-93: LGTM! Proper changelog entry.

The changelog entry is well-formatted and accurately describes the e2e tests configuration enhancements.

evm-e2e/test/utils.ts Outdated Show resolved Hide resolved
@k-yang k-yang enabled auto-merge (squash) January 29, 2025 15:05
@k-yang k-yang merged commit 5d1f87b into main Jan 29, 2025
9 checks passed
@k-yang k-yang deleted the fix/e2e-tests branch January 29, 2025 15: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.

2 participants