Skip to content

[executor] No fork test for simulate() — simulation gate correctness against real contract state unverified #167

@obchain

Description

@obchain

PR: #41 (feat/executor: transaction builder + eth_call simulator)
File: crates/charon-executor/src/simulation.rs
Refs #41

Problem

CLAUDE.md safety invariant: "every liquidation transaction passes an eth_call simulation gate before broadcast."

simulation.rs contains one test: simulator_holds_addresses, which asserts that two addresses are stored in a struct. It does not call simulate() at all. There is no test that:

  1. Runs simulate() with valid liquidation calldata against a BSC fork — expecting Ok.
  2. Runs simulate() with invalid calldata (wrong protocolId, zero repay) — expecting Err.
  3. Verifies that an onlyOwner revert is correctly surfaced when sender != owner.
  4. Verifies that the gas_limit forwarding (once fixed per the companion issue) gates OOG scenarios.

Without these tests, the gate is structurally present but its correctness against real-world revert conditions is entirely unverified.

Fix

Add fork tests gated behind BSC_FORK_URL env var, following the pattern in crates/charon-protocols/tests/venus_live.rs:

#[tokio::test]
#[ignore = "requires BSC_FORK_URL"]
async fn simulate_valid_liquidation_succeeds() { ... }

#[tokio::test]
#[ignore = "requires BSC_FORK_URL"]
async fn simulate_wrong_sender_fails_onlyowner() { ... }

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p2-polishNice-to-have / polishstatus:readyScoped and ready to pick uptype:testTests, fuzz, fork, integration

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions