Skip to content

Vk/fee4 make cli tests p#760

Open
pahor167 wants to merge 27 commits intomasterfrom
vk/fee4-make-cli-tests-p
Open

Vk/fee4 make cli tests p#760
pahor167 wants to merge 27 commits intomasterfrom
vk/fee4-make-cli-tests-p

Conversation

@pahor167
Copy link
Contributor

@pahor167 pahor167 commented Feb 9, 2026

Description

Tell us why these changes are being made

Other changes

Describe any minor or "drive-by" changes here. If none delete this section

Tested

An explanation of how the changes were tested or an explanation as to why they don't need to be.

How to QA

List of steps required to QA the change if applicable

Related issues

  • Fixes #[issue number here]

PR-Codex overview

This PR focuses on removing dependencies on web3 and updating tests to use a new client parameter instead. It also includes various adjustments to improve code consistency and functionality across multiple files.

Detailed summary

  • Deleted test files related to rpc-wallet.
  • Updated gasLimit, startTimeout, and stopTimeout in anvil-test.ts.
  • Adjusted package dependencies to remove web3 and replace it with client.
  • Modified test functions to use client instead of web3.
  • Replaced Web3.utils.toWei with direct value strings in several tests.
  • Enhanced Accounts wrapper tests to utilize client for account retrieval.
  • Refactored signature handling to eliminate reliance on web3.
  • Improved contract interaction methods to use client for consistency.

