Documentation
¶
Index ¶
- func RunSpecs(stdout io.Writer, stderr io.Writer, rawSpecs []RawSpec) bool
- func ShowDiff(w io.Writer, expected_ any, got_ any)
- type AssertionMismatch
- type ExpectedTxMeta
- type Movement
- type Movements
- type RawSpec
- type Specs
- type SpecsResult
- type TestCase
- type TestCaseResult
- type TestResult
- type TxMetadataRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssertionMismatch ¶
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 RawSpec ¶
type RawSpec struct {
NumscriptPath string
SpecsPath string
NumscriptContent string
SpecsFileContent []byte
}
func ReadSpecsFiles ¶
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 ¶
func Check(program parser.Program, specs Specs) (SpecsResult, interpreter.InterpreterError)
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
Click to show internal directories.
Click to hide internal directories.