numscript test command
A JSON schema is available online, so that
you can have autocomplete and diagnostics in your editor.
Here’s the schema (using typescript notation):
$cap
.
We can express the relevant test cases in the following way:
testCase
. The preconditions in a testCase will be merged to the top-level preconditions (with the precedence being given to the inner preconditions).
For example, in the following specs:
@alice
‘s EUR/2
balance, resulting in:
variables
balances
metadata
expect.postings
or expect.missingFunds
, but there are also a few weaker assertion that might be useful when the exact postings are an implementation detail of your business logic.
expect.missingFunds
false
.
expect.postings
expect.missingFunds
assertion instead.
expect.txMetadata
set_tx_meta
). It’s a map from the metadata key to its (stringified) value.
expect.metadata
set_account_meta
). It’s a nested map from an account, to the metadata key to its (stringified) value.
accountsMeta
as well.
expect.volumes
@alice
has [EUR/2 100]
balance after the script is applied.
You might consider using this assertion when you only care about the end balance of an account, for example if you need to bring an account to a certain value (not less, not more), so you don’t care about how the postings are composed exactly.
expect.movements
@alice
sent [EUR/2 100]
to @bob
You might consider using this assertion when you care about the movements graph from-to accounts, and you don’t care about the order of the postings or the way they are split.