The following files were skipped due to too many changes: packages/cli/src/commands/governance/hashhotfix.test.ts, packages/cli/src/commands/validatorgroup/list.test.ts, packages/cli/src/test-utils/chain-setup.ts, packages/sdk/contractkit/src/wrappers/BaseWrapper.test.ts, packages/sdk/utils/src/signatureUtils.ts, packages/sdk/contractkit/src/kit.ts, packages/cli/src/commands/validatorgroup/reset-slashing-multiplier.test.ts, packages/dev-utils/src/ganache-test.ts, packages/cli/src/commands/lockedcelo/revoke-delegate.test.ts, packages/cli/src/commands/transfer/stable.test.ts, packages/cli/src/commands/epochs/send-validator-payment.test.ts, packages/cli/src/commands/validator/list.test.ts, packages/cli/src/commands/network/info.test.ts, packages/cli/src/commands/releasecelo/set-max-distribution.test.ts, packages/cli/src/commands/account/deauthorize.test.ts, packages/cli/src/commands/transfer/euros.test.ts, packages/cli/src/commands/epochs/start.test.ts, packages/cli/src/commands/account/set-name.test.ts, packages/cli/src/commands/account/balance.test.ts, packages/cli/src/commands/transfer/reals.test.ts, packages/cli/src/commands/governance/revokeupvote.test.ts, packages/cli/src/commands/governance/show.test.ts, packages/cli/src/commands/validator/register-L2.test.ts, packages/cli/src/commands/releasecelo/set-can-expire.test.ts, packages/cli/src/commands/releasecelo/locked-gold.test.ts, packages/cli/src/commands/election/current.test.ts, packages/cli/src/test-utils/cliUtils.ts, packages/cli/src/base.ts, packages/sdk/contractkit/src/kit.test.ts, packages/cli/src/commands/epochs/finish.test.ts, packages/sdk/wallets/wallet-ledger/src/ledger-wallet.test.ts, packages/sdk/contractkit/src/wrappers/Reserve.test.ts, packages/cli/src/commands/validator/deaffilliate.test.ts, packages/sdk/contractkit/src/wrappers/Validators.test.ts, packages/cli/src/commands/releasecelo/set-account.test.ts, packages/cli/src/commands/epochs/status.test.ts, packages/cli/src/commands/governance/vote.test.ts, packages/cli/src/commands/validatorgroup/commission.test.ts, packages/cli/src/commands/transfer/erc20.test.ts, packages/cli/src/commands/governance/votePartially.test.ts, packages/cli/src/commands/validator/status.test.ts, packages/cli/src/commands/governance/preparehotfix.test.ts, packages/cli/src/commands/validator/affilliate.test.ts, packages/cli/src/commands/lockedcelo/unlock.test.ts, packages/cli/src/commands/multisig/propose.test.ts, packages/sdk/contractkit/src/wrappers/Election.test.ts, packages/cli/src/commands/lockedcelo/lock.test.ts, packages/sdk/contractkit/src/wrappers/Escrow.test.ts, packages/cli/src/commands/validatorgroup/rpc-urls.test.ts, packages/cli/src/commands/transfer/dollars.test.ts, packages/cli/src/commands/validatorgroup/member.test.ts, packages/cli/src/commands/releasecelo/set-beneficiary.test.ts, packages/cli/src/commands/governance/upvote.test.ts, packages/sdk/connect/src/utils/tx-result.ts, packages/cli/src/commands/epochs/switch.test.ts, packages/sdk/utils/src/solidity.ts, packages/cli/src/commands/releasecelo/refund-and-finalize.test.ts, packages/cli/src/commands/governance/execute.test.ts, packages/cli/src/commands/election/vote.test.ts, packages/cli/src/commands/governance/dequeue.test.ts, packages/cli/src/commands/epochs/process-groups.test.ts, packages/cli/src/commands/multisig/approve.test.ts, packages/sdk/wallets/wallet-base/src/signing-utils.test.ts, packages/dev-utils/src/anvil-test.ts, packages/cli/src/commands/multisig/transfer.test.ts, packages/cli/src/commands/election/revoke.test.ts, packages/sdk/wallets/wallet-local/src/signing.test.ts, packages/cli/src/commands/account/claims.test.ts, packages/sdk/contractkit/src/wrappers/SortedOracles.test.ts, packages/sdk/contractkit/src/setupForKits.ts, packages/cli/src/commands/validatorgroup/deregister.test.ts, packages/cli/src/commands/rewards/show.test.ts, packages/cli/src/commands/multisig/show.test.ts, packages/cli/src/commands/lockedcelo/delegate.test.ts, packages/cli/src/commands/releasecelo/authorize.test.ts, packages/dev-utils/src/test-utils.ts, packages/cli/src/commands/governance/executehotfix.test.ts, packages/sdk/contractkit/src/wrappers/Governance.test.ts, packages/cli/src/commands/releasecelo/transfer-dollars.test.ts, packages/cli/src/commands/releasecelo/withdraw.test.ts, packages/cli/src/commands/election/show.test.ts, packages/cli/src/commands/releasecelo/admin-revoke.test.ts, packages/cli/src/commands/account/new.test.ts, packages/cli/src/commands/validator/deregister.test.ts, packages/cli/src/commands/governance/withdraw.test.ts, packages/sdk/connect/src/types.ts, packages/sdk/contractkit/src/wrappers/EpochManager.test.ts, packages/cli/src/base.test.ts, packages/cli/src/commands/account/authorize.test.ts, packages/cli/src/commands/election/activate.test.ts, packages/cli/src/commands/transfer/celo.test.ts, packages/cli/src/commands/governance/propose.test.ts, packages/cli/src/commands/governance/approve.test.ts, packages/sdk/connect/src/connection.ts, yarn.lock

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Pavel Hornak and others added 14 commits February 8, 2026 00:23
Use block timestamp instead of Date.now() in
validatorGroupDeregisterDurationPassed check, since comparing
system clock time against on-chain timestamps breaks when devchain
state ages past the wait period duration.

Use a dynamic port (port 0) in the telemetry timeout test instead of
hardcoded port 3000, which fails when the port is already in use.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…n tool replacing the VS Code extensions recommendations). It's not from my work. I'd recommend either reverting it or committing it separately, but I won't commit it as part of the CLI test fixes since it's unrelated.

Would you like me to revert this file, or leave it as-is?
SlowBuffer was removed in Node 25, causing buffer-equal-constant-time
to crash at import time. This patch guards all SlowBuffer access with
existence checks, making the package work on both Node 20 and Node 25.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…llel execution

The @viem/anvil library defaults to a 10s startTimeout, which is
insufficient when many Anvil instances start concurrently (e.g. when
running yarn test from the repo root). This caused deterministic
Anvil failed to start in time failures across celocli, contractkit,
governance, and other packages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 1 - @celo/utils:
- Replace web3-utils imports with viem equivalents
- Replace web3-eth-abi with viem encodeAbiParameters
- Remove web3-utils and web3-eth-abi deps, add viem

