Skip to content

Add comprehensive test coverage for intent validation#1

Merged
muhammadaus merged 17 commits intomainfrom
test-decoding
Feb 14, 2026
Merged

Add comprehensive test coverage for intent validation#1
muhammadaus merged 17 commits intomainfrom
test-decoding

Conversation

@muhammadaus
Copy link
Copy Markdown
Member

Summary

  • Added 4 new validators to test harness for exact intent validation
  • Updated all 34 tests with comprehensive validation
  • All tests passing (100%)
  • Added GitHub Actions CI/CD workflow

Validators Added

  1. Exact intent matching (expected.intent) - Validates full intent text, not just substrings
  2. Negative validation (expected.intentDoesNotContain) - Ensures raw values like max uint256 don't appear
  3. Command array validation (expected.decodedCommands) - Validates Uniswap command opcodes and names
  4. Enhanced nested intents (expected.nestedIntents) - Validates nested operation structures

Test Coverage Improvements

  • Core decode tests: Exact intent + amount validation (12 tests)
  • Uniswap tests: Command registry validation (0x0b, 0x00 opcodes)
  • AA tests: Nested intent arrays for ERC-4337, EIP-7702, Safe (11 tests)
  • Protocol tests: Exact intents for 1inch, 0x, Aave, Compound, Lido, ParaSwap, CoW, Seaport (9 tests)

Why This Matters

Previous tests used weak substring matching that allowed wrong metadata to pass. For example:

  • Uniswap metadata had command code 0xf0 instead of 0x00
  • Test only checked intentContains: 'Wrap'
  • Test passed even though command decoding was completely broken

Now breaking metadata changes are caught immediately by test failures.

CI/CD Workflow

  • Runs on push to main/test-decoding and PRs to main
  • Tests on Node.js 18.x and 20.x
  • Uploads test artifacts for debugging
  • Note: Requires GitHub secrets to be configured (CURVEGRID_JWT, ETHERSCAN_API_KEY, ALCHEMY_API)

🤖 Generated with Claude Code

muhammadaus and others added 16 commits December 31, 2025 17:09
- Node.js test framework for browser-based decoders
- Tests for core decode.js, recursive-decoder.js, advanced-decoder.js
- Protocol test suites: Uniswap, Aave, Compound, Lido, Seaport, 1inch
- Account abstraction tests: Safe, ERC-4337, EIP-7702
- Local metadata service for offline testing
- Human-readable test output with ANSI colors
- Scripts for fetching real mainnet transactions and metadata

Test coverage:
- 25/28 tests passing (89.3%)
- All Uniswap Universal Router COMMANDS
- EIP-7702 delegation parsing
- Safe multiSend decoding

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Real calldata from tx 0xf82a7507... with executeMultiple
- Contains 2 nested calls: USDC approve + Fluid deposit
- Test validates EIP-7702 type detection and authorization parsing
- All 5 EIP-7702 tests now passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use real authorization list from tx 0xf82a7507...
- Update fetch-transactions to use Alchemy RPC
- Update to Etherscan V2 API format
- 26/29 tests passing (89.7%)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add USDC metadata for selector tests
- Fix test harness to handle expected failures correctly
- All core, protocol, and account abstraction tests passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add {amount} template variables to Aave, Compound, Lido, 1inch, 0x
- Create token-registry.js for symbol/decimals lookup
- Update decode.js substituteIntentTemplate() for nested paths
- Add USDC + Fluid metadata to EIP-7702 test
- All 33 tests passing with formatted values

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add substituteIntentTemplate method to advanced decoder
- Fix decodeParametersWithFieldPaths to handle object results from ABI decoding
- Add formatTokenAmountWithParams for proper decimal formatting
- Include field.params in extractFieldInformation for token decimals/symbol
- All 33 tests passing with formatted values like "Approve 0.05 USDC + Deposit 0.05 to Fluid"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1. Fix BigInt conversion error for unlimited approvals:
   - Detect scientific notation (e.g., "1.157920892373162e+77") before BigInt conversion
   - Detect MAX_UINT256 and return "Unlimited" instead of crashing

2. Fix ParaSwap tuple offset decoding:
   - Update isDynamicType() to check if tuple has dynamic components
   - Add tuple handling to decodeDynamicType() for dynamic tuples
   - Tuples with bytes/arrays/strings are now properly decoded from tail offset

All 33 tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add comprehensive validators to catch metadata errors:
- Exact intent matching (not just substring)
- Negative validation (prevent raw max uint256)
- Command array validation (Uniswap opcodes)
- Enhanced nested intent validation (AA operations)

