Expand description
§gluonscan-testing
Contract-based mock transports. A contract is a recorded pair: a Match (a filter over
the outgoing request) and the response to reply with. You save the contracts (in code or as
JSON files), declare the filters, and get deterministic, offline, testable results — the same
model for HTTP/GraphQL (MockHttp), on-chain RPC (MockChainProvider), and, later, gRPC.
A request that matches no contract is an error, so tests fail loudly on unexpected calls.
use gluonscan_testing::{MockHttp, Match};
let http = MockHttp::new()
.on(Match::body_contains("userSupplies"), r#"{"data":{"userSupplies":[]}}"#);Structs§
- Contract
- A single recorded contract: when the filter matches, reply with
reply. - Contract
Spec - A JSON-authorable contract file (
{ "body_contains": "...", "reply": "..." }). Present fields are combined with AND. Usereplyinline orreply_pathto point at a sibling response file. - Mock
Chain Provider - A
ChainProvidermock that replays contracts (matched on method + params) for on-chain reads. - Mock
Clock - A fixed clock, so reads carry a deterministic timestamp in tests.
- Mock
Http - A
Httpmock that replays contracts and records the calls it received.
Enums§
- Match
- A filter over an outgoing request.
primaryis the URL (HTTP) or the method (RPC);bodyis the request body (HTTP) or the params (RPC). Compose withMatch::all/Match::any_of.
Functions§
- load_
contracts - Load every
*.jsoncontract spec in a directory into contracts.