Skip to content

test: add integration test for RPC hook accumulation #458

@niran

Description

@niran

Background

PR #446 fixed the RPC extension hook accumulation issue (#438), but the integration test that verified the fix was removed to avoid a circular dependency between base-client-node and base-metering/base-txpool.

Test to add

The test should verify that multiple RPC-providing extensions are all accessible when installed together:

#[tokio::test(flavor = "multi_thread")]
async fn rpc_hooks_accumulate_across_extensions() -> Result<()> {
    let chain_spec = load_chain_spec();

    // Install multiple RPC-providing extensions
    let mut extensions: Vec<Box<dyn BaseNodeExtension>> = Vec::new();
    extensions.push(Box::new(TxPoolExtension::new(TxpoolConfig {
        tracing_enabled: false,
        tracing_logs_enabled: false,
        sequencer_rpc: None,
    })));
    extensions.push(Box::new(MeteringExtension::new(true, None)));

    let node = LocalNode::new(extensions, Arc::clone(&chain_spec)).await?;

    let client = HttpClientBuilder::default().build(format!("http://{}", node.http_addr()))?;

    // TxPool RPC should be reachable
    let status: TransactionStatusResponse = client
        .request("base_transactionStatus", rpc_params![TxHash::ZERO])
        .await?;
    assert_eq!(Status::Unknown, status.status);

    // Metering RPC should also be reachable
    let meter_result = client
        .request::<serde_json::Value, _>("base_meterBlockByNumber", rpc_params!["latest"])
        .await;
    match meter_result {
        Ok(_) => {}
        Err(ClientError::Call(err)) => {
            assert_ne!(err.code(), ErrorCode::MethodNotFound.code(), "metering RPC missing");
        }
        Err(err) => panic!("unexpected error from metering RPC: {err}"),
    }

    Ok(())
}

Options for location

  1. Add to system test framework
  2. Create a top-level client integration test crate (e.g., crates/client/tests)
  3. Add tests within bin/ crates

Related

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