conformance

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2026 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package conformance holds JSON-RPC 2.0 wire vectors shared across the jsonrpc2 test suite. Keeping them in one place lets the encode, decode, and fuzz tests agree on a single corpus of canonical and adversarial inputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind uint8

Kind classifies the expected role of a vector after decoding.

const (
	// KindInvalid marks an input that a strict single-message decode rejects.
	KindInvalid Kind = iota
	// KindCall marks a request that expects a response (has method and id).
	KindCall
	// KindNotification marks a request with no id.
	KindNotification
	// KindResponseResult marks a successful response (has result).
	KindResponseResult
	// KindResponseError marks an error response (has error).
	KindResponseError
)

The recognized vector kinds.

type Vector

type Vector struct {
	// Name identifies the case using the "success:"/"error:" convention shared
	// by the test suite.
	Name string
	// Wire is the raw JSON bytes of the message.
	Wire string
	// Kind is the expected classification of Wire on a strict decode.
	Kind Kind
	// Method is the expected method name for request kinds.
	Method string
	// Params is the expected raw params for request kinds ("" means absent).
	Params string
	// Result is the expected raw result for result responses ("" means absent).
	Result string
	// ErrCode is the expected error code for error responses.
	ErrCode int32
}

Vector is a single JSON-RPC 2.0 conformance case.

func Invalid

func Invalid() []Vector

Invalid returns inputs that a strict single-message decode must reject.

func Valid

func Valid() []Vector

Valid returns the vectors that a strict single-message decode must accept and classify, including the two pinned specification traps:

  • a Response with "id":null is distinct from a notification that omits "id";
  • "result":null is a valid success result, distinct from result absent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL