Skip to main content

Crate gluonscan_testing

Crate gluonscan_testing 

Source
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.
ContractSpec
A JSON-authorable contract file ({ "body_contains": "...", "reply": "..." }). Present fields are combined with AND. Use reply inline or reply_path to point at a sibling response file.
MockChainProvider
A ChainProvider mock that replays contracts (matched on method + params) for on-chain reads.
MockClock
A fixed clock, so reads carry a deterministic timestamp in tests.
MockHttp
A Http mock that replays contracts and records the calls it received.

Enums§

Match
A filter over an outgoing request. primary is the URL (HTTP) or the method (RPC); body is the request body (HTTP) or the params (RPC). Compose with Match::all / Match::any_of.

Functions§

load_contracts
Load every *.json contract spec in a directory into contracts.