Skip to content

test(canton): golden-test EVM transaction encoding against viem #773

@Pessina

Description

@Pessina

Follow-up from PR #740.

Code:

  • /// TODO(test): golden-test against viem's `serializeTransaction` with known
    /// EvmTransactionParams. Verify the output matches byte-for-byte — this is
    /// what gets hashed and signed, so any divergence breaks on-chain verification.
    fn encode_unsigned_eip1559(params: &CantonEvmTransactionParams) -> anyhow::Result<Vec<u8>> {
  • // TODO(test): golden-test build_calldata against viem's encodeFunctionData for:
    // - ERC20 transfer/approve (static types)
    // - Uniswap exactInputSingle with tuple arg
    // - Functions with dynamic types (string, bytes, address[])
    // - Empty-args view functions (totalSupply)
    // - Invalid signature rejection, invalid hex rejection

Context: encode_unsigned_eip1559 produces the bytes that are hashed and signed for Canton bidirectional EVM transactions. Add golden tests against viem for full unsigned EIP-1559 serialization and for the calldata path used by contract calls.

Coverage to include:

  • serializeTransaction with known EvmTransactionParams, verified byte-for-byte
  • encodeFunctionData parity for ERC20 transfer/approve, tuple args, dynamic types, and empty-arg view functions
  • invalid function signature rejection and invalid hex rejection

This absorbs #769 so the viem parity coverage is tracked in one issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions