Documentation
¶
Overview ¶
Package nmaptest measures network map generation on the dedicated store path against committed expectations. A case stands in for the store load with a NetworkMapData fixture — the value NetworkMapDBStoreImpl returns for one account — then runs the production per-peer pipeline the controller uses, PeersCustomZone → GetPeerNetworkMapComponents → proto conversion, in both wire shapes: the full map (grpc.ToSyncResponse) and the component envelope expanded client-side (grpc.ToComponentSyncResponse → networkmap.EnvelopeToNetworkMap). A third mode inverts the fixture back into the Account it stands for and runs main's frozen path over it (legacynmap), so every case is pinned to what main shipped as well.
The expectation files are the point of the framework. They state what the output should be, so a failing case means the code disagrees with the expectation and the answer is normally to fix the code; an expectation changes only through a deliberate reviewed edit. Nothing in this package writes to testdata — there is no flag that records current behaviour into an expectation, because that is how a defect becomes the baseline. Cases whose expectation encodes correct behaviour the code does not yet deliver stay red on purpose.
A case lives in testdata/cases/<name>/ as case.json (manifest: description, peers, optional accountID, dnsDomain, modes), nmdata.json (the fixture the mocked store returns, using Go field names; zero values may be omitted and applyFixtureDefaults fills the boilerplate) and golden/<peerID>.json.
There is ONE expectation per peer, shared by every mode, because all three must arrive at the same client-facing map. Full and envelope are not even different computations — CalculateNetworkMapFromComponents is components.Calculate and both assemble the proto with the same encode helpers — so the only variable between them is what the envelope round-trip did in transit, and a difference there is a round-trip fidelity defect. Legacy is a different computation, main's, reached from a rebuilt account; a difference there is this tree having drifted from what main shipped. Results are canonicalized before comparison, since repeated proto fields come from map iteration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadNetworkMapData ¶
func LoadNetworkMapData(path string) (*networkmap.NetworkMapData, error)
LoadNetworkMapData reads a fixture holding the NetworkMapData the store would return for one account. Unknown fields are rejected so fixture typos fail loudly instead of silently testing a default.
func RunCase ¶
RunCase computes each target peer's network map through every enabled mode and compares the canonicalized result against the peer's expectation file. It mirrors the controller's store path: fill fixture defaults, precompute posture validation once, then run the per-peer pipeline.
func RunGoldenDir ¶
RunGoldenDir discovers and runs every fixture case under dir. A case is a directory containing case.json (manifest), nmdata.json (store fixture) and golden/<peerID>.json (expected proto.NetworkMap, protojson).
Types ¶
type Case ¶
type Case struct {
Name string
AccountID string
DNSDomain string
Peers []string
Modes []Mode
Data *networkmap.NetworkMapData
GoldenDir string
}
Case is one nmap-generation scenario: store data for a single account, the peers whose network maps are computed, and the directory holding one expected *proto.NetworkMap per peer — shared by every mode.
type Mode ¶
type Mode string
Mode selects the wire shape a case is verified through. Both end in a *proto.NetworkMap, the one comparison surface shared by every path.
const ( // ModeFull is the legacy wire shape: the server runs Calculate and sends // the expanded map (grpc.ToSyncResponse). ModeFull Mode = "full" // ModeEnvelope is the component wire shape: the server encodes components // into a NetworkMapEnvelope (grpc.ToComponentSyncResponse) and the map is // expanded the way the client engine does (networkmap.EnvelopeToNetworkMap). ModeEnvelope Mode = "envelope" // ModeLegacy is main's frozen path: the fixture is inverted back into the // Account it stands for and run through legacynmap, the copy of what main // shipped. It is the outside measurement — the other two modes share this // tree's computation, so only this one can catch the whole tree drifting. ModeLegacy Mode = "legacy" )