This is a beta version of the Solana Toolkit, and is
still a WIP. Please post all feedback as a GitHub issue
here.
The Solana test validator is a local emulator for the Solana blockchain,
designed to provide developers with a private and controlled environment for
building and testing Solana programs without the need to connect to a public
testnet or mainnet. It also includes full support of the standard
Solana RPC standard.
If you have the Solana CLI tool suite already installed, you can run the test
validator with the following command:
mucho validator --help
Install the Solana Toolkit by
running the following command:
This command initializes a new ledger and starts the local validator running at
http://localhost:8899, which can be used as your Solana RPC connection url.
By default the validator will resume an existing ledger, if one is found. To
reset the ledger, you can either manually delete the ledger directory or restart
the validator with the --reset flag:
mucho validator --reset
If the ledger exists, this command will reset the ledger to genesis, which
resets the state by deleting all existing accounts/programs and starting fresh.
To add existing onchain programs to your local environment, you can clone the
program with a new ledger. This is useful for testing interactions with other
programs that already exist on any other cluster.
To clone an account from another cluster:
mucho validator --reset \ --url CLUSTER_PROGRAM_IS_DEPLOYED_TO \ --clone PROGRAM_ADDRESS
To clone an upgradeable program and its executable data from another cluster:
mucho validator --reset \ --url CLUSTER_PROGRAM_IS_DEPLOYED_TO \ --clone-upgradeable-program PROGRAM_ADDRESS
If a ledger already exists in your working directory, you must reset the
ledger to be able to clone a program or account.
Solana has a feature set mechanism that allows you to enable or disable certain
blockchain features when running the test validator. By default, the test
validator runs with all runtime features activated.
To see all the runtime features available and their statuses:
solana feature status
To query a specific runtime feature's status:
solana feature status <ADDRESS>
To deactivate specific features in genesis:
This must be done on a fresh ledger, so if a ledger already exists in your
working directory you must add the --reset flag to reset to genesis.
mucho validator --reset \ --deactivate-feature <FEATURE_PUBKEY>
To deactivate multiple features in genesis:
mucho validator --reset \ --deactivate-feature <FEATURE_PUBKEY_1> <FEATURE_PUBKEY_2>
To check your current solana-test-validator version:
mucho validator --version
Your test validator runs on the same version as the Solana CLI installed and
configured for use.
To test your programs against different versions of the Solana runtime, you can
install multiple versions of the Solana CLI and switch between them using the
following command:
solana-install init <VERSION>
Make sure to reset your Solana test validator's ledger after changing versions
to ensure it runs a valid ledger without corruption.