Skip to content

[CLI] Run the test suite on anvil instead of ganache - #690

Open
Uxío (Uxio0) wants to merge 1 commit into
mainfrom
uxio/pla-2321-cli-run-the-test-suite-on-anvil-instead-of
Open

Uxío (Uxio0) wants to merge 1 commit into
mainfrom
uxio/pla-2321-cli-run-the-test-suite-on-anvil-instead-of

Conversation

@Uxio0

Copy link
Copy Markdown
Member

Closes PLA-2321

Ganache is not maintained. safe-eth-py and safe-transaction-service already run their tests on anvil, this PR does the same for safe-cli.

Changes

Test node

  • docker compose, CI and run_tests.sh use anvil (ghcr.io/foundry-rs/foundry:v1.9.0) instead of ganache. Same setup as safe-transaction-service: the ganache -d mnemonic, chain id 1337, 10 accounts and gas limit 200M. Test keys and addresses do not change.
  • CI starts anvil with docker compose --profile develop up --detach --wait anvil, so CI and local tests use the same node. CI used 30 accounts before, no test needs more than 10.
  • Bump safe-eth-py to 7.29.1.
  • Tests read the node URL from the configuration (ETHEREUM_NODE_URL) instead of a hardcoded localhost:8545.
  • run_tests.sh: fix the shebang, use uv with the lockfile, return the pytest exit code and always stop the containers.
  • Ledger test_execute used nonce 0, which only works on a fresh chain. It now uses the real account nonce and waits for the receipt (anvil returns the tx hash before the block is mined).

CLI fixes found by running on anvil

  • drain: get_erc_20_list asked for logs past the requested block range (up to block 500000 on a chain at block 87). Anvil rejects it. Each log range now ends at the requested to_block.
  • Interactive prompt: node and connection errors (Web3RPCError, ContractLogicError, TimeExhausted, ProviderConnectionError, requests errors) are printed and the session keeps running. Before, the session crashed with a traceback. Switching mode (blockchain / tx-service) only happens, and prints its message, after the Safe info is loaded.

Testing

  • Full suite on a fresh anvil: 86 passed, 1 skipped (needs ETHEREUM_MAINNET_NODE).
  • Manual run against anvil: safe-creator, safe-cli send-ether, drain in the interactive prompt, and a node error in the prompt (session keeps running).

Not in this PR

  • drain reads logs from block 1 in steps of 500000 blocks. Many public RPC providers reject ranges that big, so drain can still fail on mainnet. This existed before.
  • Node errors in the one-shot typer commands (for example safe-cli send-ether) still end with a traceback and a non-zero exit code.

- Replace ganache with anvil in docker compose, CI and run_tests.sh.
  Same mnemonic and chain id 1337, so test accounts do not change.
- CI starts anvil with the compose service, so CI and local tests use
  the same node setup.
- Bump safe-eth-py to 7.29.1.
- Fix drain: get_erc_20_list asked for logs past the requested block
  range, which anvil rejects.
- Node and connection errors in the interactive prompt are printed and
  the session keeps running. Switching mode only happens after the Safe
  info is loaded.
- Tests read the node URL from the configuration instead of a hardcoded
  localhost:8545.
- run_tests.sh uses uv with the lockfile, returns the pytest exit code
  and always stops the containers.
@Uxio0
Uxío (Uxio0) force-pushed the uxio/pla-2321-cli-run-the-test-suite-on-anvil-instead-of branch from 4b88eb3 to de5c20a Compare November 9, 2026 15:46
@Uxio0
Uxío (Uxio0) marked this pull request as ready for review November 9, 2026 15:49
@Uxio0
Uxío (Uxio0) requested a review from a team as a code owner November 9, 2026 15:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T15:51:53.970262Z de5c20a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de5c20a26f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread docker-compose.yml Resolved
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.

1 participant