Updated 34 tests across 14 test files:
- Core decode tests with exact intent + amount validation
- Uniswap tests with command registry validation
- AA tests (ERC-4337, EIP-7702, Safe) with nested intent arrays
- Protocol tests (1inch, 0x, Aave, Compound, Lido, ParaSwap, CoW, Seaport)

All 34 tests passing (100% success rate).

🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Automatically runs tests on:
- Push to main or test-decoding branches
- Pull requests to main

Features:
- Tests on Node.js 18.x and 20.x
- Uploads test artifacts for debugging
- Uses repository secrets for API keys

🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…e symbols

- Fix "Execute 0" bug: Skip value injection when value is zero (decode.js:597-610)
- Fix calleePath resolution: Handle both JSONPath "$.to" and simple field names "to" (recursive-decoder.js:244-254)
- Fix duplicate symbol bug: Detect and strip duplicate token symbols like "USDC USDC" (decode.js:858-870)
- Add Safe execTransaction test with value=0 validation
- Add duplicate symbol test using real USDC fixture
- Add LiFi protocol tests with metadata fixture including calldata field for nested decoding

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add interpolatedIntent detection in format parsing (line 421)
- Add interpolated intent type handling (lines 596-601)
- Update substituteIntentTemplate to support ERC-7730 path syntax:
  - Support #. prefix for parameter paths
  - Support array index notation [0], [1] etc
  - Handle paths like {#._swapData.[0].fromAmount}
- Now displays "Swap 0.20 USDC to ETH" instead of "Swap USDC to ETH"
Per ERC-7730 spec lines 244-249 and 835:
- Wallet MUST locate corresponding field format specification
- Wallet MUST apply field's format and params to format the value
- Wallet MUST replace interpolation expression with formatted value

Implementation:
- substituteInterpolatedIntent(): Main processor per spec requirements
- resolveFieldPath(): Navigate ERC-7730 paths like #._swapData.[0].fromAmount
- applyFieldFormat(): Apply tokenAmount, addressName, etc. formats
- Supports array indices [0], nested tuples, container paths

Now displays "Swap 0.20 USDC to ETH" with actual formatted amounts
- Add KNOWN_TOKENS registry with USDC, USDT, DAI, WETH, WBTC, etc.
- Replace hardcoded USDC with dynamic token lookup
- Support native ETH addresses (0x0, 0xeee...)
- Show shortened address for unknown tokens (0x1234...5678)
- Works for ALL token pairs in registry, not just USDC
- Fix tuple[] dynamic type detection by passing input to isDynamicType()
  - Arrays of tuples with dynamic components (bytes, string) now decode correctly
  - Fixes LiFi swapTokensMultipleV3ERC20ToNative field offset bug
- Remove hardcoded KNOWN_TOKENS registry
- Fetch token metadata from Railway API instead of hardcoded values
- Make applyFieldFormat async for API-based token lookups
- Make substituteInterpolatedIntent async with parallel token fetches
- Handle BigNumber objects from ethers.js in value conversion

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Sync metadata files from Kai-Sign-Builder/backend/metadata:
  - 1inch-router-v6.json: Added tokenAmount format with tokenPath
  - paraswap-augustus-v6.json: Added short tuple signature and interpolatedIntent
  - lifi-diamond.json: Updated to full backend version (3821 lines)
  - cow-protocol-settlement.json: Updated to backend version
  - Safe metadata (singleton, proxy-factory, multisend, proxy): Updated formats
- Add symbol/decimals to tokens/usdc.json for proper token metadata lookup
- Fix LiFi test selector (0xd24c2325 → 0x2c57e884 for swapTokensMultipleV3ERC20ToNative)
- ParaSwap now shows interpolated intent: "Swap 1.00 USDC via ParaSwap"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extension changes:
- Remove duplicate formatTokenAmount from content-script.js (uses decode.js)
- Add rawParams to decoder return object
- UI styling improvements for popup

Metadata updates:
- Add interpolatedIntent to 0x, 1inch, CoW, ParaSwap, LiFi
- Add WETH token metadata
- Update test expectations for new intent formats

Test improvements:
- Add types-advanced.test.js for edge cases
- Expand recursive decoder tests
- Add Uniswap Universal Router tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Selector: 0xe3ead59e
- Signature: swapExactAmountIn(address,tuple,uint256,bytes,bytes)
- Added ABI with tuple components (srcToken, destToken, fromAmount, toAmount, etc.)
- Added display format with interpolatedIntent

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@muhammadaus muhammadaus merged commit e38ad89 into main Feb 14, 2026
4 checks passed
@muhammadaus muhammadaus deleted the test-decoding branch March 2, 2026 22:01
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