Phase 2 - @celo/connect:
- Replace Web3 constructor with Provider interface
- Define standalone types for CeloTx, CeloTxReceipt, etc.
- Replace web3.eth.* calls with direct RPC calls
- Implement viemAbiCoder to replace web3.eth.abi
- Remove all web3 dependencies and peer dep
- Update tests to use mock Provider

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a web3-compatible shim layer on Connection class so that existing
code using connection.web3.eth.Contract, connection.web3.utils, etc.
continues to work after web3 was removed from @celo/connect. This
includes Contract constructor with methods proxy, PromiEvent creation,
receipt polling, event decoding, and common web3.utils functions.

Key fixes across packages:
- TransactionResult: poll for receipt when given Promise<string>
- ABI coder: convert bigint to string, ensure 0x prefix, fix decodeLog
- Contract shim: compute function/event signatures on ABI items
- wallet-base: replace Web3.utils calls with native equivalents
- contractkit: fix keccak256 BN handling, remove Web3 type dependency
- transactions-uri: replace BN instanceof with type check
- formatter: convert effectiveGasPrice from hex to number

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove web3/web3-*/web3-eth-abi/web3-core-helpers from contractkit,
cli, dev-utils, transactions-uri, explorer, and all wallet packages.

Production code changes:
- contractkit/setupForKits.ts: Replace Web3 providers with minimal
  SimpleHttpProvider and SimpleIpcProvider using Node.js http/https/net
- contractkit/kit.ts, mini-kit.ts, proxy.ts: Remove Web3 type imports
- cli/base.ts: Use getWeb3ForKit instead of new Web3(), return
  kit.web3 (shim) from getWeb3() for full API compatibility
- cli/utils/safe.ts, commands/governance/approve.ts: Remove Web3 types
- dev-utils/test-utils.ts: Inline SimpleHttpProvider, use Connection
- dev-utils/anvil-test.ts, chain-setup.ts, contracts.ts: Remove Web3
- transactions-uri/tx-uri.ts: Use viemAbiCoder from @celo/connect

Web3 shim enhancements (connection.ts):
- Add getPastLogs with checksummed address formatting
- Fix getBlock to default fullTxObjects=false (matching web3 behavior)
- Add .host property to SimpleHttpProvider for backward compat

Test file changes (~100 files):
- Remove all `import Web3 from 'web3'` statements
- Replace `web3: Web3` type annotations with `web3: any`
- Replace Web3.utils.toWei with parseEther or inlined values
- Replace Web3.utils.toBN with BigInt
- Replace new Web3() with Connection or kit helpers

Package.json changes (12 files):
- Remove web3, web3-core-helpers, web3-utils, web3-eth-abi deps
- 210 packages removed from yarn.lock

All 98 CLI test suites pass (337 tests), all 57 connect tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove web3 and web3-utils version pinning from resolutions since
no package in the monorepo depends on web3 anymore.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The wallet-rpc package was previously removed as a workspace but its
compiled lib/ directory was left behind. It has no package.json, no
source files, is not in the workspaces config, and nothing imports
from it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove only the compiled test files (rpc-wallet.test.js and
test-utils/ganache.*) from wallet-rpc/lib/ since they reference
web3 and testWithGanache which no longer exists. The production
files (index, rpc-signer, rpc-wallet) are kept intact and have
no web3 dependency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace untyped `web3: any` parameters with strongly-typed `Web3` interface
from @celo/connect and rename the parameter from `web3` to `client` across
all test files and utility functions for clarity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pahor167 pahor167 requested a review from a team as a code owner February 9, 2026 16:35
@changeset-bot
Copy link

changeset-bot bot commented Feb 9, 2026

⚠️ No Changeset found

Latest commit: 80416a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Pavel Hornak and others added 3 commits February 9, 2026 16:49
Conflicts resolved:
- approve.test.ts/approve.ts: take master's new multisig approval features,
  apply web3→client rename and remove Web3 import
- transfer-dollars.test.ts: take master's cUSD→USDm rename, keep client param
- checks.ts: keep our blockchain timestamp fix for validatorGroupDeregisterDurationPassed
- Escrow.test.ts: take master's cUSD→USDm rename, keep client param
- SortedOracles.test.ts: take master's cUSD→USDm/cEUR→EURm/cREAL→BRLm, keep client param
- yarn.lock: regenerated from master's lockfile
- contracts.ts: apply web3→client rename (missed in prior commit)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix deploy().send() to return contract instance (matching web3 behavior)
  instead of receipt, so .options.address works for contract deployment
- Add eth.accounts.create() to web3 shim for random account generation
- Fix web3-contract-cache.test.ts import path (was incorrectly renamed)
- Fix SortedOracles.test.ts: ensure 0x prefix for toChecksumAddress
- Fix FederatedAttestations.test.ts: cast eth.accounts access

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 15.26587% with 494 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.68%. Comparing base (a695c5c) to head (80416a0).

❌ Your patch check has failed because the patch coverage (15.26%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #760      +/-   ##
==========================================
- Coverage   69.61%   65.68%   -3.94%     
==========================================
  Files         150      151       +1     
  Lines        7075     7570     +495     
  Branches     1144     1250     +106     
==========================================
+ Hits         4925     4972      +47     
- Misses       2085     2532     +447     
- Partials       65       66       +1     
Components Coverage Δ
celocli ∅ <ø> (∅)
sdk 63.73% <14.82%> (-5.39%) ⬇️
wallets 73.10% <100.00%> (-0.05%) ⬇️
viem-sdks 94.15% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Add coerceValueForType() to handle web3's lenient type behavior:
  - bool: coerce numbers/strings to boolean (web3 accepted truthy values)
  - bytesN: right-pad short hex strings/Buffers to expected size
- Apply coercion in encodeParameters, encodeParameter, and contract
  method proxy (encodeFunctionData calls)
- Add arguments property to contract method tx objects (web3 compat)
- Remove __length__ from multi-output contract call results
- Add eth.accounts.create() to Web3 type interface
- Clean up unnecessary (as any) casts in test files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

size-limit report 📦

Path Size
require('@celo/actions') (cjs) 98.85 KB (0%)
import * from '@celo/actions' (esm) 23.55 KB (0%)
import { resolveAddress } from '@celo/actions' (esm) 23.49 KB (0%)
import { getGasPriceOnCelo } from '@celo/actions' (esm) 73 B (0%)
import { getAccountsContract } from '@celo/actions/contracts/accounts' (esm) 46.11 KB (0%)
import * from '@celo/actions/staking' (esm) 50.66 KB (0%)

Pavel Hornak and others added 8 commits February 9, 2026 17:54
- Add eth.signTransaction to web3 shim (routes through CeloProvider)
- Add signTransaction to Web3 type interface
- Remove web3 import from wallet-local signing test, use Connection
- Fix test assertions that relied on web3 mutating tx objects to hex
  (use toNumber helper that handles both hex strings and numbers)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes biome lint/complexity/useLiteralKeys errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove @celo/abis/web3/ICeloVersionedContract import from BaseWrapper.ts
  (the .d.ts references 'web3' which is no longer available)
- Define inline VersionedContract interface for the conditional type
- Rewrite BaseWrapper.test.ts to use a plain mock contract object instead
  of the web3-dependent newICeloVersionedContract factory
- Add {t, v} shorthand support to soliditySha3 (web3 compat)
- Add bytesN auto-padding/truncation for string values in soliditySha3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Transaction

- hashMessage was using viem's toBytes() which decodes hex strings as bytes,
  but web3's soliditySha3({type:'string'}) always treated input as UTF-8.
  Use stringToBytes() instead to match the original behavior.
- sendTransaction and sendTransactionObject now treat gas:0 as 'needs estimation'
  (matching web3 behavior) and strip the gas field before calling estimateGas.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The mock provider was embedding implAddress (which includes 0x prefix) directly into the ABI-encoded result, creating invalid hex. Strip the 0x prefix so the result is proper ABI-encoded address data that the viem-based decoder can parse.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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