Skip to content

test(e2e): add withdraw and deposit tests with big payload#3985

Merged
lumtis merged 26 commits intodevelopfrom
test/withdraw-and-call-big-payload
Jul 9, 2025
Merged

test(e2e): add withdraw and deposit tests with big payload#3985
lumtis merged 26 commits intodevelopfrom
test/withdraw-and-call-big-payload

Conversation

@lumtis
Copy link
Contributor

@lumtis lumtis commented Jun 17, 2025

Summary by CodeRabbit

  • New Features
    • Added a new end-to-end test to validate Ether withdrawal and contract call functionality with a large payload.
    • Introduced a minimal smart contract for testing, capable of handling calls, reverts, and Ether transfers.
  • Tests
    • Enhanced test coverage with a new test scenario for large payload handling during Ether withdrawal and contract calls.
    • Improved payload generation flexibility for testing by allowing customizable payload sizes.
  • Chores
    • Updated a protocol contracts dependency to a newer version.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

A new end-to-end test, TestETHWithdrawAndCallBigPayload, was introduced to validate large payload handling in ETH withdrawal and contract call operations. Supporting this, a minimal Solidity contract, its ABI, and Go bindings were added. Payload generation was refactored for flexibility, and the protocol-contracts dependency was updated.

Changes

File(s) Change Summary
e2e/e2etests/test_eth_withdraw_and_call_big_payload.go Added new E2E test: TestETHWithdrawAndCallBigPayload for ETH withdraw/call with large payload.
e2e/e2etests/e2etests.go Registered the new test and constant.
e2e/e2etests/helpers.go Refactored payload generator; added randomPayloadWithSize.
e2e/contracts/testdappempty/TestDAppEmpty.sol, .abi, .json Introduced minimal Solidity contract, ABI, and bytecode for E2E testing.
e2e/contracts/testdappempty/TestDAppEmpty.go Added Go bindings for the new contract, supporting deployment and interaction.
e2e/contracts/testdappempty/bindings.go Added Go generate directives for contract compilation and binding generation.
cmd/zetae2e/local/evm.go Included the new test in EVM chain test execution.
go.mod Updated github.com/zeta-chain/protocol-contracts dependency version.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner as E2ERunner
    participant EVMChain as EVM Chain
    participant ZEVM as ZEVM Gateway
    participant Contract as TestDAppEmpty

    TestRunner->>EVMChain: Deploy TestDAppEmpty contract
    TestRunner->>ZEVM: Increase gas limit for authorization context
    TestRunner->>ZEVM: Approve ETH ZRC20 for gateway contract
    TestRunner->>ZEVM: Withdraw ETH with call (large payload) to Contract
    ZEVM->>EVMChain: Execute contract call with payload
    EVMChain->>Contract: onCall invoked with large payload
    EVMChain-->>ZEVM: Return transaction result
    TestRunner->>ZEVM: Wait for cctx to be mined
    ZEVM-->>TestRunner: cctx status (OutboundMined)
Loading

Suggested labels

SOLANA_TESTS

Suggested reviewers

  • skosito
  • swift1337

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

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.

@lumtis lumtis added the no-changelog Skip changelog CI check label Jun 17, 2025
@lumtis lumtis marked this pull request as ready for review June 18, 2025 08:04
@lumtis lumtis requested a review from a team as a code owner June 18, 2025 08:04
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

🔭 Outside diff range comments (1)
e2e/e2etests/helpers.go (1)

17-26: Expose size parameter but guard against pathological values

randomPayloadWithSize is useful; however nothing prevents a caller from passing a multi-MB size that could bloat logs or exceed chain call limits.

 func randomPayloadWithSize(r *runner.E2ERunner, size int) string {
-    bytes := make([]byte, size)
+    const max = 4 * 1024 // 4 KB hard cap – adjust as needed
+    if size <= 0 || size > max {
+        require.Fail(r, fmt.Sprintf("payload size %d exceeds maximum %d", size, max))
+    }
+    bytes := make([]byte, size)

This keeps accidental OOM / huge calldata in check while remaining flexible.

🧹 Nitpick comments (5)
e2e/e2etests/e2etests.go (1)

364-369: Provide explicit args for new test to stay consistent

All neighbouring withdraw-and-call tests specify at least amount (and often gasLimit). Omitting them here makes the CLI help inconsistent and forces the test to rely on hard-coded values.

-    []runner.ArgDefinition{},
+    []runner.ArgDefinition{
+        {Description: "amount in wei", DefaultValue: "100000"},
+        {Description: "gas limit for withdraw", DefaultValue: "500000"},
+    },

Add whichever parameters the test actually reads so automation & docs remain uniform.

e2e/contracts/testdappempty/bindings.go (1)

1-4: Harden go:generate pipeline for reproducibility

  1. set -euo pipefail before the command chain stops partially-generated artifacts on failure.
  2. --overwrite for abigen avoids manual cleanup on re-runs.
  3. Consider deleting the intermediate JSON once the ABI/BIN are extracted to keep the repo clean (or generate into $(mktemp)).

Example:

-//go:generate sh -c "solc TestDAppEmpty.sol --evm-version london --combined-json abi,bin | jq '.contracts.\"TestDAppEmpty.sol:TestDAppEmpty\"'  > TestDAppEmpty.json"
+//go:generate sh -ceu "solc TestDAppEmpty.sol --evm-version london --combined-json abi,bin | \
+    jq '.contracts[\"TestDAppEmpty.sol:TestDAppEmpty\"]' > TestDAppEmpty.json"
 ...
-//go:generate sh -c "abigen --abi TestDAppEmpty.abi --bin TestDAppEmpty.bin  --pkg testdappempty --type TestDAppEmpty --out TestDAppEmpty.go"
+//go:generate sh -c "abigen --overwrite --abi TestDAppEmpty.abi --bin TestDAppEmpty.bin \
+    --pkg testdappempty --type TestDAppEmpty --out TestDAppEmpty.go"

These tweaks make regeneration deterministic and developer-friendly.

e2e/e2etests/test_eth_withdraw_and_call_big_payload.go (2)

20-24: Prefer t.Cleanup over a manual defer for state restoration

The test relies on a defer to restore r.ZEVMAuth.GasLimit.
When the helper evolves to use sub-tests (t.Run) or when an early r.T().Fatal is introduced, the defer will not run for the parent test, potentially leaving the runner in an inconsistent state for subsequent tests.
Registering the restoration with r.T().Cleanup (or t.Cleanup) keeps the guarantee even with nested test invocations.

 previousGasLimit := r.ZEVMAuth.GasLimit
-r.ZEVMAuth.GasLimit = 10000000
-defer func() {
-    r.ZEVMAuth.GasLimit = previousGasLimit
-}()
+r.ZEVMAuth.GasLimit = 10_000_000
+r.T().Cleanup(func() { r.ZEVMAuth.GasLimit = previousGasLimit })

26-28: Add an assertion on the payload size for self-documenting safety

The comment explains the expected encoded length, but the code never asserts it.
A quick sanity check prevents silent regressions of the helper.

payload := randomPayloadWithSize(r, 1440)
require.Len(r, payload, 2880, "hex payload length should remain within gateway limit")
e2e/contracts/testdappempty/TestDAppEmpty.sol (1)

34-42: Mark stub functions external payable/pure to minimise gas where possible

onCall currently does nothing yet is declared nonpayable without view/pure.
Explicitly flagging intent keeps the ABI clear and lowers deployment & invocation gas.

-function onCall(
+function onCall(
     zContext calldata /*context*/,
     address /*_zrc20*/,
     uint256 /*amount*/,
     bytes calldata /*message*/
-)
-external
-{
-}
+)
+external
+pure
+{}

Apply the same treatment to the other empty handlers (onRevert, onCall overload) as appropriate.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a10a4c and 879a866.

⛔ Files ignored due to path filters (2)
  • e2e/contracts/testdappempty/TestDAppEmpty.bin is excluded by !**/*.bin
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (10)
  • cmd/zetae2e/local/evm.go (1 hunks)
  • e2e/contracts/testdappempty/TestDAppEmpty.abi (1 hunks)
  • e2e/contracts/testdappempty/TestDAppEmpty.go (1 hunks)
  • e2e/contracts/testdappempty/TestDAppEmpty.json (1 hunks)
  • e2e/contracts/testdappempty/TestDAppEmpty.sol (1 hunks)
  • e2e/contracts/testdappempty/bindings.go (1 hunks)
  • e2e/e2etests/e2etests.go (2 hunks)
  • e2e/e2etests/helpers.go (1 hunks)
  • e2e/e2etests/test_eth_withdraw_and_call_big_payload.go (1 hunks)
  • go.mod (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.go`: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

  • cmd/zetae2e/local/evm.go
  • e2e/e2etests/helpers.go
  • e2e/contracts/testdappempty/bindings.go
  • e2e/e2etests/e2etests.go
  • e2e/e2etests/test_eth_withdraw_and_call_big_payload.go
  • e2e/contracts/testdappempty/TestDAppEmpty.go
🔇 Additional comments (7)
go.mod (1)

55-55: Check downstream compatibility of protocol-contracts bump

The update to github.com/zeta-chain/protocol-contracts pulls in an Ath3.0 build produced two weeks after the previous pin. Ensure:
go mod tidy (and CI) passes – the new tag may have extra indirect deps.
• Any generated bindings or interface changes expected by the E2E tests are present – otherwise the tests will silently break at runtime.

cmd/zetae2e/local/evm.go (1)

25-25: New big-payload test wired in – looks good

Hooking TestETHWithdrawAndCallBigPayloadName into the happy-path suite keeps the order/parallelism untouched and requires no extra funding. 👍

e2e/e2etests/e2etests.go (1)

25-25: Constant added – no concerns

e2e/contracts/testdappempty/bindings.go (1)

6-8: Necessity of dummy reference is questionable

var _ TestDAppEmpty exists only to silence go vet about empty packages; the generated binding already introduces usable identifiers. If future code imports the package it becomes redundant.

e2e/contracts/testdappempty/TestDAppEmpty.go (1)

1-308: Generated file – no manual changes expected.

e2e/contracts/testdappempty/TestDAppEmpty.json (1)

1-125: Compiled artefact – nothing to review.

e2e/contracts/testdappempty/TestDAppEmpty.abi (1)

1-122: Compiled artefact – nothing to review.

fadeev and others added 9 commits July 2, 2025 14:36
* update go mod

* add a new message for migrating funds

* add migrate funds to e2e

* rebase from develop

* add v2 e2e test to check flow

* add zeta gateway deposit to zetaclient

* add github workflow

* update comments

* fix code formating

* fix code formating

* fix code formating

* fix unit tests

* fix unit tests

* revert to old command to start e2e test

* remove message for migration and refactor to using contract directly

* add changelog

* generate files after removing new message

* update generated files

* update generated files

* resolve comments 1

* remove v2 from naming

* generate files
Signed-off-by: yingshanghuangqiao <yingshanghuangqiao@foxmail.com>
* Add ton.call operation

* vote inbound call

* update ton's gateway code

* e2e: ton_to_zevm_call

* Add increaseSeqno parsing

* ton: signer: increase_seqno integration

* ton: observer: increase_seqno integration

* Fix bugs. E2E for increase_seqno

* Update changelog

* Address PR comments

* Simplify inbound voting

* outbounds: validate nonce & simplify code

* bump gw
* update sim.yml

* add changelog

* update generated files
@lumtis lumtis removed the no-changelog Skip changelog CI check label Jul 2, 2025
@lumtis lumtis requested a review from a team as a code owner July 2, 2025 12:56
@github-actions github-actions bot added the ci Changes to CI pipeline or github actions label Jul 2, 2025
@lumtis lumtis changed the title test(e2e): add withdrawAndCall with big payload test(e2e): add withdraw and deposit tests with big payload Jul 2, 2025
@codecov
Copy link

codecov bot commented Jul 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.83%. Comparing base (176f984) to head (7d70ead).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3985   +/-   ##
========================================
  Coverage    64.83%   64.83%           
========================================
  Files          475      475           
  Lines        34860    34860           
========================================
  Hits         22602    22602           
  Misses       11209    11209           
  Partials      1049     1049           
Files with missing lines Coverage Δ
x/fungible/keeper/evm_gateway.go 51.16% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@swift1337 swift1337 self-requested a review July 4, 2025 13:23
@lumtis lumtis added this pull request to the merge queue Jul 7, 2025
@github-actions github-actions bot added the MERGE_FAILED Merge Queue CI failed label Jul 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 7, 2025
@lumtis lumtis added this pull request to the merge queue Jul 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 7, 2025
@lumtis lumtis added this pull request to the merge queue Jul 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 7, 2025
@lumtis lumtis added this pull request to the merge queue Jul 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 7, 2025
@lumtis lumtis enabled auto-merge July 8, 2025 14:22
@lumtis lumtis added this pull request to the merge queue Jul 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 8, 2025
@lumtis lumtis added this pull request to the merge queue Jul 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@lumtis lumtis added this pull request to the merge queue Jul 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@lumtis lumtis added this pull request to the merge queue Jul 9, 2025
Merged via the queue into develop with commit 9bfce76 Jul 9, 2025
48 checks passed
@lumtis lumtis deleted the test/withdraw-and-call-big-payload branch July 9, 2025 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking:cli MERGE_FAILED Merge Queue CI failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants