specs_format

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunSpecs

func RunSpecs(stdout io.Writer, stderr io.Writer, rawSpecs []RawSpec) bool

func ShowDiff

func ShowDiff(w io.Writer, expected_ any, got_ any)

Types

type AssertionMismatch

type AssertionMismatch[T any] struct {
	Assertion string `json:"assertion"`
	Expected  T      `json:"expected,omitempty"`
	Got       T      `json:"got,omitempty"`
}

type ExpectedTxMeta added in v0.0.25

type ExpectedTxMeta []TxMetadataRow

ExpectedTxMeta is a test case's expected transaction metadata: a list of rows, mirroring expect.metadata. Comparison ignores order (see compareTxMeta).

type Movement added in v0.0.25

type Movement struct {
	Source           string   `json:"source"`
	SourceScope      string   `json:"sourceScope,omitempty"`
	Destination      string   `json:"destination"`
	DestinationScope string   `json:"destinationScope,omitempty"`
	Asset            string   `json:"asset"`
	Amount           *big.Int `json:"amount"`
	Color            string   `json:"color,omitempty"`
}

type Movements

type Movements = []Movement

type RawSpec

type RawSpec struct {
	NumscriptPath    string
	SpecsPath        string
	NumscriptContent string
	SpecsFileContent []byte
}

func ReadSpecsFiles

func ReadSpecsFiles(paths []string) ([]RawSpec, error)

type Specs

type Specs struct {
	Schema       string                       `json:"$schema,omitempty"`
	FeatureFlags []string                     `json:"featureFlags,omitempty"`
	Balances     interpreter.Balances         `json:"balances,omitempty"`
	Vars         interpreter.VariablesMap     `json:"variables,omitempty"`
	Meta         interpreter.AccountsMetadata `json:"metadata,omitempty"`
	TestCases    []TestCase                   `json:"testCases,omitempty"`
}

--- Specs:

type SpecsResult

type SpecsResult struct {
	// Invariants: total==passing+failing
	Total   uint `json:"total"`
	Passing uint `json:"passing"`
	Failing uint `json:"failing"`
	Skipped uint `json:"skipped"`
	Cases   []TestCaseResult
}

func Check

type TestCase

type TestCase struct {
	It string `json:"it"`

	// Preconditions
	Balances interpreter.Balances         `json:"balances,omitempty"`
	Vars     interpreter.VariablesMap     `json:"variables,omitempty"`
	Meta     interpreter.AccountsMetadata `json:"metadata,omitempty"`

	// Select tests
	Focus bool `json:"focus,omitempty"`
	Skip  bool `json:"skip,omitempty"`

	// Expectations
	ExpectMissingFunds   bool `json:"expect.error.missingFunds,omitempty"`
	ExpectNegativeAmount bool `json:"expect.error.negativeAmount,omitempty"`

	ExpectPostings           []interpreter.Posting           `json:"expect.postings,omitempty"`
	ExpectTxMeta             ExpectedTxMeta                  `json:"expect.txMetadata,omitempty"`
	ExpectAccountsMeta       interpreter.SetAccountsMetadata `json:"expect.metadata,omitempty"`
	ExpectEndBalances        interpreter.Balances            `json:"expect.endBalances,omitempty"`
	ExpectEndBalancesInclude interpreter.Balances            `json:"expect.endBalances.include,omitempty"`
	ExpectMovements          Movements                       `json:"expect.movements,omitempty"`
}

type TestCaseResult

type TestCaseResult struct {
	Skipped  bool                         `json:"skipped"`
	It       string                       `json:"it"`
	Pass     bool                         `json:"pass"`
	Balances interpreter.Balances         `json:"balances"`
	Vars     interpreter.VariablesMap     `json:"variables"`
	Meta     interpreter.AccountsMetadata `json:"metadata"`

	// Output:
	Postings []interpreter.Posting `json:"postings"`

	// Assertions
	FailedAssertions []AssertionMismatch[any] `json:"failedAssertions"`
}

type TestResult

type TestResult struct {
	Specs  Specs
	File   string
	Result TestCaseResult
}

type TxMetadataRow added in v0.0.25

type TxMetadataRow struct {
	Key   string            `json:"key"`
	Value interpreter.Value `json:"value"`
}

TxMetadataRow is a single transaction metadata entry. Like SetAccountMetadataRow, the value's type is known, so it is carried as a typed Value written in the tagged value format (e.g. {"type":"account","name":"x"}).

func (*TxMetadataRow) UnmarshalJSON added in v0.0.25

func (r *TxMetadataRow) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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