Skip to content

[executor] no integration test for fetch_params against real BSC RPC — null baseFee risk unverified #191

@obchain

Description

@obchain

Summary

All three unit tests in gas.rs test pure functions (gas_cost_usd_cents, edge-case arithmetic, overflow saturation). No test calls fetch_params against a live or fork BSC provider to verify:

  1. baseFeePerGas is non-null in a real BSC block response from the configured RPC endpoints
  2. The computed max_fee_per_gas is within a sane range (e.g. 1-100 gwei)
  3. The priority_fee_gwei conversion produces the correct wei value in the returned GasParams

Given that the null-baseFee failure mode (Issue 2 in this review) exists and causes a complete gas oracle halt, the absence of a live test means the guard is unverified against the actual BSC RPC infrastructure the bot will use in production.

File

crates/charon-executor/src/gas.rs

Fix

Add an #[ignore] integration test, skipped in standard CI but runnable manually and in the BSC fork environment:

#[tokio::test]
#[ignore = "requires live BNB_HTTP_URL env var"]
async fn fetch_params_returns_sane_values_on_bsc() {
    let url = std::env::var("BNB_HTTP_URL")
        .expect("BNB_HTTP_URL must be set to run this test");
    let provider = ProviderBuilder::new().on_http(url.parse().unwrap());
    let cfg = /* minimal config with max_gas_gwei = 100 */;
    let oracle = GasOracle::new(&cfg);
    let result = oracle.fetch_params(&provider, 0).await.unwrap();
    let GasDecision::Proceed(params) = result else {
        panic!("ceiling hit unexpectedly with gwei ceiling = 100");
    };
    assert!(params.max_fee_per_gas >= U256::from(1_000_000_000u64), "max_fee below 1 gwei");
    assert!(params.max_fee_per_gas <= U256::from(100_000_000_000u64), "max_fee above 100 gwei");
    assert!(params.max_priority_fee >= U256::from(1_000_000_000u64), "priority fee below 1 gwei");
}

Refs #43

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