-
Notifications
You must be signed in to change notification settings - Fork 2
Add mock collector #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds a mock collector service for local development and testing of the gas agent. It introduces a new workspace structure, exposes AgentPayload as a library type, and provides a lightweight HTTP server for receiving agent submissions.
Changes:
- Created a workspace with the main package and a new
mock-collectorcrate - Added
src/lib.rsto exposeAgentPayloadfrom the agent as a library - Added
#[allow(dead_code)]toto_block_time()since it's only used by the binary
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Cargo.toml | Workspace configuration adding mock-collector as a member |
| Cargo.lock | Dependency updates for axum and related crates |
| src/lib.rs | New library target exposing AgentPayload type |
| src/types.rs | Added dead_code annotation to to_block_time() |
| crates/mock-collector/Cargo.toml | Dependencies for mock collector service |
| crates/mock-collector/src/main.rs | HTTP server implementation for receiving and logging agent submissions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mod chain; | ||
| mod types; | ||
|
|
||
| pub use types::AgentPayload; |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The library exports only AgentPayload, but this struct has public fields of types Settlement, System, Network, and PriceUnit. These types must also be exported from the library for consumers (like the mock-collector) to deserialize AgentPayload instances. Without these exports, the mock-collector won't be able to compile and use the AgentPayload type properly.
| pub use types::AgentPayload; | |
| pub use types::{AgentPayload, Settlement, System, Network, PriceUnit}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lnbc1QWFyb24 The collector seems to work without these since it only imports AgentPayload. Is the collector able to use those elements of the payload because it's just treating them as strings written to console?
info!("System: {:?}", submission.payload.system);
info!("Network: {:?}", submission.payload.network);
info!("From Block: {}", submission.payload.from_block);
info!("Settlement: {:?}", submission.payload.settlement);
info!(
"Price: {} {:?}",
submission.payload.price, submission.payload.unit
);
info!("Timestamp: {}", submission.payload.timestamp);
info!("Schema Version: {}", submission.payload.schema_version);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this co-pilot recommendation does not make a lot of sense in this context. If you needed to create an AgentPayload then you would need those enums, but since you are just logging public fields on the struct it is fine as it is.
Add Mock Collector
Adds a mock collector service for local development and testing of the gas agent.
Changes
New crate:
mock-collector- A lightweight HTTP server that receives and logs agent submissions atPOST /v0/agents. Useful for testing the agent without connecting to a real collector.New library target - Exposes
AgentPayloadfromsrc/lib.rsso the mock-collector (and other crates) can deserialize agent submissions.Additional Changes
Fixed test compilation - Tests in
src/chain/encode.rspreviously relied oncrate::logs::init_logs()which isn't available from the library crate root. Replaced with a self-contained test logger usingtracing_subscriber::fmt().with_test_writer().Suppressed dead code warnings - Added
#[allow(dead_code)]toModelKind,AgentKind, andSystemNetworkKey::to_block_time()since these are only used by the binary, not the library.Usage