Documentation
¶
Overview ¶
Package conformance checks a peer against SPEC.md. The runner is a scripted peer with a key of its own: it connects to the peer under test (or listens for it), drives each scenario over the wire, checks every line it receives against the JSON Schema, and reports what the peer did.
It is what `awp conform` runs. The reference implementation passes it in its own tests; scripts/conformance.sh runs it against the Python peer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Addr is the peer's address. The runner dials it once per scenario.
Addr string
// Listen is an address (tcp:host:port or unix:/path) to listen on
// instead: the peer dials the runner, and the scenarios that fit one
// connection run in turn on it. Solo scenarios are skipped.
Listen string
// Run is a shell command to start once the runner listens, with
// {addr} replaced by the listening address; it is killed at the end.
Run string
// Only names the scenarios to run; nil runs all of them.
Only []string
// Timeout bounds each wait for the peer; 15 seconds by default.
Timeout time.Duration
// Name is the runner's hello name; "awp-conform" by default.
Name string
// Trace receives every line sent (dir "out") and received ("in").
Trace func(dir string, line []byte)
// Logf receives progress; nil discards it.
Logf func(format string, args ...any)
}
Options say which peer to check and how.
type Peer ¶
type Peer struct {
Key string `json:"key"`
Name string `json:"name,omitempty"`
About string `json:"about,omitempty"`
V int `json:"v"`
Caps []string `json:"caps,omitempty"`
}
Peer is what the peer said about itself in hello.
type Report ¶
type Report struct {
Mode string `json:"mode"` // connect or listen
Addr string `json:"addr"`
Peer *Peer `json:"peer,omitempty"`
Results []Result `json:"results"`
Passed int `json:"passed"`
Failed int `json:"failed"`
Skipped int `json:"skipped"`
Duration time.Duration `json:"duration"`
}
Report is the outcome of a run.
type Result ¶
type Result struct {
Name string `json:"name"`
Section string `json:"section"`
Doc string `json:"doc"`
Status string `json:"status"` // pass, fail or skip
Reason string `json:"reason,omitempty"`
Checks []Check `json:"checks,omitempty"`
Lines int `json:"lines"` // lines received from the peer
}
Result is the outcome of one scenario.
type Scenario ¶
type Scenario struct {
Name string
Section string // of SPEC.md
Doc string
// Solo scenarios break the handshake or the connection, so they need
// a connection of their own; in listen mode they are skipped. The
// others run after a completed handshake.
Solo bool
// Handshake marks the scenario that drives the handshake itself: it
// runs first on a connection.
Handshake bool
// Needs is a hello cap the peer must list, or the scenario is skipped.
Needs string
// contains filtered or unexported fields
}
Scenario is one scripted exchange with the peer.