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.
The validator uses the autogenerated Go Client package to communicate with the Mesh Server and assert that responses adhere to the Mesh interface specification.
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.
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.
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.
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.
The Construction API testing framework (the check:construction test in mesh-cli) uses a design pattern that allows for complex transaction construction orchestration.
When running the mesh-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.
You can find a full list of check: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.
The check:constructionend 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.
If there are no issues found while running check: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.
CLI for the Mesh APIUsage: mesh-cli [command]Available Commands: check:construction Check the correctness of a Mesh Construction API Implementation check:data Check the correctness of a Mesh Data API Implementation configuration:create Create a default configuration file at the provided path configuration:validate Ensure a configuration file at the provided path is formatted correctly help Help about any command utils:asserter-configuration Generate a static configuration file for the Asserter version Print mesh-cli version view:account View an account balance view:block View a block view:networks View all network statusesFlags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values. -h, --help help for mesh-cliUse "mesh-cli [command] --help" for more information about a command.
The check:construction command automatically tests aConstruction API implementation by creating and broadcasting transactionson a blockchain. In short, this tool generates new addresses, requestsfunds, constructs transactions, signs transactions, broadcasts transactions,and confirms transactions land on-chain. At each phase, a series of testsare run to ensure that intermediate representations are correct (i.e., doesan unsigned transaction return a superset of operations provided duringconstruction?).Check out the https://github.com/coinbase/mesh-cli/tree/master/examplesdirectory for examples of how to configure this test for Bitcoin andEthereum.Right now, this tool only supports transfer testing (for both account-basedand UTXO-based blockchains). However, we plan to add support for testingarbitrary scenarios (i.e., staking, governance).Usage: mesh-cli check:construction [flags]Flags: -h, --help help for check:constructionGlobal Flags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values.
Check all server responses are properly constructed, thatthere are no duplicate blocks and transactions, that blocks can be processedfrom genesis to the current block (re-orgs handled automatically), and thatcomputed balance changes are equal to balance changes reported by the node.When re-running this command, it will start where it left off if you specifysome data directory. Otherwise, it will create a new temporary directory and startagain from the genesis block. If you want to discard some number of blockspopulate the --start flag with some block index. Starting from a given indexcan be useful to debug a small range of blocks for issues but it is highlyrecommended you sync from start to finish to ensure all correctness checksare performed.By default, account balances are looked up at specific heights (instead ofonly at the current block). If your node does not support this functionalityset historical_balance_disabled to true. This will make reconciliation muchless efficient but it will still work.If check fails due to an INACTIVE reconciliation error (balance changed withoutany corresponding operation), the cli will automatically try to find the blockmissing an operation. If historical_balance_disabled is true, this automaticdebugging tool does not work.To debug an INACTIVE account reconciliation error without historical balance lookup,set the interesting accounts to the path of a JSON file containingaccounts that will be actively checked for balance changes at each block. Thiswill return an error at the block where a balance change occurred with nocorresponding operations.If your blockchain has a genesis allocation of funds and you sethistorical_balance_disabled to true, you must provide anabsolute path to a JSON file containing initial balances with thebootstrap balance config. You can look at the examples folder for an exampleof what one of these files looks like.Usage: mesh-cli check:data [flags]Flags: --end int block index to stop syncing (default -1) -h, --help help for check:data --start int block index to start syncing (default -1)Global Flags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values.
Create a default configuration file at the provided pathUsage: mesh-cli configuration:create [flags]Flags: -h, --help help for configuration:createGlobal Flags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values.
Validate the correctness of a configuration file at the provided pathUsage: mesh-cli configuration:validate [flags]Flags: -h, --help help for configuration:validateGlobal Flags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values.
In production deployments, it is useful to initialize the responseAsserter (https://github.com/coinbase/mesh-sdk-go/tree/master/asserter) usinga static configuration instead of initializing a configuration dynamicallyfrom the node. This allows a client to error on new types/statuses that mayhave been added in an update instead of silently erroring.To use this command, simply provide an absolute path as the argument for wherethe configuration file should be saved (in JSON).Usage: mesh-cli utils:asserter-configuration [flags]Flags: -h, --help help for utils:asserter-configurationGlobal Flags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values.
While debugging, it is often useful to inspect the stateof an account at a certain block. This command allows you to look upany account by providing a JSON representation of a types.AccountIdentifier(and optionally a height to perform the query).For example, you could run view:account '{"address":"interesting address"}' 1000to lookup the balance of an interesting address at block 1000. Allowing theaddress to specified as JSON allows for querying by SubAccountIdentifier.Usage: mesh-cli view:account [flags]Flags: -h, --help help for view:accountGlobal Flags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values.
While debugging a Data API implementation, it can be veryuseful to inspect block contents. This command allows you to fetch anyblock by index to inspect its contents. It uses thefetcher (https://github.com/coinbase/mesh-sdk-go/tree/master/fetcher) packageto automatically get all transactions in the block and assert the formatof the block is correct before printing.If this command errors, it is likely because the block you are trying tofetch is formatted incorrectly.Usage: mesh-cli view:block [flags]Flags: -h, --help help for view:blockGlobal Flags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values.
While debugging a Data API implementation, it can be veryuseful to view network(s) status. This command fetches the networkstatus from all available networks and prints it to the terminal.If this command errors, it is likely because the /network/* endpoints arenot formatted correctly.Usage: mesh-cli view:networks [flags]Flags: -h, --help help for view:networksGlobal Flags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values.
Print mesh-cli versionUsage: mesh-cli version [flags]Flags: -h, --help help for versionGlobal Flags: --configuration-file string Configuration file that provides connection and test settings. If you would like to generate a starter configuration file (populated with the defaults), run mesh-cli configuration:create. Any fields not populated in the configuration file will be populated with default values.