mesh-cli
tool uses the Mesh SDK (mesh-sdk-go) to validate the correctness of both Mesh Data API and Construction API implementations.
Correctness Checks
This tool performs a variety of correctness checks using the Mesh Server. A correctness check reviews the information in the blockchain and confirms that it matches the blockchain’s historical and current account balances. If any correctness check fails, the CLI will exit and print out a detailed message explaining the error.Response Correctness
The validator uses the autogenerated Go Client package to communicate with the Mesh Server and assert that responses adhere to the Mesh interface specification.Duplicate Hashes
The validator checks that a block hash or transaction hash is never duplicated.Non-negative Balances
The validator checks that an account balance does not go negative from any operations.Balance Reconciliation
Active Accounts
The CLI checks that the balance of an account computed by its operations is equal to the balance of the account according to the node. If this balance is not identical, the CLI will exit.Inactive Accounts
The CLI randomly checks the balances of accounts that aren’t involved in any transactions. The balances of accounts could change on the blockchain node without being included in an operation returned by the Mesh Data API. Recall that all balance-changing operations should be returned by the Mesh Data API.Configuration File
All mesh-cli parameters are populated from a configuration file (--configuration-file
) that you provide at runtime. If you do not provide a configuration file, the tool uses the default configuration, for example, default.json.
To run tests against Bitcoin and Ethereum implementations, see these config samples for mesh-bitcoin and mesh-ethereum.
For more information on how to create a configuration file, read How to Write a Configuration File for mesh-cli testing.
Disable Complex Checks
If you are just getting started with your implementation, you may want to disable balance tracking (did any address balance go below zero?) and reconciliation (does the balance I calculated match the balance returned by the/account/balance
endpoint?). Take a look at the simple configuration for an example of how to do this. For more details, read our How to Disable Complex Checks documentation.
Using environment variables
It’s possible to set the configuration file path using an environment variable instead of using a CLI flag. See an example below:Writing check:construction Tests
The Construction API testing framework (thecheck:construction
test in mesh-cli) uses a design pattern that allows for complex transaction construction orchestration.
Most engineers write their check:construction
tests using the Mesh Constructor DSL. We have examples of DSL files written for UTXO-based chains and account-based chains. For more information, read How to Write a Mesh DLS File.
End Conditions
When running themesh-cli
tool in a continuous integration (CI) job, it is usually desired to exit when certain conditions are met (or before then with an exit code of 1
). We provide this functionality through the use of end conditions which you can specify in your configuration file.
check:data
You can find a full list ofcheck:data
end conditions in How to Write a Configuration File, and in the Go Configuration website. If any end condition is satisfied, the tool exits and output the results in the results output file, if the results_output_file
field’s value is populated.
check:construction
Thecheck:construction
end condition is a map of workflow:count
that indicates how many of each workflow should be performed before check:construction
stops. For example, {"create_account": 5}
indicates that 5 create_account
workflows should be performed before stopping.
Unlike check:data
, all check:construction
end conditions must be satisfied before the mesh-cli
tool exits.
Status Codes
If there are no issues found while runningcheck:data
or check:construction
, the tests will exit with a 0
status code. If there are any issues, they will exit with a 1
status code. It can be useful to run this command as an integration test for any changes to your implementation.