Skip to content

🧪 [testing improvement] tracker telemetry snapshot mapping#11

Draft
tcrypt25519 wants to merge 2 commits intomasterfrom
testing-improvement-telemetry-snapshot-16709284375591940968
Draft

🧪 [testing improvement] tracker telemetry snapshot mapping#11
tcrypt25519 wants to merge 2 commits intomasterfrom
testing-improvement-telemetry-snapshot-16709284375591940968

Conversation

@tcrypt25519
Copy link
Copy Markdown
Owner

🎯 What: The testing gap addressed

Untested mapping of RuntimeTelemetry (atomic values) to TrackerTelemetrySnapshot in TrackerTelemetry::snapshot().

📊 Coverage: What scenarios are now tested

  • Correct mapping of TransportKind.
  • Correct retrieval and mapping of atomic u64 and usize values:
    • pending_seen
    • block_count
    • last_block_txs
    • last_block_gas_used
    • initial_backfill_txs
    • p2p_peer_count
    • p2p_announced_txs
    • p2p_imported_txs

Result: The improvement in test coverage

Ensures that telemetry data collected during the tracker runtime is accurately reported to consumers of the snapshot API, preventing future regressions in data reporting.


PR created automatically by Jules for task 16709284375591940968 started by @tcrypt25519

This commit adds a unit test in `crates/mempooloracle/src/runtime.rs` to verify that
atomic telemetry values in `RuntimeTelemetry` are correctly mapped to
`TrackerTelemetrySnapshot` when `TrackerTelemetry::snapshot()` is called.

The test covers:
- Transport kind mapping
- Atomic counters for pending transactions and blocks
- Values recorded via record_backfill_size, record_block, and P2P-specific methods.
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented Apr 20, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  crates/mempooloracle/examples/cli_tool.rs  100% smaller
  crates/mempooloracle/src/transport/p2p.rs  95% smaller
  crates/mempooloracle/src/lib.rs  79% smaller
  crates/bulkmail/src/adapter/solana.rs  67% smaller
  crates/mempooloracle/src/runtime.rs  0% smaller

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a unit test for telemetry snapshots in crates/mempooloracle/src/runtime.rs. A compilation error was identified in the new test because it attempts to access the private inner field of TrackerTelemetry from within a submodule.

Comment on lines +150 to +181
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_telemetry_snapshot() {
let telemetry = Arc::new(RuntimeTelemetry::new(TransportKind::P2p));
let tracker_telemetry = TrackerTelemetry {
inner: telemetry.clone(),
};

telemetry.record_backfill_size(100);
telemetry.record_pending_seen();
telemetry.record_pending_seen();
telemetry.record_block(50, 1000);
telemetry.record_p2p_peer_count(5);
telemetry.record_p2p_announcement();
telemetry.record_p2p_announcement();
telemetry.record_p2p_announcement();
telemetry.record_p2p_import();

let snapshot = tracker_telemetry.snapshot();

assert_eq!(snapshot.transport_kind, TransportKind::P2p);
assert_eq!(snapshot.pending_seen, 2);
assert_eq!(snapshot.block_count, 1);
assert_eq!(snapshot.last_block_txs, 50);
assert_eq!(snapshot.last_block_gas_used, 1000);
assert_eq!(snapshot.initial_backfill_txs, 100);
assert_eq!(snapshot.p2p_peer_count, 5);
assert_eq!(snapshot.p2p_announced_txs, 3);
assert_eq!(snapshot.p2p_imported_txs, 1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The test will fail to compile because it attempts to instantiate TrackerTelemetry using its private field inner from within the tests submodule. In Rust, private fields are only accessible within the module where the struct is defined, and submodules are considered separate modules for this purpose. To fix this, you can move the test function out of the mod tests block and place it directly in the parent module, which allows it to access the private field. Alternatively, you could change the visibility of the inner field to pub(crate) in its definition.

References
  1. Actionable only. Only leave a comment for bugs, vulnerabilities, or major performance issues. (link)
  2. Actionable only. Only leave a comment for bugs, vulnerabilities, or major performance issues